-
Notifications
You must be signed in to change notification settings - Fork 1
403 lines (354 loc) · 14.8 KB
/
Copy pathrelease.yml
File metadata and controls
403 lines (354 loc) · 14.8 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
name: Release
on:
release:
types: [published]
workflow_dispatch:
# Skip beta/prerelease tags — handled by release-beta.yml
permissions:
contents: write
id-token: write
attestations: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.name }}
if: github.event_name == 'workflow_dispatch' || !github.event.release.prerelease
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- name: aarch64-macos
runner: macos-14
target: aarch64-apple-darwin
bottle_tag: arm64_sonoma
archive: tar.gz
- name: x86_64-linux
runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
bottle_tag: x86_64_linux
archive: tar.gz
- name: aarch64-linux
runner: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
archive: tar.gz
- name: x86_64-windows
runner: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
cache-dependency-path: dashboard/package-lock.json
- name: Build dashboard assets
working-directory: dashboard
run: |
npm ci
npm run build
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-${{ matrix.target }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-release-
${{ runner.os }}-${{ matrix.target }}-cargo-
- name: Build release binary
run: cargo build --release --target ${{ matrix.target }}
- name: Get version
id: version
shell: bash
run: |
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then
TAG="dry-run-${GITHUB_SHA::7}"
VERSION="${TAG#v}"
else
TAG="${GITHUB_REF_NAME}"
VERSION="${GITHUB_REF_NAME#v}"
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
# --- Binary archive (all platforms) ---
- name: Package binary (unix)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../tracedecay-${{ steps.version.outputs.tag }}-${{ matrix.name }}.tar.gz tracedecay
cd ../../..
- name: Generate archive attestation (unix)
if: matrix.archive == 'tar.gz' && github.event_name == 'release'
uses: actions/attest@v4
with:
subject-path: tracedecay-${{ steps.version.outputs.tag }}-${{ matrix.name }}.${{ matrix.archive }}
- name: Upload binary archive (unix)
if: matrix.archive == 'tar.gz' && github.event_name == 'release'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: gh release upload ${{ github.ref_name }} tracedecay-${{ steps.version.outputs.tag }}-${{ matrix.name }}.${{ matrix.archive }} --clobber
- name: Package binary (windows)
if: matrix.archive == 'zip'
shell: pwsh
run: |
Compress-Archive -Path target/${{ matrix.target }}/release/tracedecay.exe -DestinationPath tracedecay-${{ steps.version.outputs.tag }}-${{ matrix.name }}.zip -Force
- name: Generate archive attestation (windows)
if: matrix.archive == 'zip' && github.event_name == 'release'
uses: actions/attest@v4
with:
subject-path: tracedecay-${{ steps.version.outputs.tag }}-${{ matrix.name }}.${{ matrix.archive }}
- name: Upload binary archive (windows)
if: matrix.archive == 'zip' && github.event_name == 'release'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: gh release upload ${{ github.ref_name }} tracedecay-${{ steps.version.outputs.tag }}-${{ matrix.name }}.${{ matrix.archive }} --clobber
# --- Homebrew bottle (only for platforms with bottle_tag) ---
- name: Package Homebrew bottle
if: matrix.bottle_tag
run: |
VERSION="${{ steps.version.outputs.version }}"
BOTTLE_TAG="${{ matrix.bottle_tag }}"
mkdir -p tracedecay/${VERSION}/bin
cp target/${{ matrix.target }}/release/tracedecay tracedecay/${VERSION}/bin/tracedecay
chmod +x tracedecay/${VERSION}/bin/tracedecay
tar czf "tracedecay-${VERSION}.${BOTTLE_TAG}.bottle.tar.gz" tracedecay/
- name: Generate bottle attestation
if: matrix.bottle_tag && github.event_name == 'release'
uses: actions/attest@v4
with:
subject-path: tracedecay-${{ steps.version.outputs.version }}.${{ matrix.bottle_tag }}.bottle.tar.gz
- name: Upload bottle artifact
if: matrix.bottle_tag && github.event_name == 'release'
uses: actions/upload-artifact@v6
with:
name: bottle-${{ matrix.bottle_tag }}
path: "tracedecay-*.bottle.tar.gz"
update-homebrew:
name: Update Homebrew tap
if: github.event_name == 'release' && !github.event.release.prerelease && needs.build.result == 'success'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Get version
id: version
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Download bottle artifacts
uses: actions/download-artifact@v7
with:
path: bottles
merge-multiple: true
- name: Upload bottles to release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for f in bottles/tracedecay-*.bottle.tar.gz; do
gh release upload "${GITHUB_REF_NAME}" "$f" --clobber
done
- name: Download source tarball
run: |
curl -sL "https://github.com/${{ github.repository }}/archive/refs/tags/${GITHUB_REF_NAME}.tar.gz" -o "source.tar.gz"
- name: Compute SHA256 hashes
id: hashes
run: |
VERSION="${{ steps.version.outputs.version }}"
SOURCE_SHA=$(sha256sum source.tar.gz | awk '{print $1}')
echo "source_sha=${SOURCE_SHA}" >> "$GITHUB_OUTPUT"
for f in bottles/tracedecay-*.bottle.tar.gz; do
tag=$(basename "$f" | sed "s/tracedecay-${VERSION}\.\(.*\)\.bottle\.tar\.gz/\1/")
sha=$(sha256sum "$f" | awk '{print $1}')
echo "${tag}_sha=${sha}" >> "$GITHUB_OUTPUT"
done
# NOTE: the Homebrew tap (ScriptedAlchemy/homebrew-tap) is an external
# repo — the previous formula there must be removed/renamed
# separately; this step only writes the new Formula/tracedecay.rb.
- name: Update formula
env:
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
run: |
VERSION="${{ steps.version.outputs.version }}"
SOURCE_SHA="${{ steps.hashes.outputs.source_sha }}"
ARM64_SONOMA_SHA="${{ steps.hashes.outputs.arm64_sonoma_sha }}"
X86_64_LINUX_SHA="${{ steps.hashes.outputs.x86_64_linux_sha }}"
git clone "https://x-access-token:${TAP_GITHUB_TOKEN}@github.com/ScriptedAlchemy/homebrew-tap.git" tap
mkdir -p tap/Formula
cat > tap/Formula/tracedecay.rb << EOF
class Tracedecay < Formula
desc "Code intelligence tool that builds semantic knowledge graphs from source code"
homepage "https://github.com/ScriptedAlchemy/tracedecay"
url "https://github.com/ScriptedAlchemy/tracedecay/archive/refs/tags/v${VERSION}.tar.gz"
sha256 "${SOURCE_SHA}"
license "MIT"
bottle do
root_url "https://github.com/ScriptedAlchemy/tracedecay/releases/download/v${VERSION}"
sha256 cellar: :any_skip_relocation, arm64_sonoma: "${ARM64_SONOMA_SHA}"
sha256 cellar: :any_skip_relocation, x86_64_linux: "${X86_64_LINUX_SHA}"
end
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
end
test do
system "#{bin}/tracedecay", "--help"
end
end
EOF
cd tap
# Clean up the legacy pre-rebrand formula if it still exists.
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/tracedecay.rb
git diff --cached --quiet || git commit -m "tracedecay ${VERSION}"
git push
update-scoop:
name: Update Scoop bucket
if: github.event_name == 'release' && !github.event.release.prerelease && needs.build.result == 'success'
needs: build
runs-on: ubuntu-latest
steps:
- name: Get release info
id: release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
gh release download "${GITHUB_REF_NAME}" \
--repo "${{ github.repository }}" \
--pattern "tracedecay-${GITHUB_REF_NAME}-x86_64-windows.zip" \
--dir .
SHA256=$(sha256sum "tracedecay-${GITHUB_REF_NAME}-x86_64-windows.zip" | cut -d' ' -f1)
echo "sha256_win64=${SHA256}" >> "$GITHUB_OUTPUT"
# NOTE: the Scoop bucket (ScriptedAlchemy/scoop-bucket) is an external
# repo — the previous bucket manifest there must be removed separately;
# this step only writes the new bucket/tracedecay.json.
- name: Update Scoop manifest
env:
SCOOP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
run: |
VERSION="${{ steps.release.outputs.version }}"
TAG="${{ steps.release.outputs.tag }}"
SHA256="${{ steps.release.outputs.sha256_win64 }}"
cat > tracedecay.json << EOF
{
"version": "${VERSION}",
"description": "Code intelligence tool that builds semantic knowledge graphs from source code",
"homepage": "https://github.com/ScriptedAlchemy/tracedecay",
"license": "MIT",
"architecture": {
"64bit": {
"url": "https://github.com/ScriptedAlchemy/tracedecay/releases/download/${TAG}/tracedecay-${TAG}-x86_64-windows.zip",
"hash": "${SHA256}"
}
},
"bin": "tracedecay.exe",
"checkver": {
"github": "https://github.com/ScriptedAlchemy/tracedecay"
},
"autoupdate": {
"architecture": {
"64bit": {
"url": "https://github.com/ScriptedAlchemy/tracedecay/releases/download/v\$version/tracedecay-v\$version-x86_64-windows.zip"
}
}
}
}
EOF
git clone "https://x-access-token:${SCOOP_GITHUB_TOKEN}@github.com/ScriptedAlchemy/scoop-bucket.git" scoop-repo
cd scoop-repo
mkdir -p bucket
cp ../tracedecay.json bucket/tracedecay.json
# Clean up legacy pre-rebrand manifests (root-level and bucket/).
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add bucket/tracedecay.json
git diff --cached --quiet || git commit -m "tracedecay ${VERSION}"
git push
# Rewrites the MCP registry manifest (server.json) from the actual release
# artifacts so the version, download URLs, and fileSha256 digests always
# describe real uploaded assets. Skips (with a warning) when the release has
# no MCPB packages, since those are not yet produced by the build matrix.
update-server-json:
name: Update server.json manifest
if: github.event_name == 'release' && !github.event.release.prerelease && needs.build.result == 'success'
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: master
- name: Rewrite server.json from release artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${GITHUB_REF_NAME}"
VERSION="${TAG#v}"
REPO="${{ github.repository }}"
PLATFORMS="aarch64-macos:mcp.tar.gz x86_64-linux:mcp.tar.gz aarch64-linux:mcp.tar.gz x86_64-windows:mcp.zip"
mkdir -p assets
missing=0
for entry in $PLATFORMS; do
platform="${entry%%:*}"
ext="${entry#*:}"
asset="tracedecay-${TAG}-${platform}.${ext}"
if ! gh release download "$TAG" --repo "$REPO" --pattern "$asset" --dir assets; then
echo "::warning::release asset ${asset} not found"
missing=1
fi
done
if [ "$missing" -ne 0 ]; then
echo "::warning::server.json not updated — this release has no complete MCPB package set"
exit 0
fi
printf '[' > sha-map.json
sep=""
for entry in $PLATFORMS; do
platform="${entry%%:*}"
ext="${entry#*:}"
asset="tracedecay-${TAG}-${platform}.${ext}"
sha=$(sha256sum "assets/${asset}" | cut -d' ' -f1)
printf '%s{"platform":"%s","ext":"%s","sha":"%s"}' "$sep" "$platform" "$ext" "$sha" >> sha-map.json
sep=","
done
printf ']' >> sha-map.json
jq --arg v "$VERSION" --arg tag "$TAG" --arg repo "$REPO" --slurpfile map sha-map.json '
.version = $v
| .packages = ($map[0] | map(
{
"registryType": "mcpb",
"identifier": "https://github.com/\($repo)/releases/download/\($tag)/tracedecay-\($tag)-\(.platform).\(.ext)",
"version": $v,
"fileSha256": .sha,
"packageArguments": [
{
"type": "positional",
"valueHint": "serve"
}
],
"transport": {
"type": "stdio"
}
}
)
)
' server.json > server.json.tmp
mv server.json.tmp server.json
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add server.json
git diff --cached --quiet || git commit -m "server.json: tracedecay ${VERSION}"
git push