-
Notifications
You must be signed in to change notification settings - Fork 341
151 lines (134 loc) · 5.56 KB
/
release.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
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
name: "Release charts"
on:
workflow_dispatch:
ref: master
branches:
- master
permissions:
teams:
- development
env:
HELM_VERSION: 3.15.1
YQ_VERSION: 4.44.2
jobs:
release:
permissions:
contents: write
packages: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.VM_BOT_GH_TOKEN }}
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.VM_BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.VM_BOT_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Install tools
uses: yokawasa/[email protected]
with:
setup-tools: |
helmv3
yq
helm: "${{ env.HELM_VERSION }}"
yq: "${{ env.YQ_VERSION }}"
- name: Add dependencies
run: |
yq -M eval '.repositories[] | (.name + " " + .url)' .github/ci/helm-repos.yaml | xargs -L 1 helm repo add
make helm-repo-update
- name: Generate docs
run: make gen-docs
- name: Generate release notes
run: |
for CHANGELOG in $(find charts/*/CHANGELOG.md)
do
if grep -q "^## Next release$" $CHANGELOG
then
echo "Processing $CHANGELOG"
else
echo "ERROR: Not found 'Next release' section in $CHANGELOG"
exit 1
fi
# Useful variables
export CHART_FILE="$(dirname $CHANGELOG)/Chart.yaml"
export APP_VERSION="$(yq -M '.appVersion' $CHART_FILE)"
export CHART_VERSION="$(yq -M '.version' $CHART_FILE)"
# If version already released
if grep -q "^## $CHART_VERSION$" $CHANGELOG
then
echo "There is nothing to release for $CHANGELOG"
else
# Release notes file
export RN_FILE="$(dirname $CHANGELOG)/RELEASE_NOTES.md"
export RN_CONTENT="$(awk '/^## Next release/{flag=1;next}/^## /{flag=0}flag' $CHANGELOG | awk 'NF {p=1} p')"
# ArtifactHub annotation in Chart.yaml file
export CHANGELOG
yq -M -i '.annotations["artifacthub.io/changes"] = (load_str(strenv(CHANGELOG)) | capture("## Next release[\s]*(?P<changes>[\s\S]*?)[\s]*##") | .changes | split("\n") | .[] |= sub("^[\s]*-[\s]+", "") | filter(length > 0) | to_yaml)' $CHART_FILE
# Create release notes
echo "# Release notes for version $CHART_VERSION" > $RN_FILE
echo "" >> $RN_FILE
echo "**Release date:** $(date -I)" >> $RN_FILE
echo "" >> $RN_FILE
if [[ $APP_VERSION != "null" ]]; then
echo "![AppVersion: $APP_VERSION](https://img.shields.io/static/v1?label=AppVersion&message=$APP_VERSION&color=success&logo=)" >> $RN_FILE
fi
echo "![Helm: v3](https://img.shields.io/static/v1?label=Helm&message=v3&color=informational&logo=helm)" >> $RN_FILE
echo "" >> $RN_FILE
echo "$RN_CONTENT" >> $RN_FILE
echo "" >> $RN_FILE
# Update chart version in CHANGELOG
cp $CHANGELOG $CHANGELOG.copy
: > $CHANGELOG
while read -r line; do
echo "$line" >> $CHANGELOG
if [[ $line == "## Next release" ]]
then
echo "" >> $CHANGELOG
echo "- TODO" >> $CHANGELOG
echo "" >> $CHANGELOG
echo "## $CHART_VERSION" >> $CHANGELOG
echo "" >> $CHANGELOG
echo "**Release date:** $(date -I)" >> $CHANGELOG
echo "" >> $CHANGELOG
if [[ $APP_VERSION != "null" ]]; then
echo "![AppVersion: $APP_VERSION](https://img.shields.io/static/v1?label=AppVersion&message=$APP_VERSION&color=success&logo=)" >> $CHANGELOG
fi
echo "![Helm: v3](https://img.shields.io/static/v1?label=Helm&message=v3&color=informational&logo=helm)" >> $CHANGELOG
fi
done < $CHANGELOG.copy
rm $CHANGELOG.copy
fi
done
- name: Release
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.VM_BOT_GH_TOKEN }}"
with:
config: .github/ci/cr.yaml
- name: Release OCI
run: |
helm registry login \
-u ${{ github.actor }} \
-p ${{ github.token }} \
ghcr.io
mkdir -p .cr-release-packages
find .cr-release-packages -name "*.tgz" -exec helm push {} oci://ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/helm-charts \;
- name: Automatic update changelogs and readme
run: |
rm charts/*/RELEASE_NOTES.md
export VM_GIT_BRANCH_NAME="changelog-update-$(date +%s)"
git checkout -b "${VM_GIT_BRANCH_NAME}"
git add charts/*/CHANGELOG.md
git add charts/*/README.md
git commit -S -m "Automatic update CHANGELOGs and READMEs"
git push origin ${VM_GIT_BRANCH_NAME}
gh pr create -f
env:
GH_TOKEN: "${{ secrets.VM_BOT_GH_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.VM_BOT_GH_TOKEN }}"