Skip to content

Make publish workflow easier to reuse #1

Make publish workflow easier to reuse

Make publish workflow easier to reuse #1

Workflow file for this run

# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
name: NPM Publish
run-name: ${{ inputs.description }} (${{ inputs.release_type }}) release by @${{ github.actor }}
on:
workflow_call:
inputs:
description:
description: Description
required: false
type: string
release_type:
description: Release Type
required: true
default: patch
type: string
secrets:
npm_token:
required: true
GITHUB_TOKEN:

Check failure on line 22 in .github/workflows/publish.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish.yml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
workflow_dispatch:
inputs:
description:
description: Description
required: false
type: string
release_type:
description: Release Type
required: true
default: patch
type: choice
options:
- patch
- minor
- major
jobs:
publish-to-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
- uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: pnpm
registry-url: https://registry.npmjs.org/
scope: "@kingstinct"
- run: git config user.name "$(git log -n 1 --pretty=format:%an)"
- run: git config user.email "$(git log -n 1 --pretty=format:%ae)"
- run: pnpm install --frozen-lockfile
- run: echo "versionTag=`npm version ${{ github.event.inputs.release_type }} -m "%s ${{ github.event.inputs.description }}"`" >> $GITHUB_ENV
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
- run: git push --follow-tags --no-verify
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ env.versionTag }} ${{ github.event.inputs.description }}
tag_name: ${{ env.versionTag }}
generate_release_notes: true