-
Notifications
You must be signed in to change notification settings - Fork 17
276 lines (227 loc) · 8.56 KB
/
release.yml
File metadata and controls
276 lines (227 loc) · 8.56 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
publish-npm:
name: Publish to npm
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
pkg_version: ${{ steps.pkg-info.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Setup Node.js for npm publish
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Get package info
id: pkg-info
run: |
PKG_VERSION=$(node -p 'require("./package.json").version')
echo "version=${PKG_VERSION}" >> $GITHUB_OUTPUT
echo "Publishing hankweave@${PKG_VERSION}"
- name: Verify tag matches version
run: |
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
PKG_VERSION="${{ steps.pkg-info.outputs.version }}"
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
echo "Error: Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
exit 1
fi
echo "✓ Tag version matches package.json version"
- name: Run type check
run: bun run tc
- name: Run linting
run: bun run lint
- name: Verify package.json is configured for public release
run: |
PKG_NAME=$(node -p 'require("./package.json").name')
if [ "$PKG_NAME" != "hankweave" ]; then
echo "Error: package.json name is '$PKG_NAME', expected 'hankweave'"
echo "The sync workflow should have transformed package.json"
exit 1
fi
echo "✓ package.json configured correctly:"
echo " name: $PKG_NAME"
- name: Build
run: bun run build
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public
build-executables:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
include:
- target: linux-x64
os: ubuntu-latest
can_test: true
- target: linux-arm64
os: ubuntu-latest
can_test: false
cross_codex_tag: "0.104.0-linux-arm64"
- target: darwin-x64
os: macos-latest
can_test: false
cross_codex_tag: "0.104.0-darwin-x64"
- target: darwin-arm64
os: macos-latest
can_test: true
- target: windows-x64
os: windows-latest
can_test: true
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Install cross-platform codex binary
if: matrix.cross_codex_tag
shell: bash
run: |
# For cross-compilation: bun install only fetches the host platform's
# codex binary. Manually fetch the target platform's package and place
# it where the build script expects (node_modules/@openai/codex-<target>).
TARGET_DIR="node_modules/@openai/codex-${{ matrix.target }}"
mkdir -p "$TARGET_DIR"
npm pack "@openai/codex@${{ matrix.cross_codex_tag }}" --pack-destination /tmp
tar xzf /tmp/openai-codex-${{ matrix.cross_codex_tag }}.tgz -C "$TARGET_DIR" --strip-components=1
echo "✓ Installed cross-platform codex binary at $TARGET_DIR"
ls -la "$TARGET_DIR/vendor/" 2>/dev/null || echo " (no vendor dir — check package structure)"
- name: Build executable
run: bun scripts/build-executable.ts ${{ matrix.target }}
- name: Smoke test - Run --help
if: matrix.can_test
shell: bash
run: |
if [[ "${{ matrix.target }}" == "windows-x64" ]]; then
releases/hankweave.exe --help
else
./releases/hankweave --help
fi
- name: Upload executable artifact
uses: actions/upload-artifact@v4
with:
name: hankweave-${{ matrix.target }}
path: releases/hankweave${{ matrix.target == 'windows-x64' && '.exe' || '' }}
if-no-files-found: error
create-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [build-executables] # Only depends on binaries - release even if npm fails
if: always() && needs.build-executables.result == 'success'
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version from tag
id: version
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Version: ${VERSION}"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release-assets
# Rename artifacts to include target in filename
mv artifacts/hankweave-linux-x64/hankweave release-assets/hankweave-linux-x64
mv artifacts/hankweave-linux-arm64/hankweave release-assets/hankweave-linux-arm64
mv artifacts/hankweave-darwin-x64/hankweave release-assets/hankweave-darwin-x64
mv artifacts/hankweave-darwin-arm64/hankweave release-assets/hankweave-darwin-arm64
mv artifacts/hankweave-windows-x64/hankweave.exe release-assets/hankweave-windows-x64.exe
# Make them executable
chmod +x release-assets/hankweave-*
# List files
ls -lh release-assets/
- name: Extract changelog for this version
id: changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
# Check if RELEASE_NOTES.md exists (created by sync workflow)
if [ -f RELEASE_NOTES.md ]; then
echo "Using RELEASE_NOTES.md from sync workflow"
CHANGELOG_CONTENT=$(cat RELEASE_NOTES.md)
elif [ -f CHANGELOG.md ]; then
# Extract the section for this version from CHANGELOG.md
CHANGELOG_CONTENT=$(awk "/^## \[${VERSION}\]/,/^## \[/{if(/^## \[${VERSION}\]/) f=1; else if(/^## \[/) f=0; if(f && !/^## \[${VERSION}\]/) print}" CHANGELOG.md)
fi
if [ -z "$CHANGELOG_CONTENT" ]; then
echo "No changelog entry found for version ${VERSION}, using default notes"
CHANGELOG_CONTENT="See commits for details."
fi
# Save to file for release
cat > release-notes.md << 'NOTES_EOF'
## Installation
**Via npm:**
```bash
npm install -g hankweave
# or
npx hankweave --init
```
**Via Standalone Executable:**
Download the binary for your platform below, make it executable, and run it.
## What's Changed
NOTES_EOF
echo "$CHANGELOG_CONTENT" >> release-notes.md
cat >> release-notes.md << 'NOTES_EOF'
## Platform-Specific Instructions
### macOS
- **Apple Silicon (M1/M2/M3)**: `hankweave-darwin-arm64`
- **Intel**: `hankweave-darwin-x64`
After downloading:
```bash
xattr -d com.apple.quarantine hankweave-darwin-arm64
chmod +x hankweave-darwin-arm64
./hankweave-darwin-arm64 --help
```
### Linux
- **x64**: `hankweave-linux-x64`
- **ARM64**: `hankweave-linux-arm64`
```bash
chmod +x hankweave-linux-x64
./hankweave-linux-x64 --help
```
### Windows
- **x64**: `hankweave-windows-x64.exe`
```powershell
.\hankweave-windows-x64.exe --help
```
NOTES_EOF
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.version }}
name: Hankweave v${{ steps.version.outputs.version }}
body_path: release-notes.md
draft: false
prerelease: false
files: |
release-assets/hankweave-linux-x64
release-assets/hankweave-linux-arm64
release-assets/hankweave-darwin-x64
release-assets/hankweave-darwin-arm64
release-assets/hankweave-windows-x64.exe