-
Notifications
You must be signed in to change notification settings - Fork 22
114 lines (109 loc) · 3.56 KB
/
release-branch.yaml
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
# This creates a new release branch from the main branch.
# It serves as the cutoff point for the next minor release.
# From this point onward only bug fixes and critical changes will be accepted onto the release
# branch as backports from main. At the same time, the main branch will be open for new features
# and changes for the next minor release.
name: Release Branch Cutoff
on:
workflow_dispatch:
permissions:
# Necessary to write the branch
contents: write
jobs:
cutoff-preconditions:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
repository-projects: read
outputs:
minor: ${{ steps.get-minor.outputs.minor }}
branch: ${{ steps.verify-branch.outputs.branch }}
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.OCMBOT_APP_ID }}
private_key: ${{ secrets.OCMBOT_PRIV_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: '${{ github.workspace }}/go.mod'
cache: false
- name: Get Minor
id: get-minor
run: |
set -e
minor="$(go run ./api/version/generate print-major-minor)"
echo "minor=$minor" >> $GITHUB_OUTPUT
echo "Current Major-Minor Version: $minor"
- name: Verify Branch does not exist
id: verify-branch
run: |
set -e
minor="v${{ steps.get-minor.outputs.minor }}"
branch="releases/$minor"
if git ls-remote --exit-code origin refs/heads/$branch ; then
>&2 echo "branch $branch already exists, aborting"
exit 1
fi
echo "branch $branch does not exist"
echo "branch=$branch" >> $GITHUB_OUTPUT
create-branch:
runs-on: ubuntu-latest
needs: cutoff-preconditions
permissions:
contents: write
id-token: write
repository-projects: read
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.OCMBOT_APP_ID }}
private_key: ${{ secrets.OCMBOT_PRIV_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ steps.generate_token.outputs.token }}
- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
# tag the cutoff point in main so that it can be used for release note generation
- name: Create Cutoff Tag in Main
run: |
set -e
tag="v${{ needs.cutoff-preconditions.outputs.minor }}"
msg="Cutoff for $tag"
git tag --annotate --message "${msg}" "$tag"
git push origin "$tag"
# create a new branch
- name: Create Release Branch
run: |
set -e
branch=${{ needs.cutoff-preconditions.outputs.branch }}
git checkout -b "$branch"
git push origin $branch
# Make sure main contains the next minor after cutoff
bump-main-pr:
uses: ./.github/workflows/release-bump-version.yaml
needs: create-branch
permissions:
contents: write
id-token: write
packages: write
secrets: inherit
with:
bump-type: minor
ref: ${{ github.ref }}