forked from kubeshop/tracetest
-
Notifications
You must be signed in to change notification settings - Fork 0
219 lines (203 loc) · 7.81 KB
/
release-version.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
name: Release Tracetest
permissions:
contents: write
concurrency:
group: "release-version"
cancel-in-progress: true
defaults:
run:
shell: bash
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
jobs:
build-web:
name: build web
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
cache-dependency-path: web/package-lock.json
- name: Cache Build
id: cache-build
uses: actions/cache@v3
with:
path: web/build/
key: web-build-${{ hashFiles('web/*') }}
- run: cd web; npm ci
if: steps.cache-build.outputs.cache-hit != 'true'
- run: cd web; CI= npm run build
if: steps.cache-build.outputs.cache-hit != 'true'
- name: Upload assets
uses: actions/upload-artifact@v3
with:
name: tracetest-web
path: web/build/
release:
runs-on: ubuntu-latest
needs: [build-web]
env:
DOCKER_CLI_EXPERIMENTAL: "enabled"
GORELEASER_KEY: ${{ secrets.GORELEASER_LICENSE }}
GITHUB_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
# fix for this issue: https://github.com/goreleaser/goreleaser/issues/1163
- name: Configure Goreleaser Tags
shell: bash
run: |
prevTag=$(git describe --tags --abbrev=0 v0.11.1^ --exclude='*-rc.*')
echo "GORELEASER_CURRENT_TAG=${{ github.ref_name}}" >> $GITHUB_ENV
echo "GORELEASER_PREVIOUS_TAG="$prevTag >> $GITHUB_ENV
- name: debug info
shell: bash
run: |
echo "GORELEASER_CURRENT_TAG: "$GORELEASER_CURRENT_TAG
echo "GORELEASER_PREVIOUS_TAG: "$GORELEASER_PREVIOUS_TAG
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup go
uses: actions/setup-go@v3
with:
go-version-file: "go.mod"
cache: true
cache-dependency-path: "go.mod"
- uses: actions/download-artifact@v3
with:
name: tracetest-web
path: web/build/
# release
- uses: goreleaser/goreleaser-action@v4
if: steps.cache.outputs.cache-hit != 'true'
with:
distribution: goreleaser-pro
version: v1.23.0
args: release --clean
env:
VERSION: ${{ github.ref_name}}
TRACETEST_ENV: main
ANALYTICS_FE_KEY: ${{ secrets.ANALYTICS_FE_KEY }}
ANALYTICS_BE_KEY: ${{ secrets.ANALYTICS_BE_KEY }}
TRACETEST_DEFAULT_CLOUD_ENDPOINT: ${{ secrets.TRACETEST_DEFAULT_CLOUD_ENDPOINT }}
helm_chart_version_bump:
name: "Trigger Helm chart appVersion update"
needs: "release"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
repository: "kubeshop/helm-charts"
ref: "main"
fetch-depth: 0
token: ${{ secrets.CI_BOT_TOKEN }}
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: v3.4.0
- name: Bump up tracetest chart
run: |
# sets appVersion in the Chart.yaml
echo New appVersion: ${{ github.ref_name }}
sed -i -e "s/^appVersion: .*$/appVersion: \"${{ github.ref_name}}\"/" charts/tracetest/Chart.yaml
# Bumps charts patch version
CURRENT_VERSION=$(sed -n -e "s/^version: \(.*\)$/\1/p" charts/tracetest/Chart.yaml)
echo Current chart version ${CURRENT_VERSION}
NEW_VERSION=$(echo $CURRENT_VERSION |awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
echo New version ${NEW_VERSION}
sed -i -e "s/^version: .*/version: ${NEW_VERSION}/g" charts/tracetest/Chart.yaml
- name: Lint the chart
run: |
helm dependency update charts/tracetest
helm lint charts/tracetest
- name: Push updated chart
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git remote -v
git add .
git commit -m "automatically updated tracetest related charts"
git push
- name: Slack Notification if the helm version bump succeeded
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: tracetest
SLACK_COLOR: good
SLACK_ICON: https://github.githubassets.com/images/modules/site/features/actions-icon-actions.svg
SLACK_TITLE: Helm chart version bump succeeded :party_blob:!
SLACK_MESSAGE: "Tracetest chart version was bumped"
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> Tracetest"
notify_slack_if_helm_chart_bump_fails:
runs-on: ubuntu-latest
needs: helm_chart_version_bump
if: always() && (needs.helm_chart_version_bump.result == 'failure')
steps:
- name: Slack Notification if Helm Release action failed
uses: rtCamp/action-slack-notify@v2
env:
SLACK_CHANNEL: tracetest
SLACK_COLOR: ${{ needs.helm_chart_version_bump.result }}
SLACK_ICON: https://github.githubassets.com/images/modules/site/features/actions-icon-actions.svg
SLACK_TITLE: Helm Chart version bump action failed :boom:!
SLACK_USERNAME: GitHub
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_FOOTER: "Kubeshop --> Tracetest"
chocolatey-release:
needs: release
name: Release on Chocolatey
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download newest version
id: cliDownload
shell: pwsh
run: |
$tag = $env:TAG
$version = $tag.trimStart("v")
echo "$version"
Invoke-Webrequest -URI "https://github.com/kubeshop/tracetest/releases/download/v${version}/tracetest_${version}_windows_amd64.tar.gz" -OutFile tracetest.tar.gz
$hash = Get-FileHash tracetest.tar.gz | Select -ExpandProperty Hash
echo '::echo::on'
echo "::set-output name=hash::$hash"
echo "::set-output name=version::$version"
env:
TAG: ${{ github.ref_name }}
- name: Generate release files
shell: pwsh
run: |
(Get-Content scripts/choco/tools/chocolateyinstall.ps1) -Replace '%checksum%', $env:PACKAGE_CHECKSUM | Set-Content scripts/choco/tools/chocolateyinstall.ps1
(Get-Content scripts/choco/tracetest.nuspec) -Replace '%version%', $env:PACKAGE_VERSION | Set-Content scripts/choco/tracetest.nuspec
env:
PACKAGE_CHECKSUM: ${{ steps.cliDownload.outputs.hash }}
PACKAGE_VERSION: ${{ steps.cliDownload.outputs.version }}
- name: Pack and release
shell: pwsh
run: |
# install choco
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
cd scripts/choco
choco pack
choco push --source https://chocolatey.kubeshop.io/chocolatey --api-key $env:CHOCOLATEY_API_KEY tracetest.$env:PACKAGE_VERSION.nupkg
env:
CHOCOLATEY_API_KEY: ${{ secrets.COMMOM_CHOCO_API_KEY }}
PACKAGE_VERSION: ${{ steps.cliDownload.outputs.version }}