Skip to content

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js

Publishing action

acamposuribe31e98c5f7edc
diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml
new file mode 100644
index 0000000..5ccff5a
--- /dev/null
+++ b/.github/workflows/publish-npm.yml
@@ -0,0 +1,46 @@
+name: Publish to npm
+
+on:
+ push:
+ tags:
+ - "v*"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ id-token: write
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 20
+ registry-url: https://registry.npmjs.org
+
+ - name: Ensure tag matches package version
+ run: |
+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
+ TAG_VERSION=${GITHUB_REF_NAME#v}
+ if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
+ echo "Tag version ($TAG_VERSION) does not match package.json version ($PACKAGE_VERSION)"
+ exit 1
+ fi
+
+ - name: Install dependencies
+ run: npm ci
+
+ - name: Test
+ run: npm test
+
+ - name: Build library
+ run: npx rollup --config
+
+ - name: Publish package
+ run: npm publish --provenance
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}