From cb29967e7b73a3face0e0d12434831fcd1f00429 Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Fri, 16 Oct 2026 03:11:14 +1100 Subject: [PATCH] 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. --- .github/workflows/deploy.yml | 11 ++++---- RELEASING.md | 7 +++++ Taskfile.yml | 7 +++++ install.sh | 2 +- internal/releaseupdate/github.go | 8 ++++-- tools/publish.sh | 47 ++++++++++++++++++++++++++++++++ 6 files changed, 73 insertions(+), 9 deletions(-) create mode 100755 tools/publish.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a53058b94..f01ef51e4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -408,7 +408,8 @@ jobs: # already guarantees it describes this version. - name: Publish GitHub Release with the distribution zip env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GITHUB_TOKEN cannot write to another repository. + GH_TOKEN: ${{ secrets.RELEASES_TOKEN }} run: | set -e tag="v${{ steps.version.outputs.version }}" @@ -434,12 +435,12 @@ jobs: # Idempotent: --clobber replaces the asset and leaves the notes # alone, so a re-run of this job (a retried or superseded deploy) # cannot fail on an existing Release or duplicate the zip. - if gh release view "$tag" >/dev/null 2>&1; then - gh release upload "$tag" "${{ steps.zip.outputs.name }}.zip" SHA256SUMS --clobber + if gh release view "$tag" -R samcharles93/archie-releases >/dev/null 2>&1; then + gh release upload "$tag" -R samcharles93/archie-releases "${{ steps.zip.outputs.name }}.zip" SHA256SUMS install.sh --clobber else - gh release create "$tag" \ + gh release create "$tag" -R samcharles93/archie-releases \ --title "archied v$version" \ --notes-file "$notes" \ - "${{ steps.zip.outputs.name }}.zip" SHA256SUMS + "${{ steps.zip.outputs.name }}.zip" SHA256SUMS install.sh fi echo "published $tag with ${{ steps.zip.outputs.name }}.zip" diff --git a/RELEASING.md b/RELEASING.md index f5742f65d..6eb1e1f78 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -58,8 +58,15 @@ task release:prepare VERSION=1.3.0 # write the section into CHANGELOG.md, un # edit CHANGELOG.md -- generated notes are a starting point, not the release task release VERSION=1.3.0 # commit + annotated tag git push --atomic origin main v1.3.0 # both refs or neither +task release:publish VERSION=1.3.0 # images to GHCR, zip to archie-releases ``` +The source repository is private, so releases are published to the public +`samcharles93/archie-releases` repository, where `install.sh` and the +updater find them. `release:publish` builds from a clean worktree of the tag +and needs `gh` and `docker` logged in with write access to that repository +and to GHCR. + `release:prepare` emits bare commit subjects; they are a starting point. Rewrite them to say what a reader gets, per "What the notes are for" above. diff --git a/Taskfile.yml b/Taskfile.yml index c5e8cdafc..c6a3271b8 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -360,6 +360,13 @@ tasks: requires: vars: [VERSION] + release:publish: + desc: Push the images and publish the pushed tag to the public releases repository (VERSION=1.2.0) + cmds: + - tools/publish.sh {{.VERSION}} + requires: + vars: [VERSION] + clean: desc: Remove build artifacts cmds: diff --git a/install.sh b/install.sh index 8b9a301e0..f6ad77bff 100755 --- a/install.sh +++ b/install.sh @@ -10,7 +10,7 @@ set -euo pipefail -REPO="samcharles93/archie-core" +REPO="samcharles93/archie-releases" XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}" XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}" diff --git a/internal/releaseupdate/github.go b/internal/releaseupdate/github.go index d1d477d57..f78236550 100644 --- a/internal/releaseupdate/github.go +++ b/internal/releaseupdate/github.go @@ -18,10 +18,12 @@ import ( "github.com/samcharles93/archie-core/internal/buildinfo" ) -// ReleaseSlug is the repository releases are published to. -const ReleaseSlug = "samcharles93/archie-core" +// ReleaseSlug is the public repository releases are published to. The source +// repository is private, so its releases are unreachable without credentials. +const ReleaseSlug = "samcharles93/archie-releases" -const changelogURL = "https://github.com/" + ReleaseSlug + "/blob/main/CHANGELOG.md" +// changelogURL lists every release with its changelog section as notes. +const changelogURL = "https://github.com/" + ReleaseSlug + "/releases" // buildSuffix is the git-describe tail of an untagged build (1.7.0-4-g0736708). var buildSuffix = regexp.MustCompile(`-[0-9]+-g[0-9a-f]+$`) diff --git a/tools/publish.sh b/tools/publish.sh new file mode 100755 index 000000000..1cfec1c54 --- /dev/null +++ b/tools/publish.sh @@ -0,0 +1,47 @@ +#!/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)"