feat(release): automated tagging + release flow (#2573)
Docker Push / Push CUDA image to Docker (push) Canceled after 0s
Docker Push / Push CUDA image to Docker (push) Canceled after 0s
* feat(release): add tag-and-release workflow, backfill release notes, expand release skill
Port the verifiers tag-and-release pattern: on version bump in pyproject.toml,
auto-tag main and create the GitHub Release using assets/release/RELEASE_v{tag}.md
as the body. Skip the PyPI publish steps since prime-rl is not on PyPI.
Backfill release-note files for v0.1 through v0.5.0 by copying each existing
GitHub Release body so the workflow has historical artifacts to compare against.
Expand skills/release/SKILL.md so an agent can prepare the full release PR
(version bump, release notes file, draft PR) — merging the PR is then enough
to publish the release.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(release): rename v0.1/v0.2 notes to v0.1.0/v0.2.0 for consistency
Aligns all backfilled release note filenames on a MAJOR.MINOR.PATCH suffix.
The historical GitHub tags (v0.1, v0.2) keep their original names; this only
touches the on-disk filenames.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* chore(ci): rename release.yaml to docker-push.yaml; exclude dev tags from tag-and-release
The old release.yaml only builds and pushes the Docker image; the new
tag-and-release.yaml is now the canonical "release" workflow. Renaming
removes the ambiguity.
Add a trigger filter to tag-and-release so '*dev*' tags do not flow through
the release path. devx_tag.yaml creates dev tags via GITHUB_TOKEN, which
already does not retrigger workflows; this exclusion is defensive for any
manual dev-tag pushes. Skill note updated to clarify the two workflows
coexist.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ci): check release notes before tagging, and retry on tag-without-release
Two bugbot fixes in tag-and-release.yaml:
1. Move the assets/release/RELEASE_*.md presence check into auto-tag-on-main,
before the tag is created and pushed. Missing notes used to fail in
release-from-auto-tag, but only after the tag was already on the remote,
blocking a clean retry.
2. If the target tag already exists (locally or on origin) but no GitHub
Release exists for it yet, still emit created=true so release-from-auto-tag
runs against the existing tag. This unblocks recovery from a partial
failure (e.g. the release step crashed after the tag push) without
requiring manual cleanup or workflow_dispatch.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(release): drop in-repo release notes; promote pre-existing draft release on tag
Pivot the release flow:
- Release notes live as a draft GitHub Release created via `gh release create
--draft` (no longer tracked in the repo). Removed assets/release/*.
- The release skill instructs an agent to (1) draft the release on GitHub
with the notes inline and (2) open a draft PR that only bumps `version` in
pyproject.toml.
- On merge, tag-and-release verifies the draft release exists for the new
tag, pushes the tag, then promotes the draft via `gh release edit
--draft=false --latest`. Recovery path: if the tag exists with a draft,
the next main push (or workflow_dispatch) re-promotes it.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7f7ce8a0f4
commit
851233e5de
@@ -1,4 +1,4 @@
|
||||
name: Release
|
||||
name: Docker Push
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -0,0 +1,212 @@
|
||||
name: Tag and Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
# Stable release tags only. `.dev` tags are created by `devx_tag.yaml`
|
||||
# via GITHUB_TOKEN (which does not retrigger workflows), so they would
|
||||
# not arrive here anyway — this exclusion is defensive for manual pushes.
|
||||
- 'v*'
|
||||
- '!v*dev*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Existing tag to release (e.g. v0.6.0)'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
auto-tag-on-main:
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
created: ${{ steps.tag.outputs.created }}
|
||||
tag: ${{ steps.tag.outputs.tag }}
|
||||
version: ${{ steps.tag.outputs.version }}
|
||||
steps:
|
||||
- name: Checkout main
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Detect version bump and create tag
|
||||
id: tag
|
||||
env:
|
||||
BEFORE_SHA: ${{ github.event.before }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
echo "created=false" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
|
||||
echo "No valid base commit available; skipping auto-tag."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
OLD_VERSION=$(git show "$BEFORE_SHA:pyproject.toml" | sed -n 's/^version = "\([^"]*\)"$/\1/p' | head -n1)
|
||||
if [ -z "$OLD_VERSION" ]; then
|
||||
echo "Could not find version in previous pyproject.toml" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
NEW_VERSION=$(python - <<'PY'
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', Path("pyproject.toml").read_text())
|
||||
if not match:
|
||||
sys.exit("Could not find version in current pyproject.toml")
|
||||
print(match.group(1))
|
||||
PY
|
||||
)
|
||||
|
||||
if [ "$OLD_VERSION" = "$NEW_VERSION" ]; then
|
||||
echo "No version change detected in pyproject.toml; skipping auto-tag."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TAG="v${NEW_VERSION}"
|
||||
|
||||
# A draft GitHub Release must already exist for this tag before we
|
||||
# bump the version on main. The release skill creates it via
|
||||
# `gh release create --draft` ahead of the PR merge.
|
||||
STATE=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft' 2>/dev/null || echo "missing")
|
||||
if [ "$STATE" = "missing" ]; then
|
||||
echo "No GitHub Release found for $TAG." >&2
|
||||
echo "Create a draft release first: gh release create --draft $TAG --title $TAG --notes-file <notes>.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$STATE" = "false" ]; then
|
||||
echo "Release $TAG is already published; skipping auto-tag."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
TAG_EXISTS_LOCAL=false
|
||||
TAG_EXISTS_REMOTE=false
|
||||
if git rev-parse -q --verify "refs/tags/${TAG}" >/dev/null; then
|
||||
TAG_EXISTS_LOCAL=true
|
||||
fi
|
||||
if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then
|
||||
TAG_EXISTS_REMOTE=true
|
||||
fi
|
||||
|
||||
if [ "$TAG_EXISTS_LOCAL" = "true" ] || [ "$TAG_EXISTS_REMOTE" = "true" ]; then
|
||||
# Tag exists but draft hasn't been published — proceed to publish
|
||||
# (covers retries after the release-from-auto-tag step failed).
|
||||
echo "Tag ${TAG} already exists with a draft release; will publish."
|
||||
echo "created=true" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -a "$TAG" -m "Release $TAG"
|
||||
git push origin "$TAG"
|
||||
|
||||
echo "created=true" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
release-from-auto-tag:
|
||||
needs: auto-tag-on-main
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.auto-tag-on-main.outputs.created == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Publish draft release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ needs.auto-tag-on-main.outputs.tag }}
|
||||
run: |
|
||||
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
|
||||
tag-and-release:
|
||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout tagged release (dispatch)
|
||||
if: github.event_name == 'workflow_dispatch'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
ref: refs/tags/${{ inputs.tag }}
|
||||
|
||||
- name: Checkout tagged release (push)
|
||||
if: github.event_name != 'workflow_dispatch'
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve release version
|
||||
id: release
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
PUSHED_REF: ${{ github.ref_name }}
|
||||
INPUT_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || '' }}
|
||||
run: |
|
||||
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
|
||||
TAG="$INPUT_TAG"
|
||||
else
|
||||
TAG="$PUSHED_REF"
|
||||
fi
|
||||
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Unable to determine release tag" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$TAG" in
|
||||
v*)
|
||||
;;
|
||||
*)
|
||||
echo "Release tags must be prefixed with 'v' (received '$TAG')" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
VERSION="${TAG#v}"
|
||||
FILE_VERSION=$(python - <<'PY'
|
||||
from pathlib import Path
|
||||
import re
|
||||
import sys
|
||||
|
||||
match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', Path("pyproject.toml").read_text())
|
||||
if not match:
|
||||
sys.exit("Could not find version in pyproject.toml")
|
||||
print(match.group(1))
|
||||
PY
|
||||
)
|
||||
|
||||
if [ "$FILE_VERSION" != "$VERSION" ]; then
|
||||
echo "Version mismatch: tag requests '$VERSION' but pyproject.toml defines '$FILE_VERSION'" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Publish draft release
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
run: |
|
||||
STATE=$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json isDraft --jq '.isDraft' 2>/dev/null || echo "missing")
|
||||
if [ "$STATE" = "missing" ]; then
|
||||
echo "No GitHub Release found for $TAG." >&2
|
||||
echo "Create a draft release first: gh release create --draft $TAG --title $TAG --notes-file <notes>.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$STATE" = "false" ]; then
|
||||
echo "Release $TAG is already published; nothing to do."
|
||||
exit 0
|
||||
fi
|
||||
gh release edit "$TAG" --repo "$GITHUB_REPOSITORY" --draft=false --latest
|
||||
+62
-7
@@ -5,10 +5,65 @@ description: How to prepare and publish GitHub releases for prime-rl. Use when d
|
||||
|
||||
# Releases
|
||||
|
||||
1. **Match prior style** — `gh release list --limit 1` then `gh release view <tag>` to mirror tone and structure.
|
||||
2. **Gather commits** — `git fetch origin main` and `git log <last-tag>..origin/main --oneline --no-merges`. Re-fetch right before publishing in case PRs landed during drafting.
|
||||
3. **Structure** — numbered highlight sections (`# 1.`, `# 2.`, ...) for impactful user-facing features, then `# Breaking Changes`, `# Bug Fixes`, `# Misc`. Use `##` subsections inside a highlight when it bundles multiple items.
|
||||
4. **Verify TOML field names** — when referencing config in notes, check the actual code; don't guess.
|
||||
5. **Links** — clickable for docs (`[docs/foo.md](https://github.com/PrimeIntellect-ai/prime-rl/blob/main/docs/foo.md)`) and PRs (`[#1234](https://github.com/PrimeIntellect-ai/prime-rl/pull/1234)`).
|
||||
6. **Contributors** — list by commit count, using GitHub `@username` from the API (git author names can be inconsistent).
|
||||
7. **Always draft first** — `gh release create ... --draft`, iterate, then publish.
|
||||
Releases are driven by [`.github/workflows/tag-and-release.yaml`](../../.github/workflows/tag-and-release.yaml). The flow:
|
||||
|
||||
1. You create a **draft GitHub Release** with the notes inline (`gh release create --draft`).
|
||||
2. You open a **draft PR** that bumps `version` in `pyproject.toml`.
|
||||
3. Maintainer merges. The workflow tags the commit and promotes the draft.
|
||||
|
||||
Release notes live on the GitHub Release, not in the repo. Prime-rl is **not** on PyPI. `.dev` tags are handled separately by `devx_tag.yaml`; `tag-and-release.yaml` ignores them.
|
||||
|
||||
## 1. Decide the version
|
||||
|
||||
```bash
|
||||
git fetch origin --tags
|
||||
grep '^version' pyproject.toml
|
||||
gh release list --repo PrimeIntellect-ai/prime-rl --limit 5
|
||||
```
|
||||
|
||||
SemVer (`MAJOR.MINOR.PATCH`). Confirm with the user before continuing.
|
||||
|
||||
## 2. Draft the notes
|
||||
|
||||
Match the prior release's structure: numbered highlights (`# 1.`, ...), then `# Breaking Changes`, `# Bug Fixes`, `# Misc`, `# Contributors`. Use `##` subsections inside a highlight when it bundles multiple items.
|
||||
|
||||
```bash
|
||||
PREV=$(gh release list --limit 1 --json tagName --jq '.[0].tagName')
|
||||
gh release view "$PREV" --json body --jq .body # style reference
|
||||
git log "$PREV"..origin/main --oneline --no-merges # commits since
|
||||
gh pr list --base main --state merged --search \
|
||||
"merged:>=$(gh release view "$PREV" --json publishedAt --jq .publishedAt)" \
|
||||
--limit 500 --json number,title,author # for PR links + contributors
|
||||
```
|
||||
|
||||
Tips:
|
||||
- PR refs: `[#1234](https://github.com/PrimeIntellect-ai/prime-rl/pull/1234)`.
|
||||
- Contributors: order by commit count, use the GH `@username` from the API (not git author names).
|
||||
- Verify any TOML field names against the actual config classes.
|
||||
|
||||
## 3. Create the draft release
|
||||
|
||||
```bash
|
||||
NEW=v0.6.0
|
||||
gh release create --draft "$NEW" --title "$NEW" --target main --notes-file /tmp/release-notes-$NEW.md
|
||||
gh release view "$NEW" --json isDraft,tagName --jq '{tagName, isDraft}' # expect isDraft: true
|
||||
```
|
||||
|
||||
Iterate with `gh release edit "$NEW" --notes-file /tmp/release-notes-$NEW.md`.
|
||||
|
||||
## 4. Open the version-bump PR
|
||||
|
||||
```bash
|
||||
git switch -c chore/release-$NEW
|
||||
# bump `version = "..."` in pyproject.toml
|
||||
git add pyproject.toml
|
||||
git commit -m "chore: release $NEW"
|
||||
git push -u origin "chore/release-$NEW"
|
||||
gh pr create --draft --title "chore: release $NEW" --body "Bumps version to ${NEW#v}. Draft release: https://github.com/PrimeIntellect-ai/prime-rl/releases/tag/$NEW"
|
||||
```
|
||||
|
||||
Stop. Do not tag, push tags, or flip the draft to published — the workflow does that on merge.
|
||||
|
||||
## Recovery
|
||||
|
||||
If the workflow tagged the commit but failed to promote the draft, the next main push (or `workflow_dispatch` with `tag: v{new}`) re-promotes it.
|
||||
|
||||
Reference in New Issue
Block a user