Merge pull request #27 from gnk-softworks/next #10
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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
if: "${{ !contains(github.event.head_commit.message, 'ci: publish version') }}" | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Set Git user | |
run: | | |
git config user.name "narvik-publish-action" | |
# https://api.github.com/users/github-actions%5Bbot%5D | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
- name: Bump version | |
run: npm version patch --no-git-tag-version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Build package | |
run: npm run build | |
- name: Publish to NPM | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Commit version bump | |
run: | | |
git add package.json package-lock.json | |
git commit -m "ci: publish version $(npm pkg get version | tr -d '\n')" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create and push tag | |
run: | | |
version=$(jq --raw-output '."version"' <package.json) | |
git tag "v$version" | |
git push origin "v$version" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |