Skip to content

Merge pull request #135 from ether/fix/publish-workflow #279

Merge pull request #135 from ether/fix/publish-workflow

Merge pull request #135 from ether/fix/publish-workflow #279

Workflow file for this run

# This workflow will run tests using node and then publish a package to the npm registry when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: Node.js Package
on:
pull_request:
push:
branches:
- main
- master
env:
PNPM_HOME: ~/.pnpm-store
jobs:
test:
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v6
- uses: actions/cache@v5
name: Cache pnpm store
with:
path: ${{ env.PNPM_HOME }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: pnpm/action-setup@v6
name: Install pnpm
with:
run_install: false
-
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
-
run: pnpm i
-
run: pnpm run build
-
run: pnpm run lint
publish-npm:
if: github.event_name == 'push'
needs: test
runs-on: ubuntu-latest
steps:
-
uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/cache@v5
name: Cache pnpm store
with:
path: ${{ env.PNPM_HOME }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: pnpm/action-setup@v6
name: Install pnpm
with:
run_install: false
-
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org/
-
name: Tag the version in package.json (if not already tagged)
run: |
PKG_VER=$(node -p "require('./package.json').version")
if git rev-parse -q --verify "refs/tags/v${PKG_VER}" >/dev/null; then
echo "v${PKG_VER} already tagged; nothing to do."
exit 0
fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git tag "v${PKG_VER}"
git push origin "v${PKG_VER}"
-
run: pnpm i --frozen-lockfile
-
run: pnpm publish --no-git-checks
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}