forked from jenkins-infra/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (67 loc) · 2.8 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
71
72
73
74
75
76
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@5119fcb9089d432beecbf79bb2c7915207344b78 # v3
# 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)
echo "= changelog: ${changelog}"
# 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)
echo "= chartName: ${chartName}"
# Retrieve version from Chart.yaml
version=$(yq '.version' "${chart}/Chart.yaml")
echo "= version: ${version}"
tag="${chartName}-${version}"
echo "= tag: ${tag}"
# Retrive release id and body from tag
release=$(curl -L "https://api.github.com/repos/${{ github.repository }}/releases/tags/${tag}")
releaseId=$(echo "${release}" | jq --raw-output '.id')
echo "= releaseId: ${releaseId}"
releaseBody=$(echo "${release}" | jq --raw-output '.body')
echo "= releaseBody: ${releaseBody}"
# Update release
newlines="\r\n\r\n"
body="${releaseBody}${newlines}## Changelog${newlines}${changelog}"
echo "= body:"
echo "${body}"
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/releases/${releaseId}" \
-d "{\"body\":\"${body}\"}"
done