From 992f1ff744b5ed4e72dbeb2d89f9cca8456d2898 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 27 Oct 2026 07:01:34 +0000 Subject: [PATCH] ci(release): a Run workflow button that cuts the tag from stack.yaml release.yml ran only on a pushed v* tag, so a release needed someone who can push tags. It now also runs from Actions -> Release -> Run workflow: the version comes from stack.yaml on main, the run creates the v tag and the GitHub release on the commit it ran from (gh release create --target), then verifies and publishes exactly as a tag push does. A dispatched run refuses a ref other than main, and refuses a version whose tag already points at another commit (stack.yaml not bumped); a tag on the same commit is a re-run and carries on. A concurrency group keeps two releases from racing. Tag pushes behave as before. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BfmHkwWeA1oPJGBNF3QSQH --- .github/workflows/release.yml | 43 ++++++++++++++++++++++++++++++----- README.md | 3 ++- docs/verification.md | 12 ++++++---- 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 747a8cc..156f24c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,16 @@ on: push: tags: - "v*" + # The "Run workflow" button (Actions -> Release). It releases the version + # stack.yaml declares on main: it creates the v tag and the release + # on the commit it ran from, then verifies and publishes exactly as a tag push + # does. For when a tag cannot be pushed from where the release is cut. + workflow_dispatch: + +# One release at a time: two runs publishing the same version would race. +concurrency: + group: release + cancel-in-progress: false permissions: contents: write @@ -35,10 +45,28 @@ jobs: shell: bash run: | stack_version="$(awk '/^ version: /{print $2}' stack.yaml)" - tag_version="${GITHUB_REF_NAME#v}" test -n "${stack_version}" - test "${stack_version}" = "${tag_version}" + if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then + # A dispatched release names its own tag, from main only. + if [ "${GITHUB_REF}" != "refs/heads/main" ]; then + echo "::error::Run the release from main, not ${GITHUB_REF}." + exit 1 + fi + release_tag="v${stack_version}" + # A version is released from one commit. An existing tag on another + # commit means stack.yaml was not bumped; on this commit it is a + # re-run of this release, which carries on as a tag push would. + existing="$(git rev-list -n 1 "refs/tags/${release_tag}" 2>/dev/null || true)" + if [ -n "${existing}" ] && [ "${existing}" != "${GITHUB_SHA}" ]; then + echo "::error::${release_tag} already points at ${existing}. Bump metadata.version in stack.yaml to release ${GITHUB_SHA}." + exit 1 + fi + else + release_tag="${GITHUB_REF_NAME}" + test "${stack_version}" = "${release_tag#v}" + fi echo "STACK_VERSION=${stack_version}" >> "${GITHUB_ENV}" + echo "RELEASE_TAG=${release_tag}" >> "${GITHUB_ENV}" - name: Verify catalog run: ./scripts/verify.sh @@ -47,13 +75,16 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if gh release view "${GITHUB_REF_NAME}" >/dev/null 2>&1; then - echo "Release ${GITHUB_REF_NAME} already exists." + if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then + echo "Release ${RELEASE_TAG} already exists." exit 0 fi - gh release create "${GITHUB_REF_NAME}" \ - --title "${GITHUB_REF_NAME}" \ + # --target names the commit: on a dispatched run it is where the new + # tag is created; on a tag push the tag already points there. + gh release create "${RELEASE_TAG}" \ + --title "${RELEASE_TAG}" \ + --target "${GITHUB_SHA}" \ --generate-notes # Runs after the release so the tag and release notes are the record of diff --git a/README.md b/README.md index 339e9c5..7b72810 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,8 @@ Most compositions carry their own `README.md` with parameter and profile detail 1. Update `metadata.version` in `stack.yaml`. 2. Run `./scripts/verify.sh`. 3. Merge to `main`. -4. Push a matching tag like `v0.13.0`. +4. Push a matching tag like `v0.13.0`, or run the **Release** workflow from `main` (Actions → + Release → Run workflow), which creates the `v` tag from `stack.yaml` itself. The release workflow asserts the tag matches `stack.yaml`, reruns `./scripts/verify.sh`, creates the GitHub release, then publishes the OCI package and confirms it is pullable with `orun fetch`. The diff --git a/docs/verification.md b/docs/verification.md index 62ebbd8..276f463 100644 --- a/docs/verification.md +++ b/docs/verification.md @@ -84,12 +84,16 @@ that skipped pre-build; this one would have failed them. ## Release workflow -`.github/workflows/release.yml` runs on tag pushes matching `v*`: +`.github/workflows/release.yml` runs on tag pushes matching `v*`, and from its **Run workflow** +button (`workflow_dispatch`): -1. Derive the version from `metadata.version` in `stack.yaml` and assert it equals the tag without - its leading `v`. A mismatched tag fails the release before anything is published. +1. Derive the version from `metadata.version` in `stack.yaml`. On a tag push, assert it equals the + tag without its leading `v`; a mismatched tag fails the release before anything is published. On + a dispatched run the tag is `v`: the run must be on `main`, and it stops if that tag + already points at a different commit, so a version cannot be released twice from two commits. 2. Run `./scripts/verify.sh` — the same gate the pull request ran. -3. Create the GitHub release with `gh release create --generate-notes`, skipping if it already exists. +3. Create the GitHub release with `gh release create --generate-notes` on the run's commit, skipping + if it already exists. On a dispatched run this is also what creates the tag. 4. Publish the OCI package with an explicit target. The target is passed explicitly because with no ref `orun` infers `ghcr.io///` from the git remote, which is the wrong repository path.