Skip to content

Commit bccf33f

Browse files
authored
WEBDEV-7982: Add npm publishing GH actions (#15)
* Add npm publishing GH actions * Update actions and use GITHUB_TOKEN * Consolidate npm-publish script * Linting
1 parent 3b5527b commit bccf33f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/npm-publish.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Publish to npm whenever a release/prerelease is published
2+
name: Publish release to npm
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
id-token: write
13+
steps:
14+
- uses: actions/checkout@v6
15+
- uses: actions/setup-node@v6
16+
with:
17+
node-version: 24
18+
registry-url: 'https://registry.npmjs.org'
19+
- run: npm ci
20+
- run: npm test
21+
# Check if the release tag is a semver release (e.g., v1.2.3) or a pre-release (e.g., v1.2.3-alpha)
22+
- run: |
23+
if [[ ${{ github.event.release.tag_name }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
24+
npm publish --provenance
25+
else
26+
npm publish --provenance --tag alpha
27+
fi

0 commit comments

Comments
 (0)