Skip to content

Commit cb4ea96

Browse files
Switch release flow from release-plz to Vortex-style release-drafter (#17)
Replace release-plz with the release process used by vortex-data/vortex, adapted to onpair's single-crate, crates.io-only setup: - release-drafter.yml + .github/release-drafter.yml: maintain a draft GitHub Release on every push to develop, with the next version and categorized notes resolved from changelog/* PR labels. - labels.yml: enforce exactly one changelog/* label per PR. - publish.yml: on release published, set the crate version from the tag and publish to crates.io. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a6c11b2 commit cb4ea96

5 files changed

Lines changed: 199 additions & 27 deletions

File tree

.github/release-drafter.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name-template: "v$RESOLVED_VERSION"
2+
tag-template: "v$RESOLVED_VERSION"
3+
categories:
4+
- title: "⚠️ Breaks"
5+
labels:
6+
- "changelog/break"
7+
- title: "🚧 Deprecation"
8+
labels:
9+
- "changelog/deprecation"
10+
- title: "✨ Features"
11+
labels:
12+
- "changelog/feature"
13+
- title: "🚀 Performance"
14+
labels:
15+
- "changelog/performance"
16+
- title: "🐛 Bug Fixes"
17+
collapse-after: 8
18+
labels:
19+
- "changelog/fix"
20+
- title: "📖 Documentation"
21+
labels:
22+
- "changelog/docs"
23+
collapse-after: 3
24+
- title: "🧰 Maintenance"
25+
labels:
26+
- "changelog/chore"
27+
collapse-after: 3
28+
29+
version-resolver:
30+
major:
31+
labels:
32+
# We must explicitly label a PR with "major" to trigger a major version bump.
33+
- "major"
34+
minor:
35+
labels:
36+
# Any features or breaks will trigger a minor version bump (while we are 0.x)
37+
- "changelog/feature"
38+
- "changelog/break"
39+
default: patch
40+
41+
exclude-labels:
42+
- "changelog/skip"
43+
44+
template: |
45+
## Changes
46+
47+
$CHANGES

.github/workflows/labels.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: PR Labels
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
# Trigger on these PR activities
10+
types: [opened, reopened, synchronize, labeled, unlabeled]
11+
12+
jobs:
13+
check_changelog_label:
14+
name: Validate Changelog Label
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 10
17+
permissions:
18+
pull-requests: read # Grant permission to read PR information
19+
steps:
20+
- name: Get PR Labels from API
21+
id: get_labels_api
22+
uses: octokit/request-action@b91aabaa861c777dcdb14e2387e30eddf04619ae # v3.0.0 # Use an action to make API requests
23+
with:
24+
route: GET /repos/{owner}/{repo}/issues/{pull_number}/labels
25+
owner: ${{ github.repository_owner }}
26+
repo: ${{ github.event.repository.name }}
27+
pull_number: ${{ github.event.pull_request.number }}
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Automatically provided token
30+
31+
- name: Extract and Check Labels
32+
env:
33+
API_RESPONSE: ${{ steps.get_labels_api.outputs.data }}
34+
run: |
35+
REQUIRED_LABELS=(
36+
"changelog/break"
37+
"changelog/deprecation"
38+
"changelog/feature"
39+
"changelog/performance"
40+
"changelog/fix"
41+
"changelog/docs"
42+
"changelog/chore"
43+
"changelog/skip"
44+
)
45+
REQUIRED_LABELS_JSON=$(jq -n '$ARGS.positional' --args "${REQUIRED_LABELS[@]}")
46+
echo "Required Labels: $REQUIRED_LABELS_JSON"
47+
48+
# Parse the response from the API call
49+
# The API returns an array of label objects, we need just the 'name' property
50+
echo "API Response: $API_RESPONSE"
51+
52+
# Extract only the label names into a JSON array
53+
CURRENT_PR_LABELS_JSON=$(echo "$API_RESPONSE" | jq '[.[] | .name]')
54+
echo "Current PR Labels from API: $CURRENT_PR_LABELS_JSON"
55+
56+
# Count how many changelog labels are present
57+
found_labels=()
58+
for label in "${REQUIRED_LABELS[@]}"; do
59+
if echo "$CURRENT_PR_LABELS_JSON" | jq -e --arg label "$label" 'contains([$label])' > /dev/null; then
60+
echo "Found changelog label: $label"
61+
found_labels+=("$label")
62+
fi
63+
done
64+
65+
label_count=${#found_labels[@]}
66+
echo "Total changelog labels found: $label_count"
67+
68+
if [ "$label_count" -eq 0 ]; then
69+
echo "::error file=.github/workflows/labels.yml::Pull Request is missing a required changelog label. Please add exactly one of: ${REQUIRED_LABELS[*]}."
70+
exit 1
71+
elif [ "$label_count" -gt 1 ]; then
72+
echo "::error file=.github/workflows/labels.yml::Pull Request has multiple changelog labels (${found_labels[*]}). Please keep only one."
73+
exit 1
74+
else
75+
echo "Pull Request has exactly one changelog label: ${found_labels[0]}"
76+
fi

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish
2+
3+
concurrency:
4+
group: publish
5+
cancel-in-progress: true
6+
7+
on:
8+
release:
9+
types: [published]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
publish-rust:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 30
18+
steps:
19+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
20+
with:
21+
fetch-depth: 0
22+
- uses: ./.github/actions/setup-rust
23+
- name: Install cargo-edit
24+
uses: taiki-e/cache-cargo-install-action@66c9585ef5ca780ee69399975a5e911f47905995
25+
with:
26+
tool: cargo-edit@0.13.10
27+
28+
- name: Cargo Set Version
29+
run: |
30+
# Release Drafter tags are prefixed with "v" (e.g. v0.0.5); cargo
31+
# wants a bare semver, so strip the leading "v".
32+
VERSION="${{ github.event.release.tag_name }}"
33+
cargo set-version "${VERSION#v}"
34+
35+
- name: Publish to crates.io
36+
run: |
37+
cargo publish --no-verify --allow-dirty
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Drafter
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- develop
11+
workflow_dispatch:
12+
# Permits a custom run to create a pre-release
13+
inputs:
14+
prerelease-identifier:
15+
description: "RC identifier (e.g., rc, beta, alpha)"
16+
type: string
17+
default: "rc"
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
update_release_draft:
24+
permissions:
25+
# write permission is required to create a github release
26+
contents: write
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 10
29+
steps:
30+
- uses: release-drafter/release-drafter@693d20e7c1ce1a81d3a41962f85914253b518449 # v7.3.1
31+
with:
32+
commitish: ${{ github.ref_name }}
33+
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
34+
prerelease-identifier: ${{ inputs.prerelease-identifier || '' }}
35+
env:
36+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-plz.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)