Repository navigation
233 lines (215 loc) · 8.51 KB
/
Copy pathrelease.yml
File metadata and controls
233 lines (215 loc) · 8.51 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
# Builds the agentflex Rust binary for six targets and publishes the npm
# platform packages on version tags.
#
# Layout note: sesskit-stats is a git dependency pinned by `rev` in
# Cargo.toml, so the release builds exactly the reviewed SessKit commit.
# AgentFlex is checked out under $GITHUB_WORKSPACE/AgentFlex and every cargo
# step runs with working-directory AgentFlex.
#
# Linux choice: x86_64/aarch64-unknown-linux-musl targets produce fully
# static binaries (musl libc linked in, no glibc dependency), so the same
# artifact runs on any distro regardless of the runner's glibc version.
# Native runners are used for every target (macos-15 = arm64, macos-15-intel =
# x64, ubuntu-24.04-arm = arm64, windows-11-arm = arm64) instead of
# cross-compilation, avoiding cross toolchains and emulation.
name: release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
release_tag:
description: "Existing release tag (e.g. v0.3.2) to publish to npm from its GitHub Release binaries"
required: false
type: string
# `id-token: write` is required for npm OIDC Trusted Publishing and provenance (Sigstore).
# `contents: write` uploads the six prebuilt binaries to the tag's GitHub
# release (Homebrew and curl installs download from there).
permissions:
contents: write
id-token: write
jobs:
build:
name: build (${{ matrix.target }})
if: ${{ !inputs.release_tag }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-15
target: aarch64-apple-darwin
exe: agentflex
asset: aarch64-apple-darwin
# NOTE: macos-13 (last Ventura x64 label) is retired on GitHub-hosted
# runners (actionlint: unknown label); macos-15-intel is the
# current x64 macOS runner.
- os: macos-15-intel
target: x86_64-apple-darwin
exe: agentflex
asset: x86_64-apple-darwin
- os: ubuntu-24.04
target: x86_64-unknown-linux-musl
exe: agentflex
asset: x86_64-unknown-linux-musl
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
exe: agentflex
asset: aarch64-unknown-linux-musl
- os: windows-latest
target: x86_64-pc-windows-msvc
exe: agentflex.exe
asset: x86_64-pc-windows-msvc.exe
- os: windows-11-arm
target: aarch64-pc-windows-msvc
exe: agentflex.exe
asset: aarch64-pc-windows-msvc.exe
defaults:
run:
working-directory: AgentFlex
shell: bash
steps:
- name: Check out AgentFlex
uses: actions/checkout@v4
with:
path: AgentFlex
- name: Install musl tools (Linux static builds)
if: endsWith(matrix.target, 'musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Stage binary under canonical name
run: |
mkdir -p dist-bins
cp "target/${{ matrix.target }}/release/${{ matrix.exe }}" "dist-bins/${{ matrix.asset }}"
# Each runner is native to its target, so this executes every binary
# (including Windows and Linux arm64) on real hardware of that architecture.
- name: Smoke-test the binary on its own architecture
run: |
bin="target/${{ matrix.target }}/release/${{ matrix.exe }}"
"$bin" --version
"$bin" --json > smoke.json
"$bin" --png smoke.png
test -s smoke.png
head -c 160 smoke.json; echo
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: bin-${{ matrix.target }}
path: AgentFlex/dist-bins/${{ matrix.asset }}
if-no-files-found: error
retention-days: 7
publish:
name: publish npm packages
needs: build
if: >-
always() && (
(startsWith(github.ref, 'refs/tags/v') && needs.build.result == 'success') ||
(github.event_name == 'workflow_dispatch' && inputs.release_tag != '' && needs.build.result == 'skipped')
)
runs-on: ubuntu-24.04
defaults:
run:
working-directory: AgentFlex
shell: bash
steps:
- name: Check out AgentFlex (packaging scripts)
uses: actions/checkout@v4
with:
ref: ${{ inputs.release_tag || github.ref }}
path: AgentFlex
- name: Download built binaries
if: ${{ !inputs.release_tag }}
uses: actions/download-artifact@v4
with:
pattern: bin-*
path: AgentFlex/bins
merge-multiple: true
- name: Download binaries from existing GitHub release
if: ${{ inputs.release_tag != '' }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
mkdir -p bins release-dl
gh release download "$RELEASE_TAG" --dir release-dl --pattern "agentflex-*"
for f in release-dl/agentflex-*; do
base="$(basename "$f")"
target_name="${base#agentflex-}"
cp "$f" "bins/$target_name"
case "$target_name" in
*.exe) ;;
*) chmod +x "bins/$target_name" ;;
esac
done
ls -la bins
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: "24"
registry-url: "https://registry.npmjs.org"
package-manager-cache: false
- name: Ensure npm supports OIDC trusted publishing
run: |
npm install -g npm@^11.5.1
npm --version
- name: Check tag matches Cargo.toml version
env:
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
tag="${RELEASE_TAG:-$GITHUB_REF_NAME}"
case "$tag" in
v*) ;;
*) echo "error: release_tag '$tag' must start with v"; exit 1 ;;
esac
tag_version="${tag#v}"
cargo_version="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)"
echo "tag: $tag_version, Cargo.toml: $cargo_version"
test "$tag_version" = "$cargo_version" || { echo "error: tag v$tag_version does not match Cargo.toml version $cargo_version"; exit 1; }
- name: Assemble npm packages
env:
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
tag="${RELEASE_TAG:-$GITHUB_REF_NAME}"
node scripts/build-npm.mjs --version "${tag#v}" --bin-dir bins
# The tag release carries the six prebuilt binaries (Homebrew and
# curl installs download from there; npm alone is not enough).
# Upload before npm publish so an npm auth failure never leaves
# flex.sh or Homebrew without release binaries; created on demand so
# a rerun never fails on an existing release.
- name: Upload binaries to the GitHub release
if: ${{ !inputs.release_tag }}
run: |
tag="${GITHUB_REF_NAME}"
mkdir -p release-assets
for f in bins/*; do
cp "$f" "release-assets/agentflex-$(basename "$f")"
done
if ! gh release view "$tag" >/dev/null 2>&1; then
gh release create "$tag" --title "agentflex ${tag#v}" --generate-notes
fi
gh release upload "$tag" release-assets/agentflex-* --clobber
env:
GH_TOKEN: ${{ github.token }}
# Platform packages first, the launcher last, so the launcher never points
# at versions that are not on the registry. Versions already published
# (for example by an interrupted run) are skipped, so reruns are safe.
# Windows packages are named `windows-*`: names containing `win32` are
# rejected by npm's spam detection (verified 2026-11-04).
# Published via npm OIDC Trusted Publishing (do not set NODE_AUTH_TOKEN).
- name: Publish to npm
env:
RELEASE_TAG: ${{ inputs.release_tag }}
run: |
tag="${RELEASE_TAG:-$GITHUB_REF_NAME}"
version="${tag#v}"
for pkg in agentflex-darwin-arm64 agentflex-darwin-x64 agentflex-linux-x64 agentflex-linux-arm64 agentflex-windows-x64 agentflex-windows-arm64 agentflex; do
if npm view "$pkg@$version" version >/dev/null 2>&1; then
echo "skip $pkg@$version (already published)"
continue
fi
npm publish --access public "npm/dist/$pkg"
done