Merge pull request #19 from YuriSamp/gitignore #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish Package to npmjs | |
on: | |
push: | |
branches: | |
- "main" | |
paths-ignore: | |
- ".github**" | |
- "README.md" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8.6.8 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "20.10.0" | |
registry-url: "https://registry.npmjs.org" | |
- run: pnpm i --frozen-lockfile | |
- name: Set git configuration | |
run: | | |
git config user.name "${GITHUB_ACTOR}" | |
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: "Get next version" | |
id: version | |
run: | | |
DEFAULT_VERSION=1.0.14 | |
LATEST_TAG=$(git describe --tags --abbrev=0 || echo $DEFAULT_VERSION) | |
echo "Current version ${LATEST_TAG}" | |
NEXT_VERSION=$(echo ${LATEST_TAG} | awk -F. -v OFS=. '{$NF += 1 ; print}') | |
echo "Next version ${NEXT_VERSION}" | |
echo "value=${NEXT_VERSION}" >> $GITHUB_OUTPUT | |
- name: Update version | |
run: pnpm version ${{ steps.version.outputs.value }} | |
- name: Create tag | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/${{ steps.version.outputs.value }}', | |
sha: context.sha | |
}) | |
- run: pnpm build | |
- run: pnpm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Create Release | |
uses: actions/create-release@latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.version.outputs.value }} | |
release_name: Release ${{ steps.version.outputs.value }} |