v2.0.6 #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to NPM | |
on: | |
release: | |
types: [published] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '18.18.0' | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
- name: Validate package version | |
run: | | |
PACKAGE_VERSION=$(node -p "require('./package.json').version") | |
RELEASE_VERSION=${GITHUB_REF#refs/tags/v} | |
if [ "$PACKAGE_VERSION" != "$RELEASE_VERSION" ]; then | |
echo "Package version ($PACKAGE_VERSION) does not match release version ($RELEASE_VERSION)" | |
exit 1 | |
fi | |
- name: Install dependencies | |
run: npm ci | |
- name: Run tests | |
run: npm test | |
- name: Build package | |
run: npm run build | |
- name: Publish to NPM | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |