Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<version> 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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>` 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
Expand Down
12 changes: 8 additions & 4 deletions docs/verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<version>`: 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/<owner>/<repo>/<package>` from the git remote, which is the wrong
repository path.
Expand Down
Loading