-
Notifications
You must be signed in to change notification settings - Fork 8
170 lines (155 loc) · 6.56 KB
/
release-branch.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Create Release Branch
# creates a release branch, creates a PR and bumps all versions as specified
on:
workflow_dispatch:
jobs:
find-charts-to-release:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine changed charts
id: matrix
run: |
set -x
git rev-list --count origin/main..$(git branch --show-current)
changed_directories=$(echo $(git diff --name-only origin/main) | grep -o 'charts/[^/]*' | cut -d '/' -f 2)
if [[ -z "$changed_directories" ]]; then
echo "No chart changes detected. Chore changes need to be released manually." 1>&2
exit 1
fi
# Entferne Duplikate mit tr und sort
unique_changed_directories=$(echo "$changed_directories" | tr ' ' '\n' | sort -u | tr '\n' ' ')
echo "unique_changed_directories: ${unique_changed_directories}"
arr=($unique_changed_directories)
for element in "${arr[@]}"; do
formatted_output+=" \"$element\","
done
formatted_output=${formatted_output%,} # Entferne das letzte Komma
echo "matrix=[ $formatted_output ]" >> $GITHUB_OUTPUT
# to be able to exchange the version information in the next jobs
touch release-input-parameter.txt
- name: Create artifact
uses: actions/upload-artifact@v4
with:
name: release-input-parameter
path: release-input-parameter.txt
overwrite: true
determine-semantic-version:
needs:
- find-charts-to-release
strategy:
matrix:
value: ${{fromJSON(needs.find-charts-to-release.outputs.matrix)}}
max-parallel: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with: #fetch all commits, not just the last one
fetch-depth: 0
- name: Determine semantic version in loop
id: version
uses: paulhatch/[email protected]
with:
tag_prefix: "${{ matrix.value }}-"
change_path: "charts/${{ matrix.value }}"
major_pattern: "BREAKING_CHANGE"
minor_pattern: '/feat\s*(\(\w+\)*)?:/'
search_commit_body: true
debug: true
- uses: actions/download-artifact@v4
with:
name: release-input-parameter
- name: Create the release input parameters
id: create-release-input-parameter
run: |
set -x
#echo "debug_output: ${{ steps.version.outputs.debug_output }}"
#echo "previous_version : ${{ steps.version.outputs.previous_version }}"
#echo "is_tagged : ${{ steps.version.outputs.is_tagged }}"
#echo "version_type : ${{ steps.version.outputs.version_type }}"
#echo "previous_commit : ${{ steps.version.outputs.previous_commit }}"
#echo "previous_version : ${{ steps.version.outputs.previous_version }}"
echo -n " ${{ matrix.value }}:${{ steps.version.outputs.version_type }}" >> release-input-parameter.txt
- name: Update artifact
uses: actions/upload-artifact@v4
with:
name: release-input-parameter
path: release-input-parameter.txt
overwrite: true
release:
needs:
- determine-semantic-version
permissions:
pull-requests: write
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with: #fetch all commits, not just the last one
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: release-input-parameter
- name: Read release input parameter
id: read-release-input-parameter
run: |
release_inputs=$(cat release-input-parameter.txt | xargs)
echo "release_inputs: $release_inputs"
echo "release-input-parameter=$release_inputs" >> $GITHUB_OUTPUT
rm -f release-input-parameter.txt
- name: Bump versions
uses: ./.github/template/bump-version
with:
changes: ${{ steps.read-release-input-parameter.outputs.release-input-parameter }}
- name: Create bump version commits
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add -A
git commit -m "chore: bump versions of ${{ steps.read-release-input-parameter.outputs.release-input-parameter }}"
- name: Create changelog commits
run: |
mkdir git-chglog
wget -q -O - https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_linux_amd64.tar.gz | tar xzf - -C git-chglog
all=("${{ steps.read-release-input-parameter.outputs.release-input-parameter }}")
for i in $all; do
IFS=':' read -ra my_array <<< "$i"
./git-chglog/git-chglog \
--path ./charts/${my_array[0]} \
--tag-filter-pattern "^${my_array[0]}-\d+.\d+.\d+$" \
--next-tag ${my_array[0]}-$(grep -A0 '^version:' ./charts/${my_array[0]}/Chart.yaml | awk '{print $2}' | sed 's/\"//g') \
-o ./charts/${my_array[0]}/CHANGELOG.md
./git-chglog/git-chglog \
--path ./charts/${my_array[0]} \
--tag-filter-pattern "^${my_array[0]}-\d+.\d+.\d+$" \
--next-tag ${my_array[0]}-$(grep -A0 '^version:' ./charts/${my_array[0]}/Chart.yaml | awk '{print $2}' | sed 's/\"//g') \
-o ./charts/${my_array[0]}/RELEASE_NOTES.md \
${my_array[0]}-$(grep -A0 '^version:' ./charts/${my_array[0]}/Chart.yaml | awk '{print $2}' | sed 's/\"//g')
done
rm -Rf git-chglog
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
git add -A
git commit -m "chore: generated changelog+release notes for ${{ steps.read-release-input-parameter.outputs.release-input-parameter }}"
- name: Reset main branch with changes from develop/?
run: |
git checkout main
git reset --hard ${{ github.ref_name }}
- name: Create Release Branch & PR
id: pr
uses: peter-evans/create-pull-request@v6
with: # commits all changes and creates the release branch and PR. If one already exists, it is updated.
token: ${{ secrets.PR_CREATOR_TOKEN }}
branch: release/${{ github.ref_name }}
base: main
title: Release ${{ steps.read-release-input-parameter.outputs.release-input-parameter }}
commit-message: "release: ${{ steps.read-release-input-parameter.outputs.release-input-parameter }} and dependent charts"
delete-branch: true
labels: automated pr