-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (50 loc) · 1.86 KB
/
Copy pathrelease.yaml
File metadata and controls
53 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
name: Release
on:
# Publish whenever a version tag is pushed, e.g. v1.2.3 or v1.2.3-rc.1.
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
# contents: write -> create the GitHub release; id-token: write -> npm provenance.
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 10
env:
# Tags with a hyphen suffix (e.g. -rc.1) are prereleases.
PRERELEASE: ${{ contains(github.ref_name, '-') }}
steps:
- uses: actions/checkout@v7.0.1
- uses: actions/setup-node@v7.0.0
with:
node-version: 24
registry-url: https://registry.npmjs.org # Wires up .npmrc for publish
- run: npm install
- run: npm run typecheck
- run: npm run build # Compile src/ to dist/ before publishing
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
# rc tags become GitHub prereleases; stable tags become full releases.
# Skip if the release already exists so reruns stay idempotent.
if gh release view "$GITHUB_REF_NAME" >/dev/null 2>&1; then
echo "Release $GITHUB_REF_NAME already exists"
elif [ "$PRERELEASE" = "true" ]; then
gh release create "$GITHUB_REF_NAME" --generate-notes --verify-tag --prerelease
else
gh release create "$GITHUB_REF_NAME" --generate-notes --verify-tag
fi
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
# rc tags publish under the "next" dist-tag, stable tags under "latest".
# --access public is required for provenance on a new package.
if [ "$PRERELEASE" = "true" ]; then
npm publish --provenance --access public --tag next
else
npm publish --provenance --access public
fi