Skip to content

add test step

add test step #32

Workflow file for this run

name: Publish to NPM
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
# Fetch the last 2 commits instead of just 1. (Fetching just 1 commit
# would overwrite the whole history)
fetch-depth: 2
- name: Use Node.js (22.x)
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: 'https://registry.npmjs.org'
cache: 'npm'
- run: npm ci
- run: npm run bump
- name: Get last commit message
id: last-commit
run: |
echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
echo "author=$(git log -1 --pretty=\"%an <%ae>\")" >> $GITHUB_OUTPUT
# Commit changes to package.json and package-lock.json back to the
# repository Since we install dependencies with `npm ci`, the only update
# to package-lock should be updating the version of this package. If we
# don't commit that, the next dev to run `npm install` in the repo will
# have a package-lock.json change that updates the version to... the N-1
# version.
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_author: ${{ steps.last-commit.outputs.author }}
file_pattern: 'package.json package-lock.json'
commit_message: ${{ steps.last-commit.outputs.message }}
commit_options: '--amend --no-edit'
push_options: '--force'
skip_fetch: true
- run: npm publish --access public --loglevel verbose
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}