Create Release Note and Publish to npm #3
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: Create Release Note and Publish to npm | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Please enter the version" | |
required: true | |
type: string | |
permissions: | |
contents: read | |
jobs: | |
release: | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set Node.js Version | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 21 | |
cache: npm | |
- name: Update package.json version | |
run: | | |
node -e "let fs = require('fs'); let pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8')); pkg.version = process.env.VERSION; fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2));" | |
env: | |
VERSION: ${{ github.event.inputs.version }} | |
- name: Commit Changes | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add package.json | |
git commit -m "Update version to ${{ github.event.inputs.version }}" | |
git push | |
env: | |
VERSION: ${{ github.event.inputs.version }} | |
# - name: Publish to npm | |
# env: | |
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# run: | | |
# npm install | |
# npm publish --access public | |
- name: Create Release Tag And Note | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
version: ${{ github.event.inputs.version }} | |
uses: release-drafter/release-drafter@v6 | |
with: | |
tag: ${{ env.version }} | |
name: v${{ env.version }} | |
version: ${{ env.version }} | |
publish: true |