-
Notifications
You must be signed in to change notification settings - Fork 4
249 lines (210 loc) · 6.89 KB
/
release.yml
File metadata and controls
249 lines (210 loc) · 6.89 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Tag to release (e.g., v1.0.0)'
required: true
type: string
jobs:
# Validate the release before proceeding
validate:
name: Validate Release
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.get_version.outputs.version }}
tag: ${{ steps.get_version.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get version from tag
id: get_version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
TAG="${{ github.event.inputs.tag }}"
else
TAG="${GITHUB_REF#refs/tags/}"
fi
VERSION="${TAG#v}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Release version: ${VERSION}"
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Verify package.json version matches tag
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
TAG_VERSION="${{ steps.get_version.outputs.version }}"
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
echo "::error::Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
exit 1
fi
echo "✅ Version verified: $PACKAGE_VERSION"
- name: Check for changelog entry
run: |
if [ -f CHANGELOG.md ]; then
if grep -q "${{ steps.get_version.outputs.version }}" CHANGELOG.md; then
echo "✅ Changelog entry found"
else
echo "::warning::No changelog entry found for version ${{ steps.get_version.outputs.version }}"
fi
else
echo "::warning::CHANGELOG.md not found"
fi
# Run full test suite
test:
name: Full Test Suite
needs: validate
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
node: [20, 22, 24]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- uses: mlugg/setup-zig@v2
with:
version: "0.15.2"
- name: Install dependencies
run: |
pip install "numpy>=2"
npm install
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run full CI test suite
run: npm run test:ci
# Build production bundles
build:
name: Build Production Bundles
needs: [validate, test]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
- uses: mlugg/setup-zig@v2
with:
version: "0.15.2"
- name: Install dependencies
run: npm install
- name: Build all bundles
run: npm run build
- name: Verify build artifacts
run: |
echo "## Build Artifacts" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| File | Size | Gzipped |" >> $GITHUB_STEP_SUMMARY
echo "|------|------|---------|" >> $GITHUB_STEP_SUMMARY
for file in dist/*.js dist/*.cjs; do
if [ -f "$file" ]; then
size=$(ls -lh "$file" | awk '{print $5}')
gzip -c "$file" > "$file.gz"
gzsize=$(ls -lh "$file.gz" | awk '{print $5}')
rm "$file.gz"
echo "| $(basename $file) | $size | $gzsize |" >> $GITHUB_STEP_SUMMARY
fi
done
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
retention-days: 90
# Publish to npm (requires manual approval via 'release' environment)
publish:
name: Publish to npm
needs: [validate, test, build]
runs-on: ubuntu-latest
environment:
name: release
url: https://www.npmjs.com/package/numpy-ts
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
- uses: mlugg/setup-zig@v2
with:
version: "0.15.2"
- name: Upgrade npm (required for OIDC trusted publishing)
run: npm i -g npm@^11.5.1
- name: Show npm version (debug)
run: npm --version
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
- name: Publish to npm
run: npm publish --access public
- name: Create release summary
run: |
echo "## 🚀 Release Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag**: ${{ needs.validate.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **npm**: https://www.npmjs.com/package/numpy-ts/v/${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY
# Create GitHub Release
github-release:
name: Create GitHub Release
needs: [validate, publish]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: dist-${{ needs.validate.outputs.version }}
path: dist/
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.validate.outputs.tag }}
draft: false
prerelease: ${{ contains(needs.validate.outputs.version, '-') }}
files: |
dist/*.js
dist/*.cjs
dist/*.map
token: ${{ secrets.GITHUB_TOKEN }}
- name: Post release summary
run: |
echo "## ✅ GitHub Release Created" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Release**: ${{ needs.validate.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **URL**: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.validate.outputs.tag }}" >> $GITHUB_STEP_SUMMARY