Release New Version #5
This file contains hidden or 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: "Release New Version" | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
publish: | |
name: "Publish to NPM" | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout source code" | |
uses: actions/checkout@v2 | |
- name: "Set up Node.js" | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22.x | |
registry-url: "https://registry.npmjs.org/" | |
- name: "Install dependencies" | |
run: npm ci | |
- name: "Add node_modules/.bin to PATH" | |
run: echo "$(npm bin)" >> $GITHUB_PATH | |
- name: "Build package" | |
run: npm run build | |
- name: "Set Git user name and email" | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
- name: "Clean working directory" | |
run: git clean -fdx | |
- name: "Bump patch version" | |
run: npm version patch | |
- name: "Get new version" | |
id: get_version | |
run: echo "version=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
- name: "Push version bump commit and tag" | |
run: | | |
git push origin HEAD | |
git push origin --tags | |
- name: "Publish to NPM" | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: "Create GitHub Release" | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ steps.get_version.outputs.version }} | |
release_name: Release ${{ steps.get_version.outputs.version }} | |
body: | | |
``` | |
• See CHANGELOG.md for details | |
• Published by ${{ github.actor }} | |
``` | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |