Skip to content

Commit 6b276f8

Browse files
philzexedev-shelley
andcommitted
oss/exe-scroll: build release artifacts in CI, versioned by commit count
Add a release-exe-scroll job to the oss repo's test workflow that, on push to main, runs exe-scroll/release.sh: it computes a tag of the form exe-scroll/v0.<count>.9<sha-octal> (count = commits touching exe-scroll/, same scheme as the existing Go-module auto-tag job and Shelley's releases), cross-builds static musl binaries for amd64/arm64 via the existing build-static.sh, pushes the tag, and publishes a GitHub release with exe-scroll-linux-{amd64,arm64}. The workflow YAML stays minimal; all logic lives in the checked-in release.sh. The script is idempotent: it skips when exe-scroll/ is unchanged since the latest *released* tag, and a re-run recovers if a previous run pushed the tag but died before publishing the release. Prompt: Can you make it so that the oss repo (that's a subdir of this repo) ends up building exe-scroll release artifacts versioned by the number of commits in the dir or something like that. Shelley does a similar thing. Simple is best. Don't write shell scripts in yaml; minimal yaml is best Co-authored-by: Shelley <shelley@exe.dev>
1 parent 1aa03ee commit 6b276f8

3 files changed

Lines changed: 76 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,22 @@ jobs:
5757
git tag -a "$TAG" -m "Auto-tag $module at ${SHORT_SHA}"
5858
git push origin "$TAG"
5959
done
60+
61+
release-exe-scroll:
62+
runs-on: ubuntu-latest
63+
if: github.event_name == 'push'
64+
concurrency:
65+
group: release-exe-scroll
66+
cancel-in-progress: false
67+
permissions:
68+
contents: write
69+
needs: test
70+
steps:
71+
- uses: actions/checkout@v6
72+
with:
73+
fetch-depth: 0
74+
75+
- name: Build and release exe-scroll
76+
env:
77+
GH_TOKEN: ${{ github.token }}
78+
run: exe-scroll/release.sh

exe-scroll/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/.zig-cache
33
/ghostty-src
44
/.ghostty
5+
/dist

exe-scroll/release.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/sh
2+
# Tag and release exe-scroll from CI (see .github/workflows/test.yml).
3+
#
4+
# Versioned by the number of commits touching exe-scroll/, matching the Go
5+
# module auto-tagging scheme in test.yml: exe-scroll/v0.<count>.9<sha-octal>.
6+
# Skips (exit 0) when exe-scroll/ is unchanged since the latest release tag.
7+
#
8+
# Requires: full git history + tags (actions/checkout fetch-depth: 0), gh CLI
9+
# with GH_TOKEN, and push access to tags (permissions: contents: write).
10+
set -e
11+
12+
SRC_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
13+
cd "$SRC_DIR/.."
14+
15+
# Skip when exe-scroll/ is unchanged since the latest released tag. Both
16+
# conditions matter: checking the release (not just the tag) lets a re-run
17+
# recover if a previous run pushed the tag but died before publishing.
18+
LATEST=$(git tag -l 'exe-scroll/v*' --sort=-v:refname | head -1)
19+
if [ -n "$LATEST" ] && git diff --quiet "$LATEST" -- exe-scroll/ &&
20+
gh release view "$LATEST" >/dev/null 2>&1; then
21+
echo "exe-scroll unchanged since released $LATEST; nothing to release."
22+
exit 0
23+
fi
24+
25+
COUNT=$(git rev-list --count HEAD -- exe-scroll/)
26+
SHORT_SHA=$(git rev-parse --short=6 HEAD)
27+
SHA_OCTAL=$(printf '%o' "0x${SHORT_SHA}")
28+
TAG="exe-scroll/v0.${COUNT}.9${SHA_OCTAL}"
29+
30+
# Key idempotency on the release, not the tag: if a previous run pushed the
31+
# tag but died before creating the release, a re-run still finishes the job.
32+
if gh release view "$TAG" >/dev/null 2>&1; then
33+
echo "release $TAG already exists; nothing to release."
34+
exit 0
35+
fi
36+
37+
echo "Releasing $TAG"
38+
39+
DIST="$SRC_DIR/dist"
40+
rm -rf "$DIST"
41+
for arch in amd64 arm64; do
42+
OUT_DIR="$DIST/$arch" "$SRC_DIR/build-static.sh" "$arch"
43+
cp "$DIST/$arch/bin/exe-scroll" "$DIST/exe-scroll-linux-$arch"
44+
done
45+
46+
if ! git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
git tag -a "$TAG" -m "exe-scroll release $TAG (${SHORT_SHA})"
50+
git push origin "$TAG"
51+
fi
52+
53+
gh release create "$TAG" \
54+
--title "$TAG" \
55+
--notes "Static musl builds of exe-scroll at ${SHORT_SHA}." \
56+
"$DIST"/exe-scroll-linux-*

0 commit comments

Comments
 (0)