Skip to content

Commit 4a5df39

Browse files
yshingclaude
andcommitted
Add GitHub Actions release CI and make install.sh public-ready
- Generate .github/workflows/release.yml via cargo-dist for cross-platform builds on macOS arm64/x86, Linux arm64/x86, and Windows x86 - Remove allow-dirty = ["ci"] from dist-workspace.toml so dist can manage CI - Revert install.sh TEMP pre-launch blocks: replace gh CLI calls with curl for tag lookup, binary download, and source tarball download Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent 59a1119 commit 4a5df39

3 files changed

Lines changed: 308 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
# This file was autogenerated by dist: https://axodotdev.github.io/cargo-dist
2+
#
3+
# Copyright 2022-2024, axodotdev
4+
# SPDX-License-Identifier: MIT or Apache-2.0
5+
#
6+
# CI that:
7+
#
8+
# * checks for a Git Tag that looks like a release
9+
# * builds artifacts with dist (archives, installers, hashes)
10+
# * uploads those artifacts to temporary workflow zip
11+
# * on success, uploads the artifacts to a GitHub Release
12+
#
13+
# Note that the GitHub Release will be created with a generated
14+
# title/body based on your changelogs.
15+
16+
name: Release
17+
permissions:
18+
"contents": "write"
19+
20+
# This task will run whenever you push a git tag that looks like a version
21+
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
22+
# Various formats will be parsed into a VERSION and an optional PACKAGE_NAME, where
23+
# PACKAGE_NAME must be the name of a Cargo package in your workspace, and VERSION
24+
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
25+
#
26+
# If PACKAGE_NAME is specified, then the announcement will be for that
27+
# package (erroring out if it doesn't have the given version or isn't dist-able).
28+
#
29+
# If PACKAGE_NAME isn't specified, then the announcement will be for all
30+
# (dist-able) packages in the workspace with that version (this mode is
31+
# intended for workspaces with only one dist-able package, or with all dist-able
32+
# packages versioned/released in lockstep).
33+
#
34+
# If you push multiple tags at once, separate instances of this workflow will
35+
# spin up, creating an independent announcement for each one. However, GitHub
36+
# will hard limit this to 3 tags per commit, as it will assume more tags is a
37+
# mistake.
38+
#
39+
# If there's a prerelease-style suffix to the version, then the release(s)
40+
# will be marked as a prerelease.
41+
on:
42+
pull_request:
43+
push:
44+
tags:
45+
- '**[0-9]+.[0-9]+.[0-9]+*'
46+
47+
jobs:
48+
# Run 'dist plan' (or host) to determine what tasks we need to do
49+
plan:
50+
runs-on: "ubuntu-22.04"
51+
outputs:
52+
val: ${{ steps.plan.outputs.manifest }}
53+
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
54+
tag-flag: ${{ !github.event.pull_request && format('--tag={0}', github.ref_name) || '' }}
55+
publishing: ${{ !github.event.pull_request }}
56+
env:
57+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
steps:
59+
- uses: actions/checkout@v6
60+
with:
61+
persist-credentials: false
62+
submodules: recursive
63+
- name: Install dist
64+
# we specify bash to get pipefail; it guards against the `curl` command
65+
# failing. otherwise `sh` won't catch that `curl` returned non-0
66+
shell: bash
67+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh"
68+
- name: Cache dist
69+
uses: actions/upload-artifact@v6
70+
with:
71+
name: cargo-dist-cache
72+
path: ~/.cargo/bin/dist
73+
# sure would be cool if github gave us proper conditionals...
74+
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
75+
# functionality based on whether this is a pull_request, and whether it's from a fork.
76+
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
77+
# but also really annoying to build CI around when it needs secrets to work right.)
78+
- id: plan
79+
run: |
80+
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
81+
echo "dist ran successfully"
82+
cat plan-dist-manifest.json
83+
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
84+
- name: "Upload dist-manifest.json"
85+
uses: actions/upload-artifact@v6
86+
with:
87+
name: artifacts-plan-dist-manifest
88+
path: plan-dist-manifest.json
89+
90+
# Build and packages all the platform-specific things
91+
build-local-artifacts:
92+
name: build-local-artifacts (${{ join(matrix.targets, ', ') }})
93+
# Let the initial task tell us to not run (currently very blunt)
94+
needs:
95+
- plan
96+
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
97+
strategy:
98+
fail-fast: false
99+
# Target platforms/runners are computed by dist in create-release.
100+
# Each member of the matrix has the following arguments:
101+
#
102+
# - runner: the github runner
103+
# - dist-args: cli flags to pass to dist
104+
# - install-dist: expression to run to install dist on the runner
105+
#
106+
# Typically there will be:
107+
# - 1 "global" task that builds universal installers
108+
# - N "local" tasks that build each platform's binaries and platform-specific installers
109+
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
110+
runs-on: ${{ matrix.runner }}
111+
container: ${{ matrix.container && matrix.container.image || null }}
112+
env:
113+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
115+
permissions:
116+
"attestations": "write"
117+
"contents": "read"
118+
"id-token": "write"
119+
steps:
120+
- name: enable windows longpaths
121+
run: |
122+
git config --global core.longpaths true
123+
- uses: actions/checkout@v6
124+
with:
125+
persist-credentials: false
126+
submodules: recursive
127+
- name: Install Rust non-interactively if not already installed
128+
if: ${{ matrix.container }}
129+
run: |
130+
if ! command -v cargo > /dev/null 2>&1; then
131+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
132+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
133+
fi
134+
- name: Install dist
135+
run: ${{ matrix.install_dist.run }}
136+
# Get the dist-manifest
137+
- name: Fetch local artifacts
138+
uses: actions/download-artifact@v7
139+
with:
140+
pattern: artifacts-*
141+
path: target/distrib/
142+
merge-multiple: true
143+
- name: Install dependencies
144+
run: |
145+
${{ matrix.packages_install }}
146+
- name: Build artifacts
147+
run: |
148+
# Actually do builds and make zips and whatnot
149+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
150+
echo "dist ran successfully"
151+
- name: Attest
152+
uses: actions/attest-build-provenance@v3
153+
with:
154+
subject-path: "target/distrib/*${{ join(matrix.targets, ', ') }}*"
155+
- id: cargo-dist
156+
name: Post-build
157+
# We force bash here just because github makes it really hard to get values up
158+
# to "real" actions without writing to env-vars, and writing to env-vars has
159+
# inconsistent syntax between shell and powershell.
160+
shell: bash
161+
run: |
162+
# Parse out what we just built and upload it to scratch storage
163+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
164+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
165+
echo "EOF" >> "$GITHUB_OUTPUT"
166+
167+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
168+
- name: "Upload artifacts"
169+
uses: actions/upload-artifact@v6
170+
with:
171+
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
172+
path: |
173+
${{ steps.cargo-dist.outputs.paths }}
174+
${{ env.BUILD_MANIFEST_NAME }}
175+
176+
# Build and package all the platform-agnostic(ish) things
177+
build-global-artifacts:
178+
needs:
179+
- plan
180+
- build-local-artifacts
181+
runs-on: "ubuntu-22.04"
182+
env:
183+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184+
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
185+
steps:
186+
- uses: actions/checkout@v6
187+
with:
188+
persist-credentials: false
189+
submodules: recursive
190+
- name: Install cached dist
191+
uses: actions/download-artifact@v7
192+
with:
193+
name: cargo-dist-cache
194+
path: ~/.cargo/bin/
195+
- run: chmod +x ~/.cargo/bin/dist
196+
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
197+
- name: Fetch local artifacts
198+
uses: actions/download-artifact@v7
199+
with:
200+
pattern: artifacts-*
201+
path: target/distrib/
202+
merge-multiple: true
203+
- id: cargo-dist
204+
shell: bash
205+
run: |
206+
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
207+
echo "dist ran successfully"
208+
209+
# Parse out what we just built and upload it to scratch storage
210+
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
211+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
212+
echo "EOF" >> "$GITHUB_OUTPUT"
213+
214+
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
215+
- name: "Upload artifacts"
216+
uses: actions/upload-artifact@v6
217+
with:
218+
name: artifacts-build-global
219+
path: |
220+
${{ steps.cargo-dist.outputs.paths }}
221+
${{ env.BUILD_MANIFEST_NAME }}
222+
# Determines if we should publish/announce
223+
host:
224+
needs:
225+
- plan
226+
- build-local-artifacts
227+
- build-global-artifacts
228+
# Only run if we're "publishing", and only if plan, local and global didn't fail (skipped is fine)
229+
if: ${{ always() && needs.plan.result == 'success' && needs.plan.outputs.publishing == 'true' && (needs.build-global-artifacts.result == 'skipped' || needs.build-global-artifacts.result == 'success') && (needs.build-local-artifacts.result == 'skipped' || needs.build-local-artifacts.result == 'success') }}
230+
env:
231+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
232+
runs-on: "ubuntu-22.04"
233+
outputs:
234+
val: ${{ steps.host.outputs.manifest }}
235+
steps:
236+
- uses: actions/checkout@v6
237+
with:
238+
persist-credentials: false
239+
submodules: recursive
240+
- name: Install cached dist
241+
uses: actions/download-artifact@v7
242+
with:
243+
name: cargo-dist-cache
244+
path: ~/.cargo/bin/
245+
- run: chmod +x ~/.cargo/bin/dist
246+
# Fetch artifacts from scratch-storage
247+
- name: Fetch artifacts
248+
uses: actions/download-artifact@v7
249+
with:
250+
pattern: artifacts-*
251+
path: target/distrib/
252+
merge-multiple: true
253+
- id: host
254+
shell: bash
255+
run: |
256+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
257+
echo "artifacts uploaded and released successfully"
258+
cat dist-manifest.json
259+
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
260+
- name: "Upload dist-manifest.json"
261+
uses: actions/upload-artifact@v6
262+
with:
263+
# Overwrite the previous copy
264+
name: artifacts-dist-manifest
265+
path: dist-manifest.json
266+
# Create a GitHub Release while uploading all files to it
267+
- name: "Download GitHub Artifacts"
268+
uses: actions/download-artifact@v7
269+
with:
270+
pattern: artifacts-*
271+
path: artifacts
272+
merge-multiple: true
273+
- name: Cleanup
274+
run: |
275+
# Remove the granular manifests
276+
rm -f artifacts/*-dist-manifest.json
277+
- name: Create GitHub Release
278+
env:
279+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
280+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
281+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
282+
RELEASE_COMMIT: "${{ github.sha }}"
283+
run: |
284+
# Write and read notes from a file to avoid quoting breaking things
285+
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
286+
287+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/*
288+
289+
announce:
290+
needs:
291+
- plan
292+
- host
293+
# use "always() && ..." to allow us to wait for all publish jobs while
294+
# still allowing individual publish jobs to skip themselves (for prereleases).
295+
# "host" however must run to completion, no skipping allowed!
296+
if: ${{ always() && needs.host.result == 'success' }}
297+
runs-on: "ubuntu-22.04"
298+
env:
299+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
300+
steps:
301+
- uses: actions/checkout@v6
302+
with:
303+
persist-credentials: false
304+
submodules: recursive

dist-workspace.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ pr-run-mode = "plan"
1717
unix-archive = ".tar.gz"
1818
# Whether to enable GitHub Attestations
1919
github-attestations = true
20-
# Skip checking whether the specified configuration files are up to date
21-
allow-dirty = ["ci"]
2220
# Path that installers should place binaries in
2321
install-path = "CARGO_HOME"
2422
# Whether to install an updater program

install.sh

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,7 @@ install_skills() {
9595
main() {
9696
target=$(get_target)
9797

98-
# TEMP: pre-launch, repo is private — use `gh` for auth.
99-
# Revert this block to the curl version (see git history) once public.
100-
if ! command -v gh >/dev/null 2>&1; then
101-
echo "Error: 'gh' CLI required for pre-launch install (repo is private)" >&2
102-
exit 1
103-
fi
104-
tag=$(gh release view --repo "$REPO" --json tagName --jq .tagName)
98+
tag=$(curl -sSfL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
10599
if [ -z "$tag" ]; then
106100
echo "Error: could not determine latest release" >&2
107101
exit 1
@@ -116,10 +110,8 @@ main() {
116110
tmpdir=$(mktemp -d)
117111
trap 'rm -rf "$tmpdir"' EXIT
118112

119-
# TEMP: pre-launch, use `gh release download` instead of curl.
120-
gh release download "$tag" --repo "$REPO" \
121-
--pattern "$tarball" --pattern "$checksums" \
122-
--dir "$tmpdir" >/dev/null
113+
curl -sSfL "https://github.com/${REPO}/releases/download/${tag}/${tarball}" -o "$tmpdir/$tarball"
114+
curl -sSfL "https://github.com/${REPO}/releases/download/${tag}/${checksums}" -o "$tmpdir/$checksums"
123115

124116
expected_hash=$(grep "$tarball" "$tmpdir/$checksums" | awk '{print $1}')
125117
if [ -z "$expected_hash" ]; then
@@ -173,9 +165,7 @@ main() {
173165

174166
# Install skills (non-fatal if it fails)
175167
src_tarball="$tmpdir/source.tar.gz"
176-
# TEMP: use gh api for private repo. When public, replace with:
177-
# curl -sSfL "https://github.com/${REPO}/archive/refs/tags/${tag}.tar.gz" -o "$src_tarball"
178-
if gh api "repos/${REPO}/tarball/${tag}" > "$src_tarball" 2>/dev/null; then
168+
if curl -sSfL "https://github.com/${REPO}/archive/refs/tags/${tag}.tar.gz" -o "$src_tarball" 2>/dev/null; then
179169
install_skills "$src_tarball" || echo "Warning: skill installation failed (skipping)"
180170
else
181171
echo ""

0 commit comments

Comments
 (0)