Skip to content

Commit 122150c

Browse files
ci(shield): release branches automation (#2363)
1 parent 5691590 commit 122150c

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Shield Release Branch Updater
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
kind:
7+
description: 'Shield component'
8+
required: true
9+
default: "cluster"
10+
type: choice
11+
options:
12+
- "cluster"
13+
- "host-windows"
14+
- "host-linux"
15+
latest_release_version:
16+
description: 'Latest release version'
17+
required: true
18+
next_release_version:
19+
description: 'Next release version'
20+
required: true
21+
22+
permissions:
23+
contents: write
24+
25+
env:
26+
CURRENT_RELEASE_BRANCH: ${{ inputs.kind }}-shield-release-${{ inputs.latest_release_version}}
27+
NEXT_RELEASE_BRANCH: ${{ inputs.kind }}-shield-release-${{ inputs.next_release_version}}
28+
29+
jobs:
30+
update-current-release-branch:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout current release branch
34+
id: checkout
35+
uses: actions/checkout@v5
36+
continue-on-error: true
37+
with:
38+
ref: ${{ env.CURRENT_RELEASE_BRANCH }}
39+
fetch-depth: 0
40+
41+
- name: Checkout main branch
42+
if: steps.checkout.outcome == 'failure'
43+
uses: actions/checkout@v5
44+
45+
- name: Create current release branch
46+
if: steps.checkout.outcome == 'failure'
47+
run: |
48+
git checkout -b ${{ env.CURRENT_RELEASE_BRANCH }}
49+
git push -u origin ${{ env.CURRENT_RELEASE_BRANCH }}
50+
51+
- name: Update current release branch
52+
if: steps.checkout.outcome == 'success'
53+
run: |
54+
git config user.name "$GITHUB_ACTOR"
55+
git config user.email "[email protected]"
56+
./scripts/shield/rebase.sh
57+
git push --force-with-lease
58+
59+
update-next-release-branch:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout next release branch
63+
id: checkout
64+
uses: actions/checkout@v5
65+
continue-on-error: true
66+
with:
67+
ref: ${{ env.NEXT_RELEASE_BRANCH }}
68+
fetch-depth: 0
69+
70+
- name: Checkout main branch
71+
if: steps.checkout.outcome == 'failure'
72+
uses: actions/checkout@v5
73+
74+
- name: Create next release branch
75+
if: steps.checkout.outcome == 'failure'
76+
run: |
77+
git checkout -b ${{ env.NEXT_RELEASE_BRANCH }}
78+
git push -u origin ${{ env.NEXT_RELEASE_BRANCH }}
79+
80+
- name: Update next release branch
81+
if: steps.checkout.outcome == 'success'
82+
run: |
83+
git config user.name "$GITHUB_ACTOR"
84+
git config user.email "[email protected]"
85+
./scripts/shield/rebase.sh
86+
git push --force-with-lease

scripts/shield/rebase.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
function check_conflicts() {
4+
# check if the only conflict is on the chart version
5+
CONFLICTS=$(git --no-pager diff --cc --name-only)
6+
if [[ "$CONFLICTS" = "charts/shield/Chart.yaml" ]]; then
7+
echo "Chart version conflict detected, accepting the incoming change"
8+
9+
# Accept the main branch version for Chart.yaml
10+
git checkout --ours charts/shield/Chart.yaml
11+
git add charts/shield/Chart.yaml
12+
13+
echo "Resolved Chart.yaml conflict, continuing rebase"
14+
export GIT_EDITOR=true
15+
if git rebase --continue; then
16+
echo "Rebase continued successfully"
17+
else
18+
echo "Checking for conflicts again ..."
19+
check_conflicts
20+
fi
21+
elif [[ "$CONFLICTS" = "" ]]; then
22+
echo "All conflicts resolved!"
23+
else
24+
echo "Unexpected conflicts detected in: $CONFLICTS"
25+
git rebase --abort
26+
exit 1
27+
fi
28+
}
29+
30+
if git pull --rebase origin main; then
31+
echo "Rebased successfully!"
32+
else
33+
echo "Rebase conflicts detected"
34+
check_conflicts
35+
fi

0 commit comments

Comments
 (0)