mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-30 04:06:34 +09:00
fix(ci): publish the release only after the stable images and chart exist
Finalize undrafted the release before it retagged the images and published the cozy-installer chart, so for the length of the retag the release page announced a version whose images and chart returned manifest unknown. The retag took 80-95 seconds on the 1.6.x patches and several minutes on v1.7.0. A failure in either step also left a public release that a re-run could not repair, because the re-run looked for a draft and found none. Move the draft lookup and the latest decision into their own step that runs before any registry write, hand the decision to the retag, the chart and the release page as step outputs, and undraft last. A missing draft now fails while no stable name exists, and a failed retag leaves the draft in place for a re-run. The comments and docs that took the release to be public by the time finalize pushes the stable tag now say when it is published. Deciding latest before the retag opens minutes in which two release PRs merged close together would both decide they are the newest, leaving latest on the older line on the page, the image aliases and the chart. Finalize therefore runs one release at a time, in a concurrency group that only release PRs join and that queues every merged release rather than cancelling the one waiting. The finalize bats suites run both github-script steps under node against a stubbed API: a missing draft, an orphaned draft, an older patch after a newer minor, and every shipped changelog's tag. A contract test fails on a registry step allowed to fail, a publish step that runs after a failure, a `latest` that moves without the decision, or finalize runs that may overlap. Assisted-by: LLM Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
This commit is contained in:
11 files changed
+325
-97
No files matched your search
@@ -638,9 +638,9 @@ jobs:
|
||||
#
|
||||
# Previously this lived in tags.yaml::generate-changelog, gated on the stable
|
||||
# tag push. Under the promote flow that tag is created by
|
||||
# pull-requests-release.yaml finalize — i.e. AFTER the release is published —
|
||||
# so the changelog PR could only ever be opened once the release was already
|
||||
# public. Moving generation here is the only fix; re-gating the tag-triggered
|
||||
# pull-requests-release.yaml finalize, in the run that publishes the release
|
||||
# once the retag and the chart are done, so the changelog PR could never be
|
||||
# reviewed before the release went public. Moving generation here is the only fix; re-gating the tag-triggered
|
||||
# job cannot help.
|
||||
#
|
||||
# The generation logic is factored into .github/workflows/changelog-generate.yaml
|
||||
|
||||
@@ -46,6 +46,19 @@ jobs:
|
||||
contains(github.event.pull_request.labels.*.name, 'release') &&
|
||||
github.event.pull_request.user.login == 'cozystack-ci[bot]'
|
||||
|
||||
# One finalize at a time across release PRs. Each decides `latest` from the
|
||||
# releases already published, then moves it on the release page, the image
|
||||
# :latest aliases and cozy-installer:latest minutes later, so two
|
||||
# overlapping runs could both decide they are the newest and leave `latest`
|
||||
# on the older line. The group repeats the `if:` above so a PR that skips
|
||||
# finalize never joins it, and `queue: max` lets every merged release wait
|
||||
# its turn: by default GitHub keeps one pending job per group and cancels
|
||||
# the older one when a third arrives.
|
||||
concurrency:
|
||||
group: ${{ (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') && github.event.pull_request.user.login == 'cozystack-ci[bot]') && 'release-finalize' || format('release-finalize-skipped-{0}', github.event.pull_request.number) }}
|
||||
cancel-in-progress: false
|
||||
queue: max
|
||||
|
||||
env:
|
||||
# The registry promotion writes to: component images and the cozy-installer
|
||||
# chart. GHCR — the release registry tags.yaml builds rc images into — NOT
|
||||
@@ -305,9 +318,12 @@ jobs:
|
||||
}
|
||||
}
|
||||
|
||||
# Publish draft release and ensure correct latest flag
|
||||
- name: Publish draft release
|
||||
id: publish
|
||||
# Pick the draft this run publishes and decide whether it becomes `latest`,
|
||||
# before any registry write: a missing draft then fails the job while no
|
||||
# stable image name exists yet, and the retag, the chart and the release
|
||||
# page all act on this one decision.
|
||||
- name: Resolve draft release
|
||||
id: resolve
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
github-token: ${{ steps.app-token.outputs.token }}
|
||||
@@ -390,10 +406,16 @@ jobs:
|
||||
const isOutdated = maxRelease && compareSemver(currentSemver, maxRelease.semver) < 0;
|
||||
const makeLatest = (isRc || isOutdated) ? 'false' : 'true';
|
||||
|
||||
// The image retag step below reuses this exact decision to gate
|
||||
// The retag and chart steps below reuse this exact decision to gate
|
||||
// whether :latest moves — the release's `latest` and the images'
|
||||
// :latest must agree (a patch on an old line moves neither).
|
||||
core.setOutput('make_latest', makeLatest);
|
||||
core.setOutput('prerelease', String(isRc));
|
||||
core.setOutput('draft_id', String(draft.id));
|
||||
if (isOutdated && maxRelease) {
|
||||
core.setOutput('restore_latest_id', String(maxRelease.id));
|
||||
core.setOutput('restore_latest_tag', maxRelease.tag);
|
||||
}
|
||||
|
||||
if (isRc) {
|
||||
console.log(`🏷️ ${tag} is a prerelease, make_latest: false`);
|
||||
@@ -403,6 +425,84 @@ jobs:
|
||||
console.log(`🏷️ ${tag} is the highest version, make_latest: true`);
|
||||
}
|
||||
|
||||
# ── Transactional promotion: consumer-visible registry side effects run
|
||||
# HERE, after the candidate guard passed and the promote PR merged.
|
||||
# promote-rc.yaml published only a temporary `promotion-*` packages
|
||||
# candidate, so an abandoned promotion leaves no stable-named bytes.
|
||||
#
|
||||
# The checked-out merge commit is the promoted stable tree: the rc's
|
||||
# digests with the tag string rewritten to stable and the verified
|
||||
# candidate pinned. skopeo retags those digests to the stable image tag;
|
||||
# helm packages+pushes the stable chart.
|
||||
|
||||
# Retag every rc image/digest plus the verified packages candidate to the
|
||||
# stable tag. No container rebuild — bit-for-bit
|
||||
# the e2e-tested rc. :latest moves only when this stable is the newest
|
||||
# published version, gated by the SAME make_latest decision the release got.
|
||||
- name: Retag rc images to stable
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
STABLE_TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MOVE_LATEST: ${{ steps.resolve.outputs.make_latest == 'true' && '1' || '0' }}
|
||||
run: ./hack/promote-retag.sh "${STABLE_TAG}"
|
||||
|
||||
# Publish the stable cozy-installer OCI chart — the documented install path
|
||||
# (`helm upgrade --install cozystack oci://…/cozy-installer --version X.Y.Z`).
|
||||
# The retag above covers component images + the cozystack-packages artifact,
|
||||
# but the chart is a separate OCI artifact referenced in no values.yaml, so
|
||||
# the stable install 404s (manifest unknown) unless it is published here.
|
||||
# No container rebuild: the chart is packaged from the merged stable tree,
|
||||
# which pins the retagged images + artifact by digest; only the chart's
|
||||
# version and its platformVersion default are stamped.
|
||||
- name: Publish stable cozy-installer chart
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MAKE_LATEST: ${{ steps.resolve.outputs.make_latest }}
|
||||
run: |
|
||||
set -eu
|
||||
STABLE_VERSION="${TAG#v}"
|
||||
# Bake the correct platform version into the chart's DEFAULT values so
|
||||
# the primary `helm --install --version X.Y.Z` path reports the stable
|
||||
# version in telemetry — the operator image itself still carries the rc
|
||||
# version baked at build time, and this env override is what corrects
|
||||
# it. Done on the working tree only (never committed): committing it
|
||||
# would leak platformVersion=vX.Y.Z onto main/the release line when the
|
||||
# promote PR merges, mis-stamping the next rc built from that branch.
|
||||
export STABLE_VERSION
|
||||
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
|
||||
packages/core/installer/values.yaml
|
||||
PKG="$(helm package packages/core/installer \
|
||||
--version "${STABLE_VERSION}" --app-version "${STABLE_VERSION}" | awk '{print $NF}')"
|
||||
helm push "$PKG" "oci://${REGISTRY}"
|
||||
rm -f "$PKG"
|
||||
# cozy-installer:latest tracks the newest stable, matching the image
|
||||
# :latest and the release's `latest` flag — never moved by a patch on
|
||||
# an older line.
|
||||
if [ "${MAKE_LATEST}" = "true" ]; then
|
||||
skopeo copy --multi-arch all \
|
||||
"docker://${REGISTRY}/cozy-installer:${STABLE_VERSION}" \
|
||||
"docker://${REGISTRY}/cozy-installer:latest"
|
||||
fi
|
||||
|
||||
# Last on purpose: the release page is what announces this version, so it
|
||||
# goes public only once the stable images and chart it points at exist. A
|
||||
# failed retag leaves the draft in place, where a re-run finds it again.
|
||||
- name: Publish draft release
|
||||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
env:
|
||||
PRERELEASE: ${{ steps.resolve.outputs.prerelease }}
|
||||
MAKE_LATEST: ${{ steps.resolve.outputs.make_latest }}
|
||||
DRAFT_ID: ${{ steps.resolve.outputs.draft_id }}
|
||||
RESTORE_LATEST_ID: ${{ steps.resolve.outputs.restore_latest_id }}
|
||||
RESTORE_LATEST_TAG: ${{ steps.resolve.outputs.restore_latest_tag }}
|
||||
with:
|
||||
github-token: ${{ steps.app-token.outputs.token }}
|
||||
script: |
|
||||
const tag = '${{ steps.get_tag.outputs.tag }}';
|
||||
const isRc = process.env.PRERELEASE === 'true';
|
||||
const makeLatest = process.env.MAKE_LATEST;
|
||||
|
||||
// Release body comes from the changelog that merged with THIS PR
|
||||
// (promote-rc.yaml commits it onto the release-X.Y.Z branch), read
|
||||
// from the merge commit already checked out here.
|
||||
@@ -470,7 +570,7 @@ jobs:
|
||||
await github.rest.repos.updateRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
release_id: draft.id,
|
||||
release_id: Number(process.env.DRAFT_ID),
|
||||
draft: false,
|
||||
prerelease: isRc,
|
||||
make_latest: makeLatest,
|
||||
@@ -479,73 +579,14 @@ jobs:
|
||||
console.log(`🚀 Published release ${tag}`);
|
||||
|
||||
// If this is a backport/outdated release, ensure the correct release is marked as latest
|
||||
if (isOutdated && maxRelease) {
|
||||
console.log(`🔧 Ensuring ${maxRelease.tag} remains the latest release...`);
|
||||
if (process.env.RESTORE_LATEST_ID) {
|
||||
const restoreTag = process.env.RESTORE_LATEST_TAG;
|
||||
console.log(`🔧 Ensuring ${restoreTag} remains the latest release...`);
|
||||
await github.rest.repos.updateRelease({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
release_id: maxRelease.id,
|
||||
release_id: Number(process.env.RESTORE_LATEST_ID),
|
||||
make_latest: 'true'
|
||||
});
|
||||
console.log(`✅ Restored ${maxRelease.tag} as latest release`);
|
||||
console.log(`✅ Restored ${restoreTag} as latest release`);
|
||||
}
|
||||
|
||||
# ── Transactional promotion: consumer-visible registry side effects run
|
||||
# HERE, after the candidate guard passed and the promote PR merged.
|
||||
# promote-rc.yaml published only a temporary `promotion-*` packages
|
||||
# candidate, so an abandoned promotion leaves no stable-named bytes.
|
||||
#
|
||||
# The checked-out merge commit is the promoted stable tree: the rc's
|
||||
# digests with the tag string rewritten to stable and the verified
|
||||
# candidate pinned. skopeo retags those digests to the stable image tag;
|
||||
# helm packages+pushes the stable chart.
|
||||
|
||||
# Retag every rc image/digest plus the verified packages candidate to the
|
||||
# stable tag. No container rebuild — bit-for-bit
|
||||
# the e2e-tested rc. :latest moves only when this stable is the newest
|
||||
# published version, gated by the SAME make_latest decision the release got.
|
||||
- name: Retag rc images to stable
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
STABLE_TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MOVE_LATEST: ${{ steps.publish.outputs.make_latest == 'true' && '1' || '0' }}
|
||||
run: ./hack/promote-retag.sh "${STABLE_TAG}"
|
||||
|
||||
# Publish the stable cozy-installer OCI chart — the documented install path
|
||||
# (`helm upgrade --install cozystack oci://…/cozy-installer --version X.Y.Z`).
|
||||
# The retag above covers component images + the cozystack-packages artifact,
|
||||
# but the chart is a separate OCI artifact referenced in no values.yaml, so
|
||||
# the stable install 404s (manifest unknown) unless it is published here.
|
||||
# No container rebuild: the chart is packaged from the merged stable tree,
|
||||
# which pins the retagged images + artifact by digest; only the chart's
|
||||
# version and its platformVersion default are stamped.
|
||||
- name: Publish stable cozy-installer chart
|
||||
if: ${{ !contains(steps.get_tag.outputs.tag, '-') }}
|
||||
env:
|
||||
TAG: ${{ steps.get_tag.outputs.tag }}
|
||||
MAKE_LATEST: ${{ steps.publish.outputs.make_latest }}
|
||||
run: |
|
||||
set -eu
|
||||
STABLE_VERSION="${TAG#v}"
|
||||
# Bake the correct platform version into the chart's DEFAULT values so
|
||||
# the primary `helm --install --version X.Y.Z` path reports the stable
|
||||
# version in telemetry — the operator image itself still carries the rc
|
||||
# version baked at build time, and this env override is what corrects
|
||||
# it. Done on the working tree only (never committed): committing it
|
||||
# would leak platformVersion=vX.Y.Z onto main/the release line when the
|
||||
# promote PR merges, mis-stamping the next rc built from that branch.
|
||||
export STABLE_VERSION
|
||||
yq -i '.cozystackOperator.platformVersion = "v" + strenv(STABLE_VERSION)' \
|
||||
packages/core/installer/values.yaml
|
||||
PKG="$(helm package packages/core/installer \
|
||||
--version "${STABLE_VERSION}" --app-version "${STABLE_VERSION}" | awk '{print $NF}')"
|
||||
helm push "$PKG" "oci://${REGISTRY}"
|
||||
rm -f "$PKG"
|
||||
# cozy-installer:latest tracks the newest stable, matching the image
|
||||
# :latest and the release's `latest` flag — never moved by a patch on
|
||||
# an older line.
|
||||
if [ "${MAKE_LATEST}" = "true" ]; then
|
||||
skopeo copy --multi-arch all \
|
||||
"docker://${REGISTRY}/cozy-installer:${STABLE_VERSION}" \
|
||||
"docker://${REGISTRY}/cozy-installer:latest"
|
||||
fi
|
||||
@@ -668,8 +668,8 @@ jobs:
|
||||
# release-X.Y.Z branch so it rides the promote PR and is on the base branch the
|
||||
# moment finalize publishes the release. That is the whole point of
|
||||
# generating it there: at the time THIS job runs the stable tag has already been
|
||||
# pushed by finalize, which means the release is already public — too late for a
|
||||
# changelog PR to be of any use to a reader.
|
||||
# pushed by finalize, whose run publishes the release once the retag and the chart
|
||||
# are done — too late for a changelog PR to be of any use to a reader.
|
||||
#
|
||||
# What the freeze changed: promote-rc.yaml bases its promote PR on release-X.Y
|
||||
# whenever that branch exists, and cutting vX.Y.0-rc.1 now creates it. So EVERY
|
||||
@@ -702,8 +702,8 @@ jobs:
|
||||
# !cancelled(): this job runs on stable tags only, which skip build-arm64,
|
||||
# and a skipped ancestor makes the implicit success() false.
|
||||
if: ${{ github.repository == 'cozystack/cozystack' && (!cancelled() && needs.prepare-release.result == 'success' && !contains(github.ref_name, '-')) }}
|
||||
# Non-blocking: this is a best-effort backfill of an already-published
|
||||
# release, never a gate on one.
|
||||
# Non-blocking: this is a best-effort backfill for the release finalize
|
||||
# publishes, never a gate on one.
|
||||
continue-on-error: true
|
||||
steps:
|
||||
- name: Generate GitHub App token
|
||||
@@ -770,8 +770,8 @@ jobs:
|
||||
# promote flow it normally is, because the promote PR carried it onto
|
||||
# release-X.Y and the stable tag sits on that merge commit. Since the freeze
|
||||
# that PR always targets the line, so this is the usual state on arrival:
|
||||
# `exists` false, `at_tag` true, a reviewed and already-published changelog
|
||||
# sitting right here — port it rather than regenerate.
|
||||
# `exists` false, `at_tag` true, the reviewed changelog finalize publishes as
|
||||
# the release body sitting right here — port it rather than regenerate.
|
||||
#
|
||||
# Only when both are false is there genuinely no changelog to publish, and
|
||||
# only then does the AI run.
|
||||
@@ -794,7 +794,7 @@ jobs:
|
||||
# it reaches the tag via the merge commit. That PR targets the maintenance
|
||||
# line for every release since the freeze, so the file lands on
|
||||
# release-X.Y and never reaches main — `exists` above is false even though
|
||||
# a reviewed, already-PUBLISHED changelog exists right here.
|
||||
# the reviewed changelog finalize publishes as the body exists right here.
|
||||
#
|
||||
# Regenerating in that case would spend a second AI run and, once the
|
||||
# backstop PR merged, update-releasenotes.yaml would overwrite the
|
||||
@@ -841,7 +841,7 @@ jobs:
|
||||
CHANGELOG_BRANCH="changelog-v${VERSION}"
|
||||
|
||||
# Two ways the file can be here: ported verbatim from the tag commit
|
||||
# (at_tag=true — the reviewed, already-published changelog reaching main
|
||||
# (at_tag=true — the reviewed changelog finalize publishes, reaching main
|
||||
# for the first time), or freshly generated above. Either is valid.
|
||||
if [ ! -f "$CHANGELOG_FILE" ]; then
|
||||
echo "::error::Changelog file $CHANGELOG_FILE is absent — it was neither present at the tag nor produced by the Generate changelog using AI step"
|
||||
|
||||
@@ -22,7 +22,7 @@ The release process is promotion-based — a stable release is a renamed release
|
||||
1. Cutting a release candidate (`Cut Pre-release Tag` workflow) and watching its mandatory full E2E.
|
||||
2. Promoting the rc (`Promote RC` workflow), which generates the changelog, opens the parked `cozystack/website` docs PR, and opens the promote PR.
|
||||
3. Reviewing and merging the promote PR (no squash-merge).
|
||||
4. Finalize on merge (CI cuts the write-once tag, publishes the release from the merged changelog, and retags the rc images to stable by digest).
|
||||
4. Finalize on merge (CI cuts the write-once tag, retags the rc images to stable by digest, publishes the stable chart, and last publishes the release from the merged changelog).
|
||||
5. Merging the parked website docs PR once the release is published.
|
||||
|
||||
All detailed steps, workflows, and failure modes are documented in the pages under `docs/release/`, one per topic, and `docs/release.md` links each of them.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
| Symptom | Class | Diagnosis | Block release? |
|
||||
|---------|-------|-----------|----------------|
|
||||
| `Draft release for vX.Y.Z not found` on every release-* merge | Workflow regression — `Publish draft release` lost its `github-token` in a past refactor; default `GITHUB_TOKEN` cannot list drafts | At `pull-requests-release.yaml:163`. Undraft manually, file the fix | No |
|
||||
| `Draft release for vX.Y.Z not found` in finalize | No draft the CI app token can see: the draft for the tag is missing, or the `Resolve draft release` step lost its `github-token` again (it lists releases with the CI app token; while it ran without it, until `7d2fe2f7`, the lookup found no draft on any release) | In the `Resolve draft release` step of `pull-requests-release.yaml`. A release that is already published means a re-run after `Publish draft release` failed past the undraft: the images and the chart went out in the earlier attempt, so only check that `latest` sits on the newest stable. Otherwise the job stops before the retag and the chart, so do not undraft first: fix the cause and re-run the job, or run those two steps by hand and then undraft. File the fix when the token is gone | No |
|
||||
| Changelog Copilot job returns 402 | Token quota — `COPILOT_GITHUB_TOKEN` premium-request quota empty | Both changelog entry points hit it: the optional rc-time `changelog-rc` dispatch and the promote-time `changelog` job (both call the reusable `changelog-generate.yaml`), plus the `tags.yaml` backstop | No — `continue-on-error: true` on the AI step, generate changelog by hand following [`agents/changelog.md`](../agents/changelog.md) |
|
||||
| `Prepare Release` skipped and the run red, `Build arm64 images` failed | The rc's arm64 build failed | Read the `build-arm64` log; `build-arm64-nightly.yaml` usually failed the same way first. Fix on the line, cut the next rc | Yes — an rc is not published amd64 only |
|
||||
| `Stitch multi-arch indexes and republish` fails listing refs | `verify-multiarch.sh` found refs that are not amd64+arm64 indexes, or that it could not check | Each listed ref names its reason. Single-platform manifest or index without one architecture: make the image multi-arch, or allowlist its repository with a reason if it cannot be. Manifest unreadable: correct the ref or digest; the allowlist does not excuse it. Rate-limited or unavailable after 3 tries: re-run once the throttle clears | Yes |
|
||||
|
||||
@@ -6,7 +6,7 @@ The numbered process of a [regular release](./regular-releases.md#regular-releas
|
||||
2. [`tags.yaml`](../../.github/workflows/tags.yaml) — fires on any pre-release tag push: `build-amd64` and `build-arm64` build the pre-release side by side, then `prepare-release` publishes it and pushes its digest-pinned staging branch, then — **only for `-rc.N` tags** — the mandatory `rc-e2e` job calls `e2e-tag.yaml` in the same run (`-alpha.N` / `-beta.N` skip it and are validated on demand with `e2e-tag.yaml`'s manual button). `generate-changelog` and `update-website-docs` also live here but are **backstops only** — both are normally produced at promotion time (see 4); on a stable tag push each self-skips or no-ops when the promote flow already did the work. These stable-tag backstops only fire because finalize pushes the stable tag with the CI app token (a `GITHUB_TOKEN` push triggers no run — see 5).
|
||||
3. [`e2e-tag.yaml`](../../.github/workflows/e2e-tag.yaml) — reusable from `tags.yaml::rc-e2e` and manually dispatchable for a published tag. It checks that the tag's release carries its nocloud disk, resolves the digest-pinned tree and runs the full install, OpenAPI, and Chainsaw suite on Talos containers. A tag cut before the container lane existed has to be dispatched from its own ref. Its dispatch run title is the constant workflow name, so the promote gate correlates a manual run through the successful tag-bearing E2E job name rather than the title.
|
||||
4. [`promote-rc.yaml`](../../.github/workflows/promote-rc.yaml) — manual dispatch, from `main` only (the signature over a stable release's assets names that ref, see [Release signatures and SBOM](./signatures-and-sbom.md#release-signatures-and-sbom)). Five jobs: `parse` validates the rc tag and requires green full-E2E evidence before any staging; `promote` rewrites and commits the rc tags, publishes that packages tree as a run-specific temporary reproducible candidate, commits its digest pin in the `release-X.Y.Z` tree, and drafts the stable release; `changelog` calls the reusable `changelog-generate.yaml` **in parallel** to produce `docs/changelogs/vX.Y.Z.md` (regenerating it, or copying an rc-time changelog already committed to the `release-X.Y.Z-rc.N` staging branch by `changelog-rc.yaml` — see 7); `website-docs` (needs `parse`, `promote`) opens the `cozystack/website` docs PR from the staging branch via `FETCH_REF` (see [Phase 3](#phase-3--update-website-docs-now-the-backstop)); `open-pr` joins them, commits the changelog onto the staging branch, and opens the `release-X.Y.Z` promote PR with the `release` label but no automatic `full-e2e`. So the changelog and website docs are reviewed as part of the promotion, the already-checked rc suite is not repeated by default, and the PR body carries ✅ verified or ⚠️ bypassed plus ✅/⚠️ changelog and website-docs lines. Both `changelog` and `website-docs` are non-blocking. No stable registry name is created at dispatch.
|
||||
5. [`.github/workflows/pull-requests.yaml`](../../.github/workflows/pull-requests.yaml) verifies a promotion candidate against the prospective merge tree and original rc artifact before the required `E2E Tests` status can turn green. [`pull-requests-release.yaml`](../../.github/workflows/pull-requests-release.yaml) fires after merge and repeats that verification before any stable tag, then cuts the write-once stable + Go-module tags, publishes the release **with the merged changelog as its body**, retags the candidate and rc images to stable by digest (`:latest` gated on newest-stable), and publishes the stable chart.
|
||||
5. [`.github/workflows/pull-requests.yaml`](../../.github/workflows/pull-requests.yaml) verifies a promotion candidate against the prospective merge tree and original rc artifact before the required `E2E Tests` status can turn green. [`pull-requests-release.yaml`](../../.github/workflows/pull-requests-release.yaml) fires after merge and repeats that verification before any stable tag, then cuts the write-once stable + Go-module tags, retags the candidate and rc images to stable by digest (`:latest` gated on newest-stable), publishes the stable chart, and last publishes the release **with the merged changelog as its body**.
|
||||
6. [`update-releasenotes.yaml`](../../.github/workflows/update-releasenotes.yaml) — fires on pushes to `main` that touch `docs/changelogs/v*.md`; syncs that content into the corresponding GitHub Release body. No longer the primary path (finalize sets the body directly, which is race-free and works for maintenance lines too) — this now covers later edits to a published changelog and manual re-syncs via `workflow_dispatch`.
|
||||
7. [`changelog-rc.yaml`](../../.github/workflows/changelog-rc.yaml) — manual dispatch, **optional**: generate the changelog at rc time instead of waiting for promotion, while there is still time to review it. It calls the same reusable [`changelog-generate.yaml`](../../.github/workflows/changelog-generate.yaml) and commits the result to the `release-X.Y.Z-rc.N` staging branch as `docs/changelogs/vX.Y.Z.md`; the promote-time `changelog` job then copies that file instead of running the AI again. Skipping this workflow changes nothing — promote generates the changelog itself, exactly as before.
|
||||
|
||||
@@ -46,7 +46,7 @@ The alternate evidence path scans retained successful `workflow_dispatch` runs o
|
||||
|
||||
### Phase 2 — the changelog (generated at rc time or promotion, not here)
|
||||
|
||||
The changelog for `vX.Y.Z` is produced by [`promote-rc.yaml`](../../.github/workflows/promote-rc.yaml)'s `changelog` job (a thin call to the reusable [`changelog-generate.yaml`](../../.github/workflows/changelog-generate.yaml)) and committed onto the `release-X.Y.Z` staging branch by `open-pr`, so it rides the promote PR and is on the base branch the moment the release publishes. Finalize then uses that file verbatim as the GitHub Release body. Generating it here — on the stable tag push — would be too late by construction: that tag is created by finalize, which has already published the release. It can also be produced earlier, at rc time, via the optional [`changelog-rc.yaml`](../../.github/workflows/changelog-rc.yaml) button — which runs the same reusable core and commits the file to the `release-X.Y.Z-rc.N` staging branch, from which the promote-time `changelog` job copies it (validated) instead of regenerating.
|
||||
The changelog for `vX.Y.Z` is produced by [`promote-rc.yaml`](../../.github/workflows/promote-rc.yaml)'s `changelog` job (a thin call to the reusable [`changelog-generate.yaml`](../../.github/workflows/changelog-generate.yaml)) and committed onto the `release-X.Y.Z` staging branch by `open-pr`, so it rides the promote PR and is on the base branch the moment the release publishes. Finalize then uses that file verbatim as the GitHub Release body. Generating it here — on the stable tag push — would be too late by construction: that tag is created by finalize, in the run that publishes the release once the retag and the chart are done, so nothing generated from the tag push could be reviewed before it went public. It can also be produced earlier, at rc time, via the optional [`changelog-rc.yaml`](../../.github/workflows/changelog-rc.yaml) button — which runs the same reusable core and commits the file to the `release-X.Y.Z-rc.N` staging branch, from which the promote-time `changelog` job copies it (validated) instead of regenerating.
|
||||
|
||||
The `changelog` job runs **in parallel** with `promote`, detached at the rc tag (the "promotion" configuration in §2 of [`agents/changelog.md`](../agents/changelog.md)), using a separate **read-only** GitHub App token for the AI step so the model cannot mutate the repo even with `--allow-all-tools`. Every write — the commit onto the staging branch and the PR — happens in `open-pr` under a write-scoped token.
|
||||
|
||||
@@ -91,14 +91,15 @@ Reviewer checklist for the `chore(release): promote vX.Y.Z-rc.N -> vX.Y.Z` PR:
|
||||
|
||||
### Phase 5 — `pull-requests-release.yaml` (finalize)
|
||||
|
||||
Fires on merge of a PR that is merged, carries the `release` label, and is authored by `cozystack-ci[bot]` (the last guard closes the "name a branch `release-X.Y.Z`, get it labelled, merge it" hole). Head branch must match `release-X.Y.Z[-suffix]`. This is where **every consumer-visible or write-once side effect of a promotion happens** — after the rc's mandatory E2E was checked at dispatch and the PR merged, making promotion transactional at stable names. Steps:
|
||||
Fires on merge of a PR that is merged, carries the `release` label, and is authored by `cozystack-ci[bot]` (the last guard closes the "name a branch `release-X.Y.Z`, get it labelled, merge it" hole). Head branch must match `release-X.Y.Z[-suffix]`. This is where **every consumer-visible or write-once side effect of a promotion happens** — after the rc's mandatory E2E was checked at dispatch and the PR merged, making promotion transactional at stable names. Finalize runs one release at a time: two release PRs merged close together finalize one after the other, so the second decides `latest` against a release the first has already published. Steps:
|
||||
|
||||
1. **Verify the packages candidate before creating any stable tag.** [`hack/verify-promoted-packages.sh`](../../hack/verify-promoted-packages.sh) pulls the candidate by the digest committed in installer values, proves it matches the merged `packages/` tree after normalizing only the impossible self-reference, rejects surviving rc image tags, then follows the candidate's embedded pre-push `platformSourceRef` back to the original rc artifact and compares normalized container `repo@digest` sets. Any package edit after candidate publication or any changed container digest aborts finalize while all stable names are still absent.
|
||||
2. **Create the tag at the merge commit** (write-once). The merge commit of `Prepare release vX.Y.Z` did not exist before the PR opened, so there is nothing to move — the tag is created here for the first time. A pre-existing tag at a different commit fails the step loudly rather than being force-moved (see [Tag immutability](./tag-immutability.md#tag-immutability)). The checkout uses `persist-credentials: false` so this push authenticates as the **CI app** (via `git remote set-url`), not the default `GITHUB_TOKEN` — a `GITHUB_TOKEN` push creates no workflow run, so a persisted-credential push would silently skip `tags.yaml` entirely and its stable-tag backstops (`generate-changelog`, `update-website-docs`) would never fire.
|
||||
3. **Cut the `api/apps/v1alpha1/vX.Y.Z` Go-module tag** (write-once, stable only) at the same commit, so Go consumers of `api/apps/v1alpha1` get the release. Moved here from `tags.yaml`, whose `prepare-release` body is skipped for a promoted stable (the draft already exists).
|
||||
4. **Ensure the maintenance branch `release-X.Y` exists** at the tag commit. Since the rc freeze creates it, this is normally a no-op fast-forward — the merge commit is already the branch tip. Still created if missing; updated fast-forward-only — a non-fast-forward update warns and is left for a maintainer rather than being force-updated.
|
||||
5. **Publish the draft release**, with `docs/releasenotes/vX.Y.Z.md`, or without it `docs/changelogs/vX.Y.Z.md`, from the merge commit as its body (absent or whitespace-only files warn and leave the draft's body in place, rather than publishing blank notes, and a body over 100000 bytes is published as a link, see [Phase 6](#phase-6--update-releasenotesyaml-sync-github-release-body)). `make_latest` is computed against published-non-prerelease tags: prereleases stay `false`; tags older than the current max stay `false` (and the current max is force-restored to `latest` if necessary, so an older patch tag cut after a newer minor won't downgrade `latest`).
|
||||
6. **Retag the verified packages candidate and rc container images to stable** by digest (`hack/promote-retag.sh`, no container rebuild) and **publish the stable `cozy-installer` chart**. `:latest` (on both the images and the chart) moves only when this release's `make_latest` was `true` — the same decision as step 5, so the release's `latest` and the images' `:latest` never disagree. The chart is packaged with `platformVersion` stamped into its default values so the documented `helm --install --version X.Y.Z` path reports the stable version.
|
||||
5. **Resolve the draft release** and decide whether it becomes `latest`, before anything is written to the registry, so a missing draft fails the job while no stable image name exists yet. `make_latest` is computed against published-non-prerelease tags: prereleases stay `false`; tags older than the current max stay `false`.
|
||||
6. **Retag the verified packages candidate and rc container images to stable** by digest (`hack/promote-retag.sh`, no container rebuild) and **publish the stable `cozy-installer` chart**. `:latest` (on both the images and the chart) moves only when this release's `make_latest` was `true` — the decision step 5 made, so the release's `latest` and the images' `:latest` agree within a run. The chart is packaged with `platformVersion` stamped into its default values so the documented `helm --install --version X.Y.Z` path reports the stable version.
|
||||
7. **Publish the draft release**, with `docs/releasenotes/vX.Y.Z.md`, or without it `docs/changelogs/vX.Y.Z.md`, from the merge commit as its body (absent or whitespace-only files warn and leave the draft's body in place, rather than publishing blank notes, and a body over 100000 bytes is published as a link, see [Phase 6](#phase-6--update-releasenotesyaml-sync-github-release-body)). It runs last on purpose: the release page is what announces the version, so it goes public only once the images and chart it points at exist, and a failed retag leaves the draft in place for a re-run. For an older patch tag cut after a newer minor, the current max is force-restored to `latest` if necessary, so `latest` is not downgraded.
|
||||
|
||||
### Phase 6 — `update-releasenotes.yaml` (sync GitHub Release body)
|
||||
|
||||
|
||||
@@ -77,6 +77,6 @@ gitGraph
|
||||
1. Verifies the pinned packages candidate against the merged tree and the original rc artifact's container digests.
|
||||
2. Creates the tag `v1.2.1` at the newly created merge commit — write-once. The tag is published here for the first time, never moved.
|
||||
3. Cuts the write-once `api/apps/v1alpha1/v1.2.1` Go-module tag at the same commit.
|
||||
4. Publishes the release page (`draft` → `latest`; `latest` moves only if `v1.2.1` is the newest published stable).
|
||||
5. Retags the verified packages candidate and rc container images by digest to `v1.2.1` and publishes the stable `cozy-installer` chart — no container rebuild.
|
||||
4. Retags the verified packages candidate and rc container images by digest to `v1.2.1` and publishes the stable `cozy-installer` chart — no container rebuild.
|
||||
5. Publishes the release page (`draft` → `latest`; `latest` moves only if `v1.2.1` is the newest published stable). It goes last, so the page never announces a version whose images and chart are not in the registry yet.
|
||||
7. Once the release is published, merge the parked `cozystack/website` docs PR, then announce the release to the community.
|
||||
@@ -9,6 +9,6 @@ For RCs and final releases, run this before merging the release PR. Each item is
|
||||
- [ ] **Apply-mutate-reapply** on the kubernetes umbrella HelmRelease (catches second-reconcile bugs).
|
||||
- [ ] **For every CRD-source bump** (kubevirt, cert-manager, flux, cilium, kamaji): `helm template | kubectl apply --dry-run=server` against the freshly-installed CRDs.
|
||||
- [ ] **For every flux / helm-controller / kubevirt-operator / cert-manager bump:** paste the upstream breaking-changes section of the bump's CHANGELOG into the PR body before merge.
|
||||
- [ ] **After cutting the tag,** watch `pull-requests-release.yaml::Finalize Release`. If it fails on `Draft release for v... not found`, undraft the release manually and file the workflow regression — this has been a known recurring failure since the `Publish draft release` step lost its explicit `github-token` in refactor `66a756b6`.
|
||||
- [ ] **After cutting the tag,** watch `pull-requests-release.yaml::Finalize Release`. If it fails on `Draft release for v... not found` while the release is still a draft, nothing has been written to the registry yet, so undrafting the release by hand would publish it without its stable images and chart. If the release is already published, this is a re-run after `Publish draft release` failed past the undraft: the images and the chart went out in the earlier attempt, so only check that `latest` sits on the newest stable (`gh release edit <tag> --latest`). Fix the cause and re-run the failed job; a re-run uses the same workflow file, so for a workflow regression run `hack/promote-retag.sh` and push the stable chart by hand first (the commands are the `Retag rc images to stable` and `Publish stable cozy-installer chart` steps), then undraft. If the step lost its `github-token` again, file the workflow regression: it lists releases with the CI app token, and while it ran without it, until `7d2fe2f7`, the lookup found no draft on any release.
|
||||
- [ ] **The promote PR carries `docs/changelogs/vX.Y.Z.md` and it was verified** per [Changelog pre-publish verification](./changelogs.md#changelog-pre-publish-verification). Finalize publishes this file as the release body, so verifying it before merge is verifying the release notes.
|
||||
- [ ] **The `cozystack/website` docs PR stays parked until publish.** Promotion opens it early; merging it before the GitHub release for `vX.Y.Z` is live 404s the new version's docs and API links. Merge it right after finalize publishes the release (regular-release step 6, patch step 7).
|
||||
@@ -55,8 +55,8 @@ A regular release sequence runs as follows:
|
||||
2. Creates the tag `v1.2.0` at the newly created merge commit — write-once. The tag is published here for the first time, never moved.
|
||||
3. Cuts the write-once `api/apps/v1alpha1/v1.2.0` Go-module tag at the same commit.
|
||||
4. Ensures the `release-1.2` maintenance branch exists at the tag commit. Since the rc freeze created it, this is normally a no-op fast-forward: the merge commit is already its tip.
|
||||
5. Publishes the release page (`draft` → `latest`), using `docs/changelogs/v1.2.0.md` from the merge commit as the release body.
|
||||
6. Retags the verified packages candidate and rc container images by digest to `v1.2.0` (and `:latest` only when `v1.2.0` is the newest published stable), and publishes the stable `cozy-installer` chart — no container rebuild.
|
||||
5. Retags the verified packages candidate and rc container images by digest to `v1.2.0` (and `:latest` only when `v1.2.0` is the newest published stable), and publishes the stable `cozy-installer` chart — no container rebuild.
|
||||
6. Publishes the release page (`draft` → `latest`), using `docs/changelogs/v1.2.0.md` from the merge commit as the release body. It goes last, so the page never announces a version whose images and chart are not in the registry yet.
|
||||
6. Once the release is published, merge the parked `cozystack/website` docs PR (opened back at promote time, step 3.iv) so the live site's version routing flips to `v1.2.0` — its versioned docs and `openapi.json` are on GitHub now. The maintainer can then announce the release to the community.
|
||||
|
||||
```mermaid
|
||||
|
||||
@@ -120,6 +120,75 @@ step_line() {
|
||||
printf '%s\n' "$setup" | code_lines | grep -qF 'uses: fluxcd/flux2/action@'
|
||||
}
|
||||
|
||||
# The release page announces the version, so it must not go public before the
|
||||
# stable images and chart it points at exist. A step that fails after the draft
|
||||
# is undrafted also cannot be re-run: the draft lookup in resolve no longer finds
|
||||
# anything to publish.
|
||||
@test "finalize publishes the release page only after the stable images and chart exist" {
|
||||
resolve="$(step_line 'Resolve draft release' "$FINALIZE")"
|
||||
retag="$(step_line 'Retag rc images to stable' "$FINALIZE")"
|
||||
chart="$(step_line 'Publish stable cozy-installer chart' "$FINALIZE")"
|
||||
publish="$(step_line 'Publish draft release' "$FINALIZE")"
|
||||
[ -n "$resolve" ] && [ -n "$retag" ] && [ -n "$chart" ] && [ -n "$publish" ]
|
||||
[ "$resolve" -lt "$retag" ]
|
||||
[ "$retag" -lt "$chart" ]
|
||||
[ "$chart" -lt "$publish" ]
|
||||
|
||||
# One latest decision, made before the first registry write; the registry
|
||||
# steps and the release page read it instead of recomputing it.
|
||||
for step in 'Retag rc images to stable' 'Publish stable cozy-installer chart' 'Publish draft release'; do
|
||||
step_block "$step" "$FINALIZE" | code_lines | grep -qF 'steps.resolve.outputs.make_latest'
|
||||
done
|
||||
}
|
||||
|
||||
# Finalize decides `latest` minutes before it moves it, so two release PRs
|
||||
# merged close together must not finalize at once. The group is built from the
|
||||
# job's own condition: a PR that skips finalize must not take the shared
|
||||
# group's one pending slot from a release waiting in it.
|
||||
@test "finalize runs one release at a time, and only release PRs share the queue" {
|
||||
[ "$(yq '.jobs.finalize.concurrency.cancel-in-progress' "$FINALIZE")" = false ]
|
||||
# One pending job per group is GitHub's default: a third release merged while
|
||||
# two are in line would cancel the one waiting.
|
||||
[ "$(yq '.jobs.finalize.concurrency.queue' "$FINALIZE")" = max ]
|
||||
cond="$(yq '.jobs.finalize.if' "$FINALIZE" | tr '\n' ' ' | sed 's/[[:space:]][[:space:]]*/ /g; s/^ //; s/ $//')"
|
||||
[ -n "$cond" ]
|
||||
want="\${{ ($cond) && 'release-finalize' || format('release-finalize-skipped-{0}', github.event.pull_request.number) }}"
|
||||
[ "$(yq '.jobs.finalize.concurrency.group' "$FINALIZE")" = "$want" ]
|
||||
}
|
||||
|
||||
# Order alone does not hold the page back. A registry step allowed to fail
|
||||
# without failing the job, or a publish step that runs whatever happened before
|
||||
# it, publishes over a missing image or chart all the same. And a patch on an
|
||||
# older line must move no `latest`: the image and chart aliases follow the one
|
||||
# decision, not a default.
|
||||
@test "finalize publishes nothing after a failed registry step, and latest moves only on the resolved decision" {
|
||||
for step in 'Resolve draft release' 'Retag rc images to stable' 'Publish stable cozy-installer chart' 'Publish draft release'; do
|
||||
STEP="$step" yq --exit-status '.jobs.finalize.steps[] | select(.name == strenv(STEP)) | has("continue-on-error") | not' "$FINALIZE" >/dev/null
|
||||
done
|
||||
# No condition at all on the publish step, so it runs only when every step
|
||||
# before it succeeded; and no registry command whose failure is swallowed.
|
||||
yq --exit-status '.jobs.finalize.steps[] | select(.name == "Publish draft release") | has("if") | not' "$FINALIZE" >/dev/null
|
||||
[ "$(yq '.jobs.finalize.steps[] | select(.name == "Retag rc images to stable") | .run' "$FINALIZE")" = './hack/promote-retag.sh "${STABLE_TAG}"' ]
|
||||
chart_code="$(yq '.jobs.finalize.steps[] | select(.name == "Publish stable cozy-installer chart") | .run' "$FINALIZE" | code_lines)"
|
||||
[ "$(printf '%s\n' "$chart_code" | head -n 1)" = 'set -eu' ]
|
||||
if printf '%s\n' "$chart_code" | grep -qF '||'; then
|
||||
echo "Publish stable cozy-installer chart swallows a failure with ||" >&2; false
|
||||
fi
|
||||
|
||||
# A registry step skipped for a stable tag publishes over a missing artifact
|
||||
# just as a failed one would; only a prerelease skips them.
|
||||
for step in 'Retag rc images to stable' 'Publish stable cozy-installer chart'; do
|
||||
[ "$(STEP="$step" yq '.jobs.finalize.steps[] | select(.name == strenv(STEP)) | .if' "$FINALIZE")" = "\${{ !contains(steps.get_tag.outputs.tag, '-') }}" ]
|
||||
done
|
||||
|
||||
move_latest="$(yq '.jobs.finalize.steps[] | select(.name == "Retag rc images to stable") | .env.MOVE_LATEST' "$FINALIZE")"
|
||||
[ "$move_latest" = "\${{ steps.resolve.outputs.make_latest == 'true' && '1' || '0' }}" ]
|
||||
|
||||
chart_run="$(yq '.jobs.finalize.steps[] | select(.name == "Publish stable cozy-installer chart") | .run' "$FINALIZE")"
|
||||
[ "$(printf '%s\n' "$chart_run" | code_lines | grep -cF 'cozy-installer:latest')" -eq 1 ]
|
||||
printf '%s\n' "$chart_run" | code_lines | grep -A3 -F 'if [ "${MAKE_LATEST}" = "true" ]; then' | grep -qF 'cozy-installer:latest'
|
||||
}
|
||||
|
||||
@test "promote rejects an old target base before publishing a candidate" {
|
||||
validate="$(step_block 'Validate rc is promotable' "$PROMOTE")"
|
||||
prepare_line="$(step_line 'Prepare stable branch' "$PROMOTE")"
|
||||
|
||||
@@ -189,6 +189,31 @@ JS
|
||||
[ -s "$6/calls" ] || { echo "step '$3' recorded nothing" >&2; return 1; }
|
||||
}
|
||||
|
||||
# finalize decides in Resolve draft release and publishes in Publish draft
|
||||
# release, which gets the decision as step outputs wired to env in the workflow.
|
||||
# Runs both and reads that wiring from the workflow itself, so a renamed output
|
||||
# or env key fails here instead of publishing with an empty release id. The
|
||||
# publish step's calls and log land in <out>, the resolve step's in <out>.resolve.
|
||||
#
|
||||
# run_publish <tree> <releases.json> <out> <tag>
|
||||
run_publish() {
|
||||
run_step "$FINALIZE" finalize 'Resolve draft release' "$1" "$2" "$3.resolve" "$4" || return 1
|
||||
[ "$(tail -n 1 "$3.resolve/calls")" = ok ] || {
|
||||
echo "Resolve draft release did not finish:" >&2
|
||||
sed 's/^/ /' "$3.resolve/calls" "$3.resolve/log" >&2; return 1; }
|
||||
wiring="$(yq '.jobs.finalize.steps[] | select(.name == "Publish draft release") | .env | to_entries | .[] | .key + " " + .value' "$FINALIZE")"
|
||||
[ -n "$wiring" ] || { echo "Publish draft release is wired to no env" >&2; return 1; }
|
||||
exports=""
|
||||
while read -r key expr; do
|
||||
name="$(printf '%s' "$expr" | sed -n 's/^\${{ steps\.resolve\.outputs\.\([a-z_]*\) }}$/\1/p')"
|
||||
[ -n "$name" ] || { echo "$key is not wired to a Resolve draft release output: $expr" >&2; return 1; }
|
||||
exports="$exports export $key='$(sed -n "s/^setOutput $name=//p" "$3.resolve/calls")';"
|
||||
done <<EOF
|
||||
$wiring
|
||||
EOF
|
||||
( eval "$exports"; run_step "$FINALIZE" finalize 'Publish draft release' "$1" "$2" "$3" "$4" )
|
||||
}
|
||||
|
||||
# The body finalize publishes for v1.7.0 in place of one over 100000 bytes.
|
||||
LINK_V170='The release notes for v1.7.0 are too long for a GitHub release description; the full changelog is [docs/changelogs/v1.7.0.md](https://github.com/cozystack/cozystack/blob/v1.7.0/docs/changelogs/v1.7.0.md).'
|
||||
|
||||
@@ -530,8 +555,8 @@ v1.6.0=reject:format"
|
||||
return 0
|
||||
}
|
||||
|
||||
# finalize's Publish draft release step, run as the workflow carries it, one
|
||||
# merge-commit tree per case. Whatever the tree holds, the release is
|
||||
# finalize's Resolve and Publish draft release steps, run as the workflow carries
|
||||
# them, one merge-commit tree per case. Whatever the tree holds, the release is
|
||||
# published: with the release notes, else the changelog, else the draft's own
|
||||
# body, and with a link in place of anything over 100000 bytes, since the tags
|
||||
# already exist and a body GitHub refuses would strand the release.
|
||||
@@ -562,10 +587,10 @@ EOF
|
||||
|
||||
for spec in notes:$notes blanknotes:$cl changelog:$cl at:$cl over:link multibyte:link overnotes:link neither:none blank:none; do
|
||||
c="${spec%%:*}"; want="${spec#*:}"
|
||||
run_step "$FINALIZE" finalize 'Publish draft release' "$tmp/$c" "$tmp/releases.json" "$tmp/out.$c" v1.7.0
|
||||
run_publish "$tmp/$c" "$tmp/releases.json" "$tmp/out.$c" v1.7.0
|
||||
with_body=' body'
|
||||
[ "$want" != none ] || with_body=''
|
||||
expected="$(printf 'ok\nsetOutput make_latest=true\nupdateRelease 1 draft=false make_latest=true prerelease=false%s\n' "$with_body")"
|
||||
expected="$(printf 'ok\nupdateRelease 1 draft=false make_latest=true prerelease=false%s\n' "$with_body")"
|
||||
[ "$(sort "$tmp/out.$c/calls")" = "$expected" ] || {
|
||||
echo "$c: finalize did something other than publishing v1.7.0:" >&2
|
||||
sed 's/^/ /' "$tmp/out.$c/calls" "$tmp/out.$c/log" >&2; exit 1; }
|
||||
@@ -590,6 +615,89 @@ EOF
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# The draft lookup is the first thing finalize does after the tags exist, and it
|
||||
# runs before the retag, so a release with no draft stops the job while no stable
|
||||
# image name has been written.
|
||||
@test "finalize: a missing draft fails in Resolve draft release, before anything is published" {
|
||||
need_node
|
||||
tmp="$(mktemp -d)"
|
||||
printf '[{"id": 2, "draft": false, "prerelease": false, "tag_name": "v1.6.5", "name": "v1.6.5", "body": "v1.6.5"}]\n' > "$tmp/releases.json"
|
||||
mkdir -p "$tmp/tree"
|
||||
run_step "$FINALIZE" finalize 'Resolve draft release' "$tmp/tree" "$tmp/releases.json" "$tmp/out" v1.7.0
|
||||
grep -qF 'threw Draft release for v1.7.0 not found' "$tmp/out/calls" || {
|
||||
echo "a missing draft did not stop Resolve draft release:" >&2
|
||||
sed 's/^/ /' "$tmp/out/calls" "$tmp/out/log" >&2; exit 1; }
|
||||
if grep -q '^updateRelease' "$tmp/out/calls"; then
|
||||
echo "Resolve draft release wrote to a release it could not resolve" >&2; exit 1
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# An older patch cut after a newer minor must not take `latest`: it is published
|
||||
# without it, and the newest release is asserted as latest again.
|
||||
@test "finalize: an older patch is published without latest and the newest release keeps it" {
|
||||
need_node
|
||||
tmp="$(mktemp -d)"
|
||||
cat > "$tmp/releases.json" <<'EOF'
|
||||
[
|
||||
{"id": 5, "draft": true, "prerelease": false, "tag_name": "v1.6.6", "name": "v1.6.6", "body": "draft"},
|
||||
{"id": 3, "draft": false, "prerelease": false, "tag_name": "v1.7.0", "name": "v1.7.0", "body": "v1.7.0"},
|
||||
{"id": 2, "draft": false, "prerelease": false, "tag_name": "v1.6.5", "name": "v1.6.5", "body": "v1.6.5"}
|
||||
]
|
||||
EOF
|
||||
mkdir -p "$tmp/tree/docs/changelogs"
|
||||
write_changelog "$tmp/tree/docs/changelogs/v1.6.6.md" 1.6.6
|
||||
run_publish "$tmp/tree" "$tmp/releases.json" "$tmp/out" v1.6.6
|
||||
want="ok
|
||||
updateRelease 3 make_latest=true
|
||||
updateRelease 5 draft=false make_latest=false prerelease=false body"
|
||||
[ "$(sort "$tmp/out/calls")" = "$want" ] || {
|
||||
echo "an older patch did not leave latest with v1.7.0:" >&2
|
||||
sed 's/^/ /' "$tmp/out/calls" "$tmp/out/log" >&2; exit 1; }
|
||||
grep -qx 'setOutput make_latest=false' "$tmp/out.resolve/calls" || {
|
||||
echo "Resolve draft release did not decide make_latest=false for an older patch" >&2; exit 1; }
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# A tag deleted and pushed again orphans its draft: GitHub renames the draft's
|
||||
# tag_name to untagged-<hash> and keeps its name. Resolve repairs the tag before
|
||||
# any registry write, and Publish undrafts the release Resolve settled on, not
|
||||
# one it looks up again. A draft that shares only the name, because it belongs
|
||||
# to another tag, is never taken over.
|
||||
@test "finalize: an orphaned draft is repaired in Resolve and published by its id, another tag's draft is not taken" {
|
||||
need_node
|
||||
tmp="$(mktemp -d)"
|
||||
cat > "$tmp/releases.json" <<'EOF'
|
||||
[
|
||||
{"id": 7, "draft": true, "prerelease": false, "tag_name": "untagged-0123456789abcdef", "name": "v1.7.0", "body": "draft"},
|
||||
{"id": 2, "draft": false, "prerelease": false, "tag_name": "v1.6.5", "name": "v1.6.5", "body": "v1.6.5"}
|
||||
]
|
||||
EOF
|
||||
mkdir -p "$tmp/tree/docs/changelogs"
|
||||
write_changelog "$tmp/tree/docs/changelogs/v1.7.0.md" 1.7.0
|
||||
run_publish "$tmp/tree" "$tmp/releases.json" "$tmp/out" v1.7.0
|
||||
grep -qx 'updateRelease 7 tag_name=v1.7.0' "$tmp/out.resolve/calls" || {
|
||||
echo "Resolve draft release did not repair the orphaned draft's tag:" >&2
|
||||
sed 's/^/ /' "$tmp/out.resolve/calls" >&2; exit 1; }
|
||||
grep -qx 'setOutput draft_id=7' "$tmp/out.resolve/calls" || {
|
||||
echo "Resolve draft release did not hand the repaired draft to Publish draft release" >&2; exit 1; }
|
||||
want="ok
|
||||
updateRelease 7 draft=false make_latest=true prerelease=false body"
|
||||
[ "$(sort "$tmp/out/calls")" = "$want" ] || {
|
||||
echo "the repaired draft is not the release that was published:" >&2
|
||||
sed 's/^/ /' "$tmp/out/calls" "$tmp/out/log" >&2; exit 1; }
|
||||
|
||||
printf '[{"id": 8, "draft": true, "prerelease": true, "tag_name": "v1.7.0-rc.2", "name": "v1.7.0", "body": "draft"}]\n' > "$tmp/other.json"
|
||||
run_step "$FINALIZE" finalize 'Resolve draft release' "$tmp/tree" "$tmp/other.json" "$tmp/out.other" v1.7.0
|
||||
grep -qF 'threw Draft release for v1.7.0 not found' "$tmp/out.other/calls" || {
|
||||
echo "a draft of another tag was taken for v1.7.0:" >&2
|
||||
sed 's/^/ /' "$tmp/out.other/calls" >&2; exit 1; }
|
||||
if grep -q '^updateRelease' "$tmp/out.other/calls"; then
|
||||
echo "Resolve draft release edited the draft of another tag" >&2; exit 1
|
||||
fi
|
||||
rm -rf "$tmp"
|
||||
}
|
||||
|
||||
# A release with no release notes publishes exactly what finalize published
|
||||
# before they existed. Every shipped changelog is a fixture; one over 100000
|
||||
# bytes, which GitHub may refuse, publishes the link instead.
|
||||
@@ -604,7 +712,16 @@ EOF
|
||||
mkdir -p "$tmp/$tag/docs/changelogs"
|
||||
cp "$f" "$tmp/$tag/docs/changelogs/"
|
||||
printf '[{"id": 1, "draft": true, "prerelease": false, "tag_name": "%s", "name": "%s", "body": "draft"}]\n' "$tag" "$tag" > "$tmp/$tag.json"
|
||||
run_step "$FINALIZE" finalize 'Publish draft release' "$tmp/$tag" "$tmp/$tag.json" "$tmp/out.$tag" "$tag"
|
||||
run_publish "$tmp/$tag" "$tmp/$tag.json" "$tmp/out.$tag" "$tag"
|
||||
# The prerelease flag reaches Publish as an output of Resolve, so it is
|
||||
# asserted here, on every shipped tag, rather than assumed from the body.
|
||||
case "$tag" in
|
||||
*-*) flags='make_latest=false prerelease=true' ;;
|
||||
*) flags='make_latest=true prerelease=false' ;;
|
||||
esac
|
||||
grep -qxF "updateRelease 1 draft=false $flags body" "$tmp/out.$tag/calls" || {
|
||||
echo "$tag: published with the wrong flags, want $flags:" >&2
|
||||
sed 's/^/ /' "$tmp/out.$tag/calls" >&2; exit 1; }
|
||||
if [ "$(wc -c < "$f")" -le 100000 ]; then
|
||||
cmp -s "$tmp/out.$tag/body.1" "$f" || { echo "$tag: not published byte for byte" >&2; exit 1; }
|
||||
verbatim=$((verbatim + 1))
|
||||
|
||||
Reference in new issue
Block a user