-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (63 loc) · 2.25 KB
/
Copy pathrelease.yml
File metadata and controls
75 lines (63 loc) · 2.25 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Release
# Publishes @getpipher/welcome to npm on tag push (v*) AND creates a GitHub
# Release (auto-generated notes). Uses the getpipher org secret NPM_TOKEN
# (granular npm token, Read-and-write, scoped to @getpipher, with
# "Bypass 2FA" — no OTP needed). Inherited by all getpipher repos.
# gh secret set NPM_TOKEN --org getpipher
# The GitHub Release step uses the auto-provided github.token (no secret).
#
# Shape: cursor/vision/term (pnpm + node 20 + typecheck + test:run gates +
# idempotent npm publish) + armory-todo (idempotent gh release create).
# Both the publish and the release steps are idempotent — safe to re-run.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write # needed for `gh release create`
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
with:
version: 10
- uses: actions/setup-node@v7
with:
node-version: "24"
cache: pnpm
registry-url: https://registry.npmjs.org
- run: pnpm install --frozen-lockfile
- run: pnpm typecheck
- run: pnpm test:run
- name: Skip if already published
id: check
run: |
set -u
ver=$(node -p "require('./package.json').version")
pkg=$(node -p "require('./package.json').name")
existing=$(npm view "$pkg@$ver" version 2>/dev/null || true)
if [ "$existing" = "$ver" ]; then
echo "::notice::$pkg@$ver already on npm — skipping publish"
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "Publishing $pkg@$ver"
echo "skip=false" >> "$GITHUB_OUTPUT"
fi
- name: Publish
if: steps.check.outputs.skip != 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
- name: Create GitHub Release
if: success()
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="${GITHUB_REF_NAME}"
if gh release view "$tag" >/dev/null 2>&1; then
echo "::notice::Release $tag already exists — skipping"
else
gh release create "$tag" --generate-notes --title "$tag"
fi