-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (71 loc) · 3.1 KB
/
Copy pathrelease-pr.yml
File metadata and controls
88 lines (71 loc) · 3.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Release PR
on:
workflow_dispatch:
inputs:
version:
description: "Next version (e.g. 1.2.0)"
required: true
type: string
jobs:
open-release-pr:
name: Bump version and open release PR
runs-on: ubuntu-latest
steps:
- name: Validate version format
run: |
if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must be X.Y.Z (no pre-release suffixes). Got: ${{ inputs.version }}"
exit 1
fi
- uses: actions/checkout@v4
with:
ref: dev
fetch-depth: 0
token: ${{ secrets.RELEASE_PR_TOKEN }}
- name: Confirm version is strictly greater than current
run: |
CURRENT=$(grep -m1 '^version = ' Cargo.toml | sed -E 's/version = "(.*)"/\1/')
NEXT="${{ inputs.version }}"
HIGHEST=$(printf '%s\n%s\n' "$CURRENT" "$NEXT" | sort -V | tail -n1)
if [ "$CURRENT" = "$NEXT" ] || [ "$HIGHEST" != "$NEXT" ]; then
echo "::error::New version ($NEXT) must be strictly greater than current ($CURRENT)"
exit 1
fi
echo "Bumping $CURRENT -> $NEXT"
- name: Bump version in Cargo.toml
run: |
# Replace the first `version = "..."` line, which is the [package] version.
sed -i -E "0,/^version = \".*\"/ s//version = \"${{ inputs.version }}\"/" Cargo.toml
# Keep Cargo.lock in sync without touching anything else.
cargo update --workspace --offline || cargo update --workspace
- name: Commit and push bump
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: bump version to ${{ inputs.version }}"
git push origin dev
- name: Open release PR
env:
GH_TOKEN: ${{ secrets.RELEASE_PR_TOKEN }}
run: |
PR_BODY_FILE=$(mktemp)
cat > "$PR_BODY_FILE" <<'EOF'
<!-- release-notes -->
<!-- release-notes:todo — remove this line once the notes below are final. While this marker is present, merging falls back to GitHub's auto-generated notes. -->
## Release notes
### Highlights
<!-- One narrative bullet per theme: what changed and why it matters to a user. Group related work; don't echo commit messages. -->
### Behavior changes to know about
<!-- Observable deltas: changed defaults, renamed output, compatibility notes. Omit the section when empty. -->
### Fixes
<!-- Bugs fixed: the observable symptom, then the cause. Omit the section when empty. -->
### Internal changes
<!-- Refactors, test and infrastructure work. Omit the section when empty. -->
EOF
PR_URL=$(gh pr create \
--base main \
--head dev \
--title "Release v${{ inputs.version }}" \
--body-file "$PR_BODY_FILE")
echo "Opened release PR: $PR_URL" >> "$GITHUB_STEP_SUMMARY"