Skip to content

ci: create release tags only via an approved cut-release workflow - #148

Open
darkobas2 wants to merge 9 commits into
mainfrom
ci/cut-release
Open

darkobas2 wants to merge 9 commits into
mainfrom
ci/cut-release

Conversation

@darkobas2

@darkobas2 darkobas2 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Adds a Cut release workflow. After this, release tags for this repo are created only by CI, never pushed by hand.

How a release works now:

  1. Someone starts Actions → Cut release with the tag (e.g. 1.1.12) and the branch or commit to tag (default main).
  2. The first job checks the tag format and that the tag is new, and resolves the exact commit. The run summary shows the commit that will be tagged.
  3. The second job waits for approval on the release environment. A second person (not the one who started the run) approves it.
  4. The job creates the tag and publishes a GitHub release for it (with generated notes) as the bee-runner app. The published release then runs publish_docker.yaml as before.

Why: since the 2026-11-09 supply chain incident, publishing must need two people. Once this is merged, a ruleset will block tag creation for everyone except org owners and the bee-runner app, as already done on bee.

All actions are pinned to a commit SHA, and the app token only gets contents: write.

Before merging: the repo needs access to the BEE_RUNNER_KEY org secret and a release environment (devops will set both up).


Update: tags are now created by the bee-releaser app, not bee-runner.
The bee-runner key is an org secret, so any workflow on any branch could read it and create tags without approval (thanks for the review). The new app's key is stored only in this repo's release / release-ci environment (RELEASE_APP_KEY, app id in vars.RELEASE_APP_ID). That environment only runs from the default branch, and for cut-release only after a second person approves. Tag rulesets will allow only org owners and this app.

Do not merge before devops has set up the environment (infra/ansible/github-release-app.yml).

Docker Hub credentials (release-ci environment)

Image-publishing jobs now run in the release-ci environment, which holds a per-repo Docker Hub access token (DOCKERHUB_USERNAME/DOCKERHUB_PASSWORD) limited to this repo's images and usable only from the default branch / release tags. After merge, the shared org-level Docker Hub secret will be unshared from this repo.

Cut-release summary: SHA only

The cut-release run summary is what the release approver looks at before approving. It used to show the commit subject, the ref and the branch, and tried to escape them. That approach was too fragile:

  • First version: HTML in a commit subject could change what the approver saw.
  • Escaped <a> version: GitHub still applied markdown inside the line, so a commit URL in the subject was autolinked to a different commit, and a trailing \ escaped </a> (found by @akrem-chabchoub).

Every fix just moved the edge case, so the summary no longer renders any text an outsider can influence. It now shows:

  • the full SHA, in <code> so GitHub doesn't shorten it to 7 characters
  • fixed text: "On the default branch." or "NOT on the default branch (on a release branch)."
  • a link to the commit, built from the SHA

The approver opens the link to see the commit itself.

Also:

  • The job fails if the ref doesn't resolve to a 40-character SHA. Before, a ref of . or .. resolved to undefined.
  • The free-form ref is no longer in run-name, which is what the run list and the approval notification show.

Tested by running the real resolve script from each workflow file in about 22,600 runs with hostile tags, refs, commit messages and branch names, and rendering every summary through GitHub's markdown API. No untrusted text reached the summary.

Same change in bee, storage-incentives, beeport, beekeeper and swarm-gateway.

Tag job is safe to re-run

If createRelease failed after the tag was created, re-running the job failed with "already exists" and left a tag without a release. Now an existing tag is accepted only if it points at the approved SHA, and the release is created only if it is missing. A tag at any other SHA still fails the job.

…environment

The bee-runner key is an org secret, so any workflow on any branch can read it
and mint a token that creates tags, bypassing the approval. The new release app's
key lives only in this repo's release environment, which only runs from the
default branch (and, for cut-release, after a second person approves).
Publishing jobs now read DOCKERHUB_USERNAME/PASSWORD from the release-ci
environment (per-repo token, limited to this repo's images; default branch
and release tags only) instead of the shared org secret.
repos.getCommit also resolves commits that are on no branch, such as fork PR
heads under refs/pull/*. Refuse to tag unless the commit is on the default
branch or a release/* branch, and show that branch in the run summary.
The run summary is what the release approver reviews. Escape the commit
subject, ref and branch so a crafted subject can't alter it, and show the
full SHA.
A line that starts with an inline <a> is still parsed as markdown by
GitHub, so a commit URL in the subject was autolinked to another commit
and a trailing backslash escaped </a>. Wrap the line in <p> so it is an
HTML block with no markdown processing, and escape backslashes too.
Putting the commit subject, ref and branch into the summary and escaping
them was too fragile. Each escaping attempt was bypassed: first raw HTML
in the subject, then GitHub's markdown processing inside an inline <a>
(autolinked commit URLs, a trailing backslash escaping </a>). The summary
is what the release approver trusts, so it should not render any text an
outsider can influence.

The summary now shows only the full SHA (in <code>, so GitHub does not
shorten it), fixed text saying whether the commit is on the default
branch, and a commit link built from the SHA. Also:
- fail if the ref does not resolve to a 40-hex SHA
- drop the free-form ref from run-name
If createRelease failed after the tag was created, re-running the job
failed with 'already exists' and left a tag without a release. Accept an
existing tag only when it points at the approved SHA, and create the
release only if it is missing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant