-
Notifications
You must be signed in to change notification settings - Fork 13
124 lines (106 loc) · 4.26 KB
/
release-finalize.yml
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
name: Finalize Release
on:
pull_request:
types: [closed]
branches:
- main
# Add permissions for GitHub operations
permissions:
contents: write
pull-requests: write
jobs:
finalize-release:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper tagging
- name: Setup Git Identity
run: |
set -e
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: Download changelog artifact
uses: actions/download-artifact@v4
with:
name: changelog
path: .
- name: Get release version
id: get_version
run: |
set -e
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
# We only support release/v* format now
VERSION=${BRANCH_NAME#release/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag_name=$VERSION" >> $GITHUB_OUTPUT
- name: Create and push tag
run: |
set -e
git tag -a ${{ steps.get_version.outputs.tag_name }} -m "Release ${{ steps.get_version.outputs.tag_name }}"
git push origin ${{ steps.get_version.outputs.tag_name }}
# This tag push will automatically trigger the docker.yml workflow for building images
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.get_version.outputs.tag_name }}
name: Release ${{ steps.get_version.outputs.tag_name }}
body_path: CHANGELOG.md # Use the downloaded changelog
generate_release_notes: false # We're using our own changelog
draft: false
prerelease: false
- name: Create PR to develop
run: |
set -e
gh pr create --base develop --head ${{ github.event.pull_request.head.ref }} \
--title "Merge ${{ github.event.pull_request.head.ref }} into develop" \
--body "Merge release branch into develop."
- name: Merge into develop
run: |
set -e
PR_NUMBER=$(gh pr list --head ${{ github.event.pull_request.head.ref }} --base develop --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge --repo ${{ github.repository }} --merge --auto $PR_NUMBER
else
echo "No PR found to merge into develop"
exit 1
fi
# --- Post-Release Version Bump ---
- name: Checkout develop branch for version bump
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper tagging
ref: develop
- name: Install dependencies for version bump
run: |
set -e
sudo apt-get update && sudo apt-get install -y protobuf-compiler
cargo install cargo-edit
- name: Calculate and apply next development version
id: calculate_next_version
run: |
set -e
# Extract version without 'v' prefix
RAW_VERSION=${{ steps.get_version.outputs.version }}
VERSION_WITHOUT_V="${RAW_VERSION#v}"
IFS='.' read -ra VERSION_PARTS <<< "$VERSION_WITHOUT_V"
MAJOR="${VERSION_PARTS[0]}"
MINOR="${VERSION_PARTS[1]}"
PATCH=$((VERSION_PARTS[2] + 1)) # Increment the patch version
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}-dev"
echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Setting develop version to $NEXT_VERSION"
# Update Cargo.toml versions
find . -name "Cargo.toml" -type f -exec cargo set-version $NEXT_VERSION --manifest-path {} \;
# Update any other version references
if [ -f "VERSION" ]; then
echo "$NEXT_VERSION" > VERSION
fi
# Commit and push the version bump directly to develop
git add -A
git commit -m "chore: bump version to $NEXT_VERSION [skip ci]"
git push origin develop