-
Notifications
You must be signed in to change notification settings - Fork 0
157 lines (138 loc) · 5.32 KB
/
Copy pathpublish-alpha.yml
File metadata and controls
157 lines (138 loc) · 5.32 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Publish Alpha
on:
workflow_dispatch:
concurrency: ${{ github.workflow }}
permissions:
contents: write
jobs:
publish-alpha:
name: Publish Alpha
runs-on: ubuntu-latest
environment: npm
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- name: Setup pnpm
uses: pnpm/action-setup@v6
with:
version: 10
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
cache: pnpm
registry-url: https://registry.npmjs.org
- name: Install Dependencies
run: pnpm install --frozen-lockfile
- name: Validate npm token
run: |
if [ -z "${NPM_TOKEN:-}" ]; then
echo "::error::NPM_TOKEN secret is required for publishing."
exit 1
fi
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Test
run: pnpm test
- name: Typecheck
run: pnpm typecheck
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Pack Check
run: pnpm pack:check
- name: Configure npm auth
run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > "$HOME/.npmrc"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish Alpha
run: pnpm release:alpha
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set alpha dist-tags
run: |
for dir in packages/core packages/dom packages/router packages/testing; do
name=$(node -p "require('./$dir/package.json').name")
version=$(node -p "require('./$dir/package.json').version")
npm dist-tag add "$name@$version" alpha
echo "Set $name alpha → $version"
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Push git tags
run: |
for dir in packages/core packages/dom packages/router packages/testing; do
name=$(node -p "require('./$dir/package.json').name")
version=$(node -p "require('./$dir/package.json').version")
tag="$name@$version"
remote_sha=$(git ls-remote --tags origin "refs/tags/$tag" | awk '{print $1}')
if [ -n "$remote_sha" ]; then
local_sha=$(git rev-list -n 1 "$tag" 2>/dev/null || echo "")
if [ "$remote_sha" = "$local_sha" ]; then
echo "⏭️ git tag $tag already exists at $remote_sha on remote, skipping"
else
echo "::error::git tag $tag exists on remote at $remote_sha but local is $local_sha"
exit 1
fi
else
if ! git rev-parse "$tag" >/dev/null 2>&1; then
git tag "$tag"
echo "Created local tag $tag"
fi
git push origin "$tag"
echo "✅ git tag $tag pushed"
fi
done
- name: Verify alpha dist-tags
run: |
for dir in packages/core packages/dom packages/router packages/testing; do
name=$(node -p "require('./$dir/package.json').name")
expected=$(node -p "require('./$dir/package.json').version")
attempt=0
max_attempts=25
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
actual=$(npm view "$name" dist-tags.alpha --prefer-online 2>/dev/null || npm view "$name" dist-tags.alpha)
if [ "$actual" = "$expected" ]; then
echo "✅ $name alpha dist-tag: $actual (attempt $attempt)"
break
fi
echo "Attempt $attempt: $name — expected $expected, got $actual"
if [ $attempt -lt $max_attempts ]; then
sleep $((RANDOM % 6 + 10))
fi
done
if [ "$actual" != "$expected" ]; then
echo "::error::alpha dist-tag for $name is $actual, expected $expected (after $max_attempts attempts)"
exit 1
fi
done
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Verify git tags on remote
run: |
for dir in packages/core packages/dom packages/router packages/testing; do
name=$(node -p "require('./$dir/package.json').name")
version=$(node -p "require('./$dir/package.json').version")
tag="$name@$version"
attempt=0
max_attempts=25
while [ $attempt -lt $max_attempts ]; do
attempt=$((attempt + 1))
if git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
remote_sha=$(git ls-remote --tags origin "refs/tags/$tag" | awk '{print $1}')
echo "✅ $tag found on remote at $remote_sha (attempt $attempt)"
break
fi
echo "Attempt $attempt: $tag not yet found on remote"
if [ $attempt -lt $max_attempts ]; then
sleep $((RANDOM % 6 + 10))
fi
done
if ! git ls-remote --exit-code --tags origin "refs/tags/$tag" >/dev/null 2>&1; then
echo "::error::git tag $tag not found on remote (after $max_attempts attempts)"
exit 1
fi
done