-
Notifications
You must be signed in to change notification settings - Fork 157
92 lines (85 loc) · 3.16 KB
/
Copy pathrelease-pr.yml
File metadata and controls
92 lines (85 loc) · 3.16 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
89
90
91
92
name: Release PR
on:
workflow_dispatch:
inputs:
version:
description: "Version (leave empty for auto bump, or specify e.g. 0.8.0-beta.1)"
required: false
type: string
bump:
description: "Auto bump type (ignored when version is specified)"
required: false
type: choice
options:
- patch
- minor
- major
default: patch
jobs:
create-release-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Generate App token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v6
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0
- name: Resolve version
id: version
run: |
if [ -n "${{ inputs.version }}" ]; then
VERSION="${{ inputs.version }}"
else
CURRENT=$(grep '^version:' charts/openab/Chart.yaml | awk '{print $2}')
BASE="${CURRENT%%-*}"
if [[ "$CURRENT" == *-beta.* ]]; then
BETA_NUM="${CURRENT##*-beta.}"
VERSION="${BASE}-beta.$((BETA_NUM + 1))"
else
IFS='.' read -r major minor patch <<< "$BASE"
case "${{ inputs.bump }}" in
major) major=$((major + 1)); minor=0; patch=0 ;;
minor) minor=$((minor + 1)); patch=0 ;;
patch) patch=$((patch + 1)) ;;
esac
VERSION="${major}.${minor}.${patch}-beta.1"
fi
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "::notice::Release version: ${VERSION}"
# Determine stable version (strip pre-release suffix)
STABLE="${VERSION%%-*}"
echo "stable=${STABLE}" >> "$GITHUB_OUTPUT"
- name: Update version files
run: |
VERSION="${{ steps.version.outputs.version }}"
STABLE="${{ steps.version.outputs.stable }}"
# Chart.yaml always gets the full version (beta or stable)
sed -i "s/^version: .*/version: ${VERSION}/" charts/openab/Chart.yaml
sed -i "s/^appVersion: .*/appVersion: \"${VERSION}\"/" charts/openab/Chart.yaml
# Cargo.toml only gets stable version (main stays clean)
sed -i "s/^version = .*/version = \"${STABLE}\"/" Cargo.toml
- name: Create release PR
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
BRANCH="release/v${VERSION}"
git config user.name "openab-app[bot]"
git config user.email "274185012+openab-app[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git add -A
git commit -m "release: v${VERSION}"
git push origin "$BRANCH"
gh pr create \
--title "release: v${VERSION}" \
--body "Merge this PR to tag \`v${VERSION}\` and trigger the build pipeline." \
--base main --head "$BRANCH"