Node.js Package Release #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: Node.js Package Release | |
on: | |
workflow_dispatch: | |
inputs: | |
semver: | |
description: "The semantic version to bump (patch, minor, major)" | |
required: true | |
default: "patch" | |
nodeVersion: | |
description: "The Node.js version to use" | |
required: true | |
default: "16.x" | |
jobs: | |
release: | |
permissions: | |
contents: write | |
# Use the semver as the job name | |
name: "Release ${{ github.event.inputs.semver }}" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup SSH | |
uses: webfactory/ssh-agent@d4b9b8ff72958532804b70bbe600ad43b36d5f2e | |
with: | |
ssh-private-key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
- uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{ secrets.ACTIONS_DEPLOY_KEY }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ github.event.inputs.nodeVersion }} | |
registry-url: "https://registry.npmjs.org" | |
- name: Bump version and push tag | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
npm version ${{ github.event.inputs.semver }} | |
git push && git push --tags | |
- name: Publish | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
- run: | | |
echo VERSION=$(cat package.json | grep version | tr -d " " | cut -d":" -f2 | tr -d "\",") >> $GITHUB_ENV | |
shell: bash | |
name: Set version as env var | |
- uses: actions/create-release@v1 | |
name: Release | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.VERSION }} | |
release_name: Release ${{ env.VERSION }} | |
draft: false | |
prerelease: false |