-
Notifications
You must be signed in to change notification settings - Fork 1
216 lines (196 loc) · 7.68 KB
/
go-kubernetes.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
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
name: Test and release
on:
workflow_call:
secrets:
# required when `sonarCloudEnabled`
SONAR_TOKEN:
required: false
# required when `publishingHelmChartEnabled`
GH_RW_TOKEN:
required: false
inputs:
goVersion:
type: string
default: 1.19
binaryName:
type: string
required: true
dockerImage:
type: string
required: true
chartsRepoUrl:
type: string
default: https://riotkit-org.github.io/helm-of-revolution
chartOwner:
type: string
default: "riotkit-org"
chartRepository:
type: string
default: "helm-of-revolution"
chartRepoBranch:
type: string
default: "gh-pages"
chartsDir:
description: "Local directory, where chart is placed"
type: string
default: "helm"
chartImageTagPath:
description: "Path to the image tag name in values.yaml (dot notation)"
type: string
default: ".image.tag"
sonarCloudEnabled:
type: boolean
default: false
publishingHelmChartEnabled:
type: boolean
default: false
dockerReleasingEnabled:
type: boolean
default: true
testReportEnabled:
type: boolean
default: false
testReportPattern:
type: string
default: "junit.xml"
coverageReportEnabled:
type: boolean
default: false
coverageReportPath:
type: string
default: "coverage.out"
osVariant:
type: string
default: "ubuntu-20.04"
jobs:
build:
runs-on: ${{ inputs.osVariant }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ inputs.goVersion }}
- name: Build
run: "make build"
- name: Test
run: "make coverage"
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
if: github.ref == 'refs/heads/main' && inputs.sonarCloudEnabled
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: actions/upload-artifact@v3
with:
name: binary
path: .build/${{ inputs.binaryName }}
- name: Test report
if: always() && inputs.testReportEnabled
uses: phoenix-actions/test-reporting@v8
with:
name: Tests
path: ${{ inputs.testReportPattern }}
reporter: java-junit
- name: Coverage report
if: always() && ! contains(github.event.pull_request.user.login, 'dependabot[bot]') && inputs.coverageReportEnabled
uses: slavcodev/coverage-monitor-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
coverage_path: ${{ inputs.coverageReportPath }}
release-binary:
runs-on: ${{ inputs.osVariant }}
needs: ["build"]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- uses: actions/download-artifact@v3
with:
name: binary
path: .build/
- name: Release binaries to GitHub releases
uses: softprops/action-gh-release@v1
with:
files: |
.build/${{ inputs.binaryName }}
release-docker:
runs-on: ${{ inputs.osVariant }}
needs: ["build"]
if: (contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main') && inputs.dockerReleasingEnabled
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/download-artifact@v3
with:
name: binary
path: .build/
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create docker tags
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ inputs.dockerImage }}
- name: Build and relase docker
uses: docker/build-push-action@v2
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
release-chart:
runs-on: ${{ inputs.osVariant }}
needs: ["release-docker"]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') && inputs.publishingHelmChartEnabled
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- uses: DamianReeves/write-file-action@v1.2
with:
path: set-version.sh
contents: |
set -e
chartsDir=${{ inputs.chartsDir }}
version=${{github.ref_name}}
dotPath=${{inputs.chartImageTagPath}}
for chartName in $(ls ${chartsDir}); do
if [ ! -f "${chartsDir}/${chartName}/Chart.yaml" ]; then
echo " >> ${chartsDir}/${chartName}/Chart.yaml not present, skipping"
continue
fi
yq e -i ".version = \"${version/v/}\"" "${chartsDir}/${chartName}/Chart.yaml"
yq e -i ".appVersion = \"${version}\"" "${chartsDir}/${chartName}/Chart.yaml"
yq e -i "${dotPath} = \"${version}\"" "${chartsDir}/${chartName}/values.yaml"
done
- name: Set version
uses: mikefarah/yq@v4.30.6
with:
cmd: sh set-version.sh
- name: Publish Helm chart
uses: stefanprodan/helm-gh-pages@master
with:
token: "${{ secrets.GH_RW_TOKEN }}"
charts_dir: ${{ inputs.chartsDir }}
charts_url: ${{ inputs.chartsRepoUrl }}
owner: ${{ inputs.chartOwner }}
repository: ${{ inputs.chartRepository }}
branch: ${{ inputs.chartRepoBranch }}
target_dir: ./
commit_username: "${{ env.GITHUB_ACTOR }}"
commit_email: "${{ env.GITHUB_ACTOR }}@users.noreply.github.com"
app_version: "${{github.ref_name}}"
chart_version: "${{github.ref_name}}"