-
-
Notifications
You must be signed in to change notification settings - Fork 26
70 lines (61 loc) · 2.68 KB
/
release.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
name: Release Charts
on:
push:
branches:
- main
paths:
- 'charts/**'
# Only allow 1 release at a time (avoid concurent deployment to gh-pages)
concurrency: "release-chart"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
# Needed for subchart dependencies
- name: Add jenkins-infra Helm repository
run: helm repo add jenkins-infra https://jenkins-infra.github.io/helm-charts
- name: Run chart-releaser
id: chart_releaser
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Update modified chart release(s)
id: update_chart_releases
if: steps.chart_releaser.outputs.changed_charts != ''
run: |
# KISS, last commit subject as changelog for every modified chart
changelog=$(git log --format=%s -n 1)
# Set IFS to a comma to split the string into an array
IFS=',' read -ra changedCharts <<< "${{ steps.chart_releaser.outputs.changed_charts }}"
for chart in "${changedCharts[@]}"; do
chartName=$(echo "${chart}" | cut -d '/' -f 2)
# Retrieve version from Chart.yaml
version=$(yq '.version' "${chart}/Chart.yaml")
# Retrive release id and body from tag
tag="${chartName}-${version}"
release=$(curl --location --silent --fail --show-error "https://api.github.com/repos/${{ github.repository }}/releases/tags/${tag}")
releaseId=$(echo "${release}" | jq --raw-output '.id')
releaseBody=$(echo "${release}" | jq --raw-output '.body')
# Update release
newlines="\r\n\r\n"
body="${releaseBody}${newlines}## Changelog${newlines}${changelog}"
echo "= release description for ${tag}:"
echo "${body}"
curl --silent --fail --show-error --output /dev/null --location \
-X PATCH \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/releases/${releaseId}" \
--data "{\"body\":\"${body}\"}"
done