-
Notifications
You must be signed in to change notification settings - Fork 49
223 lines (212 loc) · 8.04 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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
name: Release
on:
push:
tags:
- "v*"
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push image to docker hub
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USER }} --password-stdin
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker buildx create --use
make container
- name: Release Note
run: |
RELEASE_VERSION=${GITHUB_REF#refs/*/}
PREVERSION=$(git for-each-ref --sort='-creatordate' --format='%(refname:lstrip=2)' --count=50 'refs/tags/*' | grep -v 'rc' | awk 'NR==2')
echo ${PREVERSION}
echo ${PREVERSION}
echo "$(./.github/release-note.sh ${PREVERSION} ${RELEASE_VERSION})" > release_note.md
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
body_path: release_note.md
- name: Collect Release Info
run: |
echo "${{ steps.create_release.outputs.upload_url }}" >> UPLOAD_URL
echo ${{ env.RELEASE_VERSION }} >> RELEASE_VERSION
git reset --hard
- name: Upload RELEASE_VERSION
uses: actions/upload-artifact@v4
with:
name: RELEASE_VERSION
path: RELEASE_VERSION
- name: Upload UPLOAD_URL
uses: actions/upload-artifact@v4
with:
name: UPLOAD_URL
path: UPLOAD_URL
- name: Repository Dispatch
uses: aurelien-baudet/workflow-dispatch@v2
with:
workflow: Upload_release
token: ${{ secrets.REPOSITORYDISPATCH }}
inputs: '{"url": "${{ steps.create_release.outputs.upload_url }}", "tag": "${{ github.ref_name }}"}'
- name: Make changes to pull request
run: make version && echo ${GITHUB_REF#refs/*/} > plugins/stable.txt
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
add-paths: |
*.yaml
plugins/stable.txt
token: ${{ secrets.REPOSITORYDISPATCH }}
commit-message: "feat: update krew index version to ${{ github.ref }}"
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
signoff: false
branch: feat/update-krew-index-version
base: master
delete-branch: true
title: 'feat: update krew index version to ${{ github.ref }}'
body: |
update report
- update with *today's* date
- update krew index version to ${{ github.ref }}
labels: |
report
automated pr
draft: false
release-helm-chart:
name: Release KubeVPN Helm Chart
needs: [ build ]
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Helm tool installer
uses: azure/setup-helm@v4
with:
version: "v3.6.3"
- name: Change chart version
run: |
VERSION=${GITHUB_REF#refs/*/}
CHART_VERSION=${VERSION/#v/}
sed -i "s/^appVersion:.*$/appVersion: \"${VERSION}\"/;s/^version:.*$/version: ${CHART_VERSION}/" charts/kubevpn/Chart.yaml
sed -i "s/tag:.*$/tag: \"${VERSION}\"/" charts/kubevpn/values.yaml
- name: Tar chart
run: |
VERSION=${GITHUB_REF#refs/*/}
CHART_VERSION=${VERSION/#v/}
tar --transform 's/^charts\/kubevpn/kubevpn/' -zcf kubevpn-${CHART_VERSION}.tgz charts/kubevpn
shasum -a 256 kubevpn-${CHART_VERSION}.tgz | awk '{print $1}' > kubevpn-${CHART_VERSION}.tgz-SHA256
- name: Download UPLOAD_URL
uses: actions/download-artifact@v4
with:
name: UPLOAD_URL
- name: Get Release UPLOAD_URL
id: get_release_info
run: |
UploadUrl=$(cat ./UPLOAD_URL)
echo "::set-output name=upload_url::$UploadUrl"
- name: Get assert name
id: get_assert_info
run: |
VERSION=${GITHUB_REF#refs/*/}
CHART_VERSION=${VERSION/#v/}
AssertName=kubevpn-${CHART_VERSION}.tgz
echo "::set-output name=assert_name::$AssertName"
- name: Get assert SHA256 name
id: get_assert_info_sha256
run: |
VERSION=${GITHUB_REF#refs/*/}
CHART_VERSION=${VERSION/#v/}
AssertName=kubevpn-${CHART_VERSION}.tgz-SHA256
echo "::set-output name=assert_name::$AssertName"
- name: Upload Release Asset KubeVPN Server Chart
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ steps.get_assert_info.outputs.assert_name }}
asset_name: ${{ steps.get_assert_info.outputs.assert_name }}
asset_content_type: application/octet-stream
- name: Upload Release Asset KubeVPN Chart SHA256
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ${{ steps.get_assert_info_sha256.outputs.assert_name }}
asset_name: ${{ steps.get_assert_info_sha256.outputs.assert_name }}
asset_content_type: application/octet-stream
github-pages-deploy:
name: Release Helm Chart To branch master
permissions:
contents: write
runs-on: ubuntu-latest
needs: release-helm-chart
steps:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
check-latest: true
- name: Checkout code
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@v4
- name: Change chart version
run: |
VERSION=${GITHUB_REF#refs/*/}
CHART_VERSION=${VERSION/#v/}
sed -i "s/^appVersion:.*$/appVersion: \"${VERSION}\"/;s/^version:.*$/version: ${CHART_VERSION}/" charts/kubevpn/Chart.yaml
sed -i "s/tag:.*$/tag: \"${VERSION}\"/" charts/kubevpn/values.yaml
- name: Package and upload helm chart
run: |
# download helm chart releaser
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/v1.6.1/chart-releaser_1.6.1_linux_amd64.tar.gz"
tar -xzf cr.tar.gz
rm -f cr.tar.gz
owner=$(cut -d '/' -f 1 <<< "$GITHUB_REPOSITORY")
repo=$(cut -d '/' -f 2 <<< "$GITHUB_REPOSITORY")
# package chart
./cr package charts/$repo
# update index and push to github pages
git config user.email "[email protected]"
git config user.name "$owner"
./cr index \
--owner "$owner" \
--git-repo "$repo" \
--token "${{ secrets.CREATE_HELM_PR }}" \
--release-name-template "v{{ .Version }}" \
--index-path ./index.yaml \
--charts-repo https://github.com/$owner/$repo \
--pages-branch master \
--pages-index-path charts/index.yaml \
--push