-
Notifications
You must be signed in to change notification settings - Fork 3
173 lines (153 loc) · 5.91 KB
/
create-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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
###############
# Create release Workflow that :
# - update Chart.yaml version to input one and push to current checkout branch
# - package Helm Chart using chart-releaser (https://github.com/helm/chart-releaser) tool
# - create and publish Github release based on commit previously using release-drafter (https://github.com/release-drafter/release-drafter) tool
# - upload tgz package as release asset
# - update Helm index on gh-pages using chart-releaser (https://github.com/helm/chart-releaser) tool
###############
name: Create release
run-name: Create release ${{ inputs.chart }}-${{ inputs.version }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
chart:
type: choice
description: Chart to release
required: true
default: test-chart
options: #charts directories name supported
- console
- gateway
version:
type: string
description: Chart version to release
required: true
latest:
type: boolean
description: Is this release latest
required: true
default: true
bump_chart:
type: boolean
description: Bump chart version and commit
required: true
default: true
permissions:
contents: write
pull-requests: write
jobs:
create-release:
runs-on: ubuntu-latest
env:
RELEASE_NAME: "${{ inputs.chart }}-${{ inputs.version }}"
PACKAGE_NAME: "${{ inputs.chart }}-${{ inputs.version }}.tgz"
RELEASE_TAG: "${{ inputs.chart }}-${{ inputs.version }}"
CHART_DIR: "./charts/${{ inputs.chart }}"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout main
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.CONDUKTORBOT_REPO_WRITE }}
# :puke:
- name: Gateway PACKAGE_NAME ugly patch
if: ${{ inputs.chart == 'gateway' }}
run:
echo "PACKAGE_NAME=conduktor-gateway-${{ inputs.version }}.tgz" >> "${GITHUB_ENV}"
- name: Gateway RELEASE_TAG ugly patch
if: ${{ inputs.chart == 'gateway' }}
run:
echo "RELEASE_TAG=conduktor-gateway-${{ inputs.version }}" >> "${GITHUB_ENV}"
- name: Gateway RELEASE_NAME ugly patch
if: ${{ inputs.chart == 'gateway' }}
run:
echo "RELEASE_NAME=conduktor-gateway-${{ inputs.version }}" >> "${GITHUB_ENV}"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: "v3.10.1"
- name: Add bitnami repository
run: helm repo add bitnami https://charts.bitnami.com/bitnami
- name: Install Chart Releaser
env:
CR_VERSION: 1.6.1
CR_BIN_PATH: "/opt/hostedtoolcache/chart-releaser"
run: |
echo $PATH
mkdir -p ${{ env.CR_BIN_PATH }}
wget -O /tmp/cr.tar.gz https://github.com/helm/chart-releaser/releases/download/v${{env.CR_VERSION}}/chart-releaser_${{env.CR_VERSION}}_linux_amd64.tar.gz
tar -xzvf /tmp/cr.tar.gz -C ${{ env.CR_BIN_PATH }}
sudo chmod +x ${{ env.CR_BIN_PATH }}/cr
echo "${{env.CR_BIN_PATH}}" >> $GITHUB_PATH
echo "Chart releaser installed at ${{env.CR_BIN_PATH}}"
- name: Setup ConduktorBot GPG
id: gpg
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.CONDUKTOR_BOT_GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Setup git config
run: |
git config user.name "${{ steps.gpg.outputs.name }}"
git config user.email "${{ steps.gpg.outputs.email }}"
- name: Update chart version
if: ${{ inputs.bump_chart }}
uses: mikefarah/yq@master
env:
VERSION: ${{ inputs.version }}
with:
cmd: yq e -i '.version = env(VERSION)' ${{ env.CHART_DIR }}/Chart.yaml
- name: Commit chart version update
id: commit
run: |
if ${{ inputs.bump_chart }}; then
echo "Bumping chart version"
git add ${{ env.CHART_DIR }}/Chart.yaml
git diff
git commit -am "Update chart ${{ inputs.chart }} version to ${{ inputs.version }}"
git push
else
echo "Not bumping chart version"
fi
update_commit=$(git rev-parse HEAD)
echo "commit_sha1=${update_commit}" >> "${GITHUB_OUTPUT}"
- name: Package chart ${{ inputs.chart }}
id: package
run: |
cr version
cr package ${{ env.CHART_DIR }} --package-path ${{ env.CHART_DIR }}/.cr-release-packages
echo "package_file=${{ env.CHART_DIR }}/.cr-release-packages/${{ env.PACKAGE_NAME }}" >> "${GITHUB_OUTPUT}"
- name: Create github release ${{ env.RELEASE_NAME }}
id: release
uses: release-drafter/release-drafter@v5
with:
config-name: "release-drafter/${{ inputs.chart }}.yaml"
publish: true
version: ${{ inputs.version }}
name: "${{ env.RELEASE_NAME }}"
tag: "${{ env.RELEASE_TAG }}"
latest: ${{ inputs.latest }}
commitish: ${{ steps.commit.outputs.commit_sha1 }}
- name: Upload package chart to release
id: upload
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ env.GITHUB_TOKEN }}
file: ${{ steps.package.outputs.package_file }}
tag: ${{ steps.release.outputs.tag_name }}
- name: Update helm index
run: |
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")
cr version
cr index \
--index-path index.yaml \
--push \
-r "$repo" \
-o "$owner" \
--package-path ${{ env.CHART_DIR }}/.cr-release-packages \
--token ${{ secrets.CONDUKTORBOT_REPO_WRITE }}