feat(release): arm64/arm targets + Forgejo release one-shot + CI workflows 📦🤖
Some checks are pending
CI / vet-build-test (push) Waiting to run

- build-release.sh: add linux/arm64 (Raspberry Pi!) + linux/arm targets — the
  curl|sh install on a clean Pi needs a real arm64 asset to download.
- scripts/release.sh: one-shot local release. Cross-compiles, then creates/updates
  the Forgejo release and uploads de-versioned assets (devbox_<os>_<arch>) that
  install.sh fetches directly. No CI runner required.
- .forgejo + .github CI workflows: go vet + build + test -race on push/PR;
  on vX.Y.Z tag, build-release + publish. GitHub's runs on hosted runners today.
- docker-compose: pull the published hub image by default; --build for local source.
This commit is contained in:
shoemoney 2026-06-23 13:31:54 -05:00
parent 7f9eef7b3c
commit 9b1165a49a
7 changed files with 188 additions and 4 deletions

20
.forgejo/workflows/ci.yml Normal file
View file

@ -0,0 +1,20 @@
# Forgejo Actions CI — runs once a runner is registered (act_runner with a
# `linux`/`ubuntu-latest` label). Until then it's inert, no harm.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
vet-build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go vet ./...
- run: go build ./...
- run: go test ./... -race

View file

@ -0,0 +1,23 @@
# On `vX.Y.Z` tag push: cross-compile every target and publish the Forgejo
# release with installer-named assets. Reuses scripts/release.sh so the local
# one-shot and CI never drift. Needs a runner + a RELEASE_TOKEN secret (a
# Forgejo token with write:repository). Until both exist, run release.sh by hand.
name: Release
on:
push:
tags: ['v*']
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # tags + history for `git describe`
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: ./scripts/release.sh "${{ github.ref_name }}"
env:
FORGEJO_TOKEN: ${{ secrets.RELEASE_TOKEN }}

21
.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,21 @@
# GitHub Actions mirror of .forgejo/workflows/ci.yml. This one runs on GitHub's
# hosted runners today (Forgejo's waits on a self-hosted runner), so it's what
# actually gates PRs green/red on the github mirror.
name: CI
on:
push:
branches: [main]
pull_request:
jobs:
vet-build-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- run: go vet ./...
- run: go build ./...
- run: go test ./... -race

41
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,41 @@
# On `vX.Y.Z` tag push: cross-compile every target and attach installer-named
# assets to a GitHub release (mirror of the Forgejo release). Point install.sh at
# this with DEVBOX_RELEASE_URL=https://github.com/<owner>/devbox/releases/download/<tag>.
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- name: Build all targets
run: VERSION="${{ github.ref_name }}" ./scripts/build-release.sh
- name: De-version asset names (match install.sh)
run: |
cd dist
for f in devbox_*_* devbox-hub_*_*; do
[ -f "$f" ] || continue
ext=""; case "$f" in *.exe) ext=".exe"; f="${f%.exe}";; esac
arch="${f##*_}"; rest="${f%_*}"; os="${rest##*_}"; bin="${rest%_*}"; bin="${bin%_*}"
mv "$f$ext" "${bin}_${os}_${arch}${ext}"
done
ls -la
- name: Publish GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ github.ref_name }}" dist/* \
--title "${{ github.ref_name }}" \
--generate-notes

View file

@ -1,6 +1,7 @@
# devbox hub — drop-in for a NAS (TrueNAS SCALE, Synology, unRAID, any Docker host).
#
# docker compose up -d --build # hub on :8088, data persisted, self-healing
# docker compose up -d # pulls the published image, hub on :8088
# docker compose up -d --build # build from local source instead
# docker compose exec hub devbox-hub token --data /data # mint a join token
# docker compose logs -f hub
#
@ -8,9 +9,9 @@
services:
hub:
# Published image is the default; `--build` rebuilds from the local source tree.
image: git.shoemoney.ai/shoemoney/devbox-hub:latest
build: .
# Prefer a published image once you have one:
# image: git.shoemoney.ai/shoemoney/devbox-hub:latest
container_name: devbox-hub
restart: unless-stopped # keep-alive + auto-restart + recover (crash & reboot)
ports:

View file

@ -10,7 +10,8 @@ VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo d
LDFLAGS="-s -w -X main.version=$VERSION"
BINS=(devbox devbox-hub)
TARGETS=(linux/amd64 darwin/arm64 darwin/amd64 windows/amd64)
# linux/arm64 = Raspberry Pi 5/4/3 (64-bit) + arm Macs' Linux VMs; linux/arm = 32-bit Pi OS.
TARGETS=(linux/amd64 linux/arm64 linux/arm darwin/arm64 darwin/amd64 windows/amd64)
rm -rf dist && mkdir -p dist

