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
9 changes: 9 additions & 0 deletions .github/workflows/canary-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ on:
# https://github.com/orgs/community/discussions/25615
tags-ignore:
- "**"
paths-ignore:
- '.github/**'
- '.cargo/**'
- '.direnv/**'
- '.vscode/**'
- 'docs/**'
- 'Cargo.*'
- 'crates/**/Cargo.*'
- '*.md'
Comment on lines +8 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Do we want this to just be paths instead set to rust source files?

branches:
- develop
workflow_dispatch:
Expand Down
96 changes: 91 additions & 5 deletions .github/workflows/prep-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,96 @@ jobs:
sys.exit(1)
PY

- name: Push changes to release branch
id: push_changes
- name: Commit version bumps
id: commit_version_bumps
run: |
set -e
set -euo pipefail
git add -A || true
git commit -m "Bumping to version ${{ steps.bump.outputs.new_version }}" || true
git push origin HEAD
git commit -m "chore(release): bumping to version ${{ steps.bump.outputs.new_version }}" || echo "No version bump changes to commit"

- name: Update changelog via xtask
run: cargo xtask changeset changelog ${{ steps.bump.outputs.new_version }}

- name: Extract changelog section
id: changelog
shell: bash
env:
NEW: ${{ steps.bump.outputs.new_version }}
OLD: ${{ steps.meta.outputs.current_version }}
run: |
set -euo pipefail
# Write the extracted section to a file and also expose it as a multiline output "body"
python3 - <<'PY' > CHANGELOG_SECTION.md
try:
import os, re, sys, pathlib
new = os.environ["NEW"]
old = os.environ["OLD"]

p = pathlib.Path("CHANGELOG.md")
if not p.exists():
raise FileNotFoundError("CHANGELOG.md not found at repo root")
text = p.read_text(encoding="utf-8")

# Find header for the new version
start = re.search(rf'(?m)^# \[{re.escape(new)}\]', text)
if not start:
print(f"::error::Could not find changelog entry for {new}", file=sys.stderr)
sys.exit(1)

# Prefer the *specific* previous version header if present; otherwise, next '# ['; else, EOF
segment = text[start.start():]
end_old = re.search(rf'(?m)^# \[{re.escape(old)}\]', segment)
if end_old:
segment = segment[:end_old.start()]
else:
nxt = re.search(r'(?m)^# \[', segment[len('# [' + new + ']'):])
if nxt:
# adjust to absolute end
segment = segment[: (len('# [' + new + ']') + nxt.start())]

segment = segment.rstrip() + "\n"
print(segment)
except Exception:
import traceback
traceback.print_exc()
sys.exit(1)
Comment on lines +183 to +216
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We might want this to just be a file that it includes and runs vs writing inline. Your choice

PY

{
echo 'body<<EOF'
cat CHANGELOG_SECTION.md
echo 'EOF'
} >> "$GITHUB_OUTPUT"

- name: Commit and push changelog updates
shell: bash
run: |
set -euo pipefail
git add -A || true
git commit -m "chore(release): changelog for ${{ steps.bump.outputs.new_version }}" || echo "No changelog updates to commit"
git push origin HEAD

- name: Open/Update draft PR to main
env:
HEAD: ${{ github.ref_name }}
TITLE: Releasing ${{ steps.bump.outputs.new_version }}
shell: bash
run: |
set -euo pipefail
# Try to create; if it already exists, update it
if ! gh pr create \
--base main \
--head "$HEAD" \
--title "$TITLE" \
--draft \
--body-file CHANGELOG_SECTION.md \
--label release
then
num=$(gh pr list --head "$HEAD" --base main --state open --json number -q '.[0].number' || true)
if [[ -n "$num" ]]; then
gh pr edit "$num" --title "$TITLE" --body-file CHANGELOG_SECTION.md --add-label release
else
echo "::error::Failed to create or find PR from $HEAD to main"
exit 1
fi
fi
Comment on lines +240 to +256
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This works for now, but it might be more stable as a cargo xtask in the future since bash can be very finicky.

7 changes: 3 additions & 4 deletions .github/workflows/release-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ jobs:
shell: bash
run: |
docker manifest push $FQDN:$VERSION

# Only push the latest tag if this isn't a release candidate (ends with
# `rc.#`.
if [[ ! "$VERSION" =~ -rc\.[0-9]+$ ]]; then

# push :latest only if version DOES NOT start with canary OR end with -rc.<digits>
if [[ ! "$VERSION" =~ (^canary|-rc\.[0-9]+$) ]]; then
docker manifest push $FQDN:latest
fi