From e9d82816b75502cc42f444c6745a20137bbec840 Mon Sep 17 00:00:00 2001 From: vickydotbat Date: Tue, 16 Jun 2026 13:08:10 +0000 Subject: [PATCH] Release workflow revision (#1) Adds a manual release workflow and ensures images are only published on v* tags Reviewed-on: https://git.westgate.pw/ShadowsOverWestgate/sow-tools/pulls/1 Co-authored-by: vickydotbat Co-committed-by: vickydotbat --- .gitea/workflows/build-image.yml | 12 +++----- .gitea/workflows/publish-image.yml | 49 ++++++++++++++++++++++++++++++ .gitea/workflows/test-image.yml | 19 ++++++++++++ 3 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 .gitea/workflows/publish-image.yml create mode 100644 .gitea/workflows/test-image.yml diff --git a/.gitea/workflows/build-image.yml b/.gitea/workflows/build-image.yml index f8b7e45..eeba638 100644 --- a/.gitea/workflows/build-image.yml +++ b/.gitea/workflows/build-image.yml @@ -1,5 +1,6 @@ -# Build the Crucible image. PR-first (D7): PRs build only; push to main also -# publishes registry.westgate.pw/deployment/crucible:. Never a mutable tag. +# Publish the immutable crucible: image on version tags. +# PR/main test builds live in test-image.yml and never publish, so registry +# packages are only generated for releases we intend to use (not on every merge). # # Daemonless: the host-mode runner has no container runtime, so the image is # built by Nix (`nix build .#image`, see flake.nix) and pushed with skopeo @@ -8,15 +9,14 @@ name: build-image on: push: - branches: [main] - pull_request: + tags: ["v*"] env: REGISTRY: registry.westgate.pw IMAGE: deployment/crucible jobs: - build-image: + publish: runs-on: nix-docker steps: - uses: actions/checkout@v4 @@ -29,9 +29,7 @@ jobs: - name: Build OCI image (daemonless) run: nix build .#image - # Publish only on main (post-merge). PRs verify the build but never push. - name: Publish image - if: github.event_name == 'push' && github.ref == 'refs/heads/main' env: REGISTRY_USER: ${{ secrets.REGISTRY_USER }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} diff --git a/.gitea/workflows/publish-image.yml b/.gitea/workflows/publish-image.yml new file mode 100644 index 0000000..a0c6838 --- /dev/null +++ b/.gitea/workflows/publish-image.yml @@ -0,0 +1,49 @@ +# Manual compatibility publisher for the Crucible image. +# Normal release publishing happens in build-image.yml on v* tags; this is the +# break-glass / re-publish path, triggered by hand. +# +# Daemonless: built by Nix (`nix build .#image`) and pushed with skopeo from the +# OCI tarball. No `docker build`/`docker login` involved. +name: publish-image + +on: + workflow_dispatch: + +env: + REGISTRY: registry.westgate.pw + IMAGE: deployment/crucible + +jobs: + publish: + runs-on: nix-docker + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Resolve tag + id: tag + run: echo "sha=$(git rev-parse --short=12 HEAD)" >> "$GITHUB_OUTPUT" + + - name: Build OCI image (daemonless) + run: nix build .#image + + - name: Publish image + env: + REGISTRY_USER: ${{ secrets.REGISTRY_USER }} + REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} + run: | + nix shell nixpkgs#skopeo -c skopeo copy \ + --dest-creds "${REGISTRY_USER}:${REGISTRY_PASSWORD}" \ + docker-archive:result \ + "docker://${REGISTRY}/${IMAGE}:${{ steps.tag.outputs.sha }}" + + - name: Emit release fragment + run: | + FRAG_REPO=sow-tools \ + FRAG_SHA=${{ steps.tag.outputs.sha }} \ + FRAG_ARTIFACT="${REGISTRY}/${IMAGE}:${{ steps.tag.outputs.sha }}" \ + FRAG_URL="${REGISTRY}/${IMAGE}" \ + FRAG_RUN_ID=${{ gitea.run_id }} \ + bash scripts/emit-release-fragment.sh + - uses: actions/upload-artifact@v3 + with: { name: release-fragment, path: release-fragment.json } diff --git a/.gitea/workflows/test-image.yml b/.gitea/workflows/test-image.yml new file mode 100644 index 0000000..52b5827 --- /dev/null +++ b/.gitea/workflows/test-image.yml @@ -0,0 +1,19 @@ +# Test-build the Crucible image on PRs and main. Proves `nix build .#image` +# still works (daemonless, Nix-built OCI tarball) but does NOT publish — +# release publishing happens in build-image.yml on v* tags. +name: test-image + +on: + push: + branches: [main] + pull_request: + +jobs: + build-image: + runs-on: nix-docker + steps: + - uses: actions/checkout@v4 + with: { fetch-depth: 0 } + + - name: Build OCI image (daemonless, no publish) + run: nix build .#image