77
scripts/release.sh Executable file
View file

@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -euo pipefail
# One-shot local release to Forgejo. No CI runner required.
#
# ./scripts/release.sh # (re)publish the moving 'latest' release from HEAD
# ./scripts/release.sh v1.0.0 # cut a versioned release (creates the git tag at HEAD)
#
# Builds every target via build-release.sh, then creates/updates the Forgejo release
# and uploads assets under the *de-versioned* names install.sh downloads:
# devbox_<os>_<arch> devbox-hub_<os>_<arch> (+ .exe on windows) + SHA256SUMS
#
# Auth: ~/.config/forgejo/token (or $FORGEJO_TOKEN). Override host/repo with
# FORGEJO_API / REPO if you ever move the remote.
cd "$(dirname "$0")/.."
TAG="${1:-latest}"
API="${FORGEJO_API:-https://git.shoemoney.ai/api/v1}"
REPO="${REPO:-shoemoney/devbox}"
TOKEN="${FORGEJO_TOKEN:-$(cat ~/.config/forgejo/token 2>/dev/null || true)}"
[ -n "$TOKEN" ] || { echo "🛑 no Forgejo token (set FORGEJO_TOKEN or ~/.config/forgejo/token)" >&2; exit 1; }
auth=(-H "Authorization: token $TOKEN")
api() { curl -fsSL "${auth[@]}" "$@"; }
# 1. Build. A real tag stamps its name into the binary; 'latest' uses git-describe.
if [ "$TAG" = latest ]; then
./scripts/build-release.sh
else
VERSION="$TAG" ./scripts/build-release.sh
fi
COMMIT=$(git rev-parse HEAD)
# 2. Drop any existing release+tag with this name so we recreate cleanly (latest is a
# moving target; re-cutting a vX.Y.Z is rare but should be idempotent too).
old_id=$(api "$API/repos/$REPO/releases/tags/$TAG" 2>/dev/null \
| python3 -c 'import sys,json;print(json.load(sys.stdin).get("id",""))' 2>/dev/null || true)
if [ -n "${old_id:-}" ]; then
echo "↻ replacing existing release '$TAG' (id $old_id)"
curl -fsSL -X DELETE "${auth[@]}" "$API/repos/$REPO/releases/$old_id" || true
fi
# Move the lightweight tag to HEAD for 'latest'; leave real version tags alone if present.
if [ "$TAG" = latest ]; then
curl -fsSL -X DELETE "${auth[@]}" "$API/repos/$REPO/tags/$TAG" >/dev/null 2>&1 || true
fi
# 3. Create the release (Forgejo creates the tag at $COMMIT if it doesn't exist).
prerelease=$([ "$TAG" = latest ] && echo true || echo false)
body=$(printf 'devbox %s — built %s from `%s`.\n\nInstall: `curl -fsSL https://git.shoemoney.ai/shoemoney/devbox/raw/branch/main/install.sh | sh`' "$TAG" "$(date -u +%Y-%m-%dT%H:%MZ)" "${COMMIT:0:7}")
rel_id=$(api -X POST "$API/repos/$REPO/releases" \
-H 'Content-Type: application/json' \
-d "$(python3 -c 'import json,sys; t,c,b,p=sys.argv[1:5]; print(json.dumps({"tag_name":t,"target_commitish":c,"name":t,"body":b,"draft":False,"prerelease":p=="true"}))' "$TAG" "$COMMIT" "$body" "$prerelease")" \
| python3 -c 'import sys,json;print(json.load(sys.stdin)["id"])')
echo "✅ release '$TAG' created (id $rel_id)"
# 4. Upload de-versioned assets. dist names are <bin>_<version>_<os>_<arch>[.exe].
upload() {
local f="$1" base ext arch rest os bin name
base=$(basename "$f"); ext=""
case "$base" in *.exe) ext=".exe"; base="${base%.exe}";; esac
arch="${base##*_}"; rest="${base%_*}"
os="${rest##*_}"; bin="${rest%_*}"; bin="${bin%_*}" # strip version component
name="${bin}_${os}_${arch}${ext}"
echo " ⬆ $name"
api -X POST "$API/repos/$REPO/releases/$rel_id/assets?name=$name" \
-F "attachment=@$f" >/dev/null
}
for f in dist/devbox_* dist/devbox-hub_*; do [ -f "$f" ] && upload "$f"; done
# checksums keep their plain name
echo " ⬆ SHA256SUMS"
api -X POST "$API/repos/$REPO/releases/$rel_id/assets?name=SHA256SUMS" \
-F "attachment=@dist/SHA256SUMS" >/dev/null
echo
echo "🎉 https://git.shoemoney.ai/$REPO/releases/tag/$TAG"