Files
archie/tools/publish.sh
T
sam cb29967e7b fix(releaseupdate): find releases in the public releases repository
The source repository is private, so the updater and install.sh got 404.
Releases are now published to samcharles93/archie-releases by
task release:publish.
2026-10-16 03:11:14 +11:00

48 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Publishes a tagged release by hand: the agent and archied images to GHCR,
# then the linux-amd64 zip, SHA256SUMS and install.sh to the public releases
# repository, whose release notes are the version's changelog section.
# Builds from a clean worktree of the tag, so local edits never ship.
set -euo pipefail
version="${1:?usage: tools/publish.sh X.Y.Z}"
tag="v$version"
releases="samcharles93/archie-releases"
registry="ghcr.io/samcharles93"
root="$(git rev-parse --show-toplevel)"
work="$(mktemp -d)"
trap 'git -C "$root" worktree remove --force "$work/src" >/dev/null 2>&1 || true; rm -rf "$work"' EXIT
git -C "$root" worktree add -q --detach "$work/src" "$tag"
cd "$work/src"
sha="$(git rev-parse "$tag^{commit}")"
docker build -q -f Dockerfile --build-arg RUNTIME_VERSION="$version" \
-t "$registry/archie-agent:latest" -t "$registry/archie-agent:sha-$sha" . >/dev/null
docker push -q "$registry/archie-agent:latest"
docker push -q "$registry/archie-agent:sha-$sha"
digest="$(docker inspect --format '{{range .RepoDigests}}{{println .}}{{end}}' "$registry/archie-agent:latest" |
grep "^$registry/archie-agent@" | head -1 | cut -d@ -f2)"
test -n "$digest"
docker build -q -f Dockerfile.archied --build-arg GATEWAY_VERSION="$version" --build-arg RUNTIME_VERSION="$version" \
-t "$registry/archied:latest" -t "$registry/archied:edge" -t "$registry/archied:sha-$sha" . >/dev/null
for t in latest edge "sha-$sha"; do docker push -q "$registry/archied:$t"; done
ldflags="-X github.com/samcharles93/archie-core/internal/installtype.buildType=binary -X github.com/samcharles93/archie-core/internal/buildinfo.Version=$version -X github.com/samcharles93/archie-core/internal/buildinfo.Runtime=$version"
name="archie-core-archied-$tag-linux-amd64"
mkdir -p "$name"
for cmd in $(jq -r '.required_topology.units[]' release.json); do
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "$ldflags" -o "$name/$cmd" "./cmd/$cmd"
done
cp deployments/INSTRUCTIONS.md CHANGELOG.md "$name/"
jq --arg image "$registry/archie-agent@$digest" '. + {agent_image: $image}' release.json >"$name/release.json"
if [ -f README.md ]; then cp README.md "$name/"; fi
zip -qr "$name.zip" "$name"
sha256sum "$name.zip" >SHA256SUMS
awk -v hdr="## [$version]" 'index($0,hdr)==1{p=1} p&&/^## \[/&&index($0,hdr)!=1{exit} p{print}' CHANGELOG.md >notes.md
test -s notes.md
gh release create "$tag" -R "$releases" --title "archie $tag" --notes-file notes.md "$name.zip" SHA256SUMS install.sh
echo "published $tag to $releases (agent $digest)"