Skip to content

Publish

Publish #9

Workflow file for this run

env: {}
# FILE GENERATED WITH: npx ghat fregante/ghatemplates/npm-publish
# SOURCE: https://github.com/fregante/ghatemplates
# Collaborators can publish a new version of what's on master via "workflow_dispatch"
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
name: Publish
on:
workflow_dispatch:
inputs:
Version:
description: 'Version accepted by `npm version *`'
required: true
jobs:
NPM:
runs-on: ubuntu-latest
# https://docs.npmjs.com/generating-provenance-statements#example-github-actions-workflow
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
registry-url: https://registry.npmjs.org
- run: npm ci || npm install
- uses: fregante/setup-git-user@v2
- name: Create version
# Get the generated version, this enables support for keywords: `npm version patch`
run: |
VERSION="$(npm version "${{ github.event.inputs.Version }}")"
echo "VERSION=$VERSION" >> $GITHUB_ENV
- run: npm publish --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- run: git push --follow-tags
- run: gh release create "$VERSION" --generate-notes
env:
GH_TOKEN: ${{ github.token }}