Skip to content

Time to Snak & Roll #14

Time to Snak & Roll

Time to Snak & Roll #14

Workflow file for this run

name: NPM publish
on:
release:
types: [published]
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}
# install Node.js
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm install
# set up git since we will later push to the repo
- run: git config --global user.name "GitHub CI bot"
- run: git config --global user.email "[email protected]"
# upgrade npm version in package.json to the tag used in the release.
- run: npm version --no-git-tag-version ${{ github.event.release.tag_name }}
# build the project
- run: npm run build
# run tests just in case
- run: npm test
- run: npm config set '//registry.npmjs.org/:_authToken' "${{ secrets.NPM_TOKEN }}"
# publish to NPM -> there is one caveat, continue reading for the fix
- run: npm publish
env:
# Use a token to publish to NPM. See below for how to set it up
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# push the version changes to GitHub
- run: git push
env:
# The secret is passed automatically. Nothing to configure.
github-token: ${{ secrets.GITHUB_TOKEN }}