-
Notifications
You must be signed in to change notification settings - Fork 66
295 lines (245 loc) · 9.12 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
name: Release
# N.B.: build steps should match the tests we run in ci.yml
on:
create
jobs:
build:
# Use older Ubuntu release to avoid building with a too new glibc, which will cause
# errors on older distributions, if anyone uses the generated binary directly.
runs-on: ubuntu-20.04
permissions: {}
# ensure we don't release on create events for branches (only tags)
if: ${{ startsWith( github.ref, 'refs/tags' ) }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: 1.21
id: go
- name: Set up protoc
uses: pganalyze/setup-protoc@ab6203da1c3118e4406048171b09238ad31ad73e
with:
version: 3.14.0
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check out code
uses: actions/checkout@v4
with:
submodules: true
- name: Runs tests
run: |
make build OUTFILE=pganalyze-collector-linux-amd64
make test
DOCKER_BUILDKIT=1 make integration_test
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: pganalyze-collector-linux-amd64
path: pganalyze-collector-linux-amd64
build_arm:
runs-on: ubicloud-standard-2-arm
permissions: {}
# ensure we don't release on create events for branches (only tags)
if: ${{ startsWith( github.ref, 'refs/tags' ) }}
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: 1.21
id: go
- name: Set up protoc
uses: pganalyze/setup-protoc@149f6c87b92550901b26acd1632e11c3662e381f
with:
version: 3.14.0
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check out code
uses: actions/checkout@v4
with:
submodules: true
- name: Runs tests
run: |
make build OUTFILE=pganalyze-collector-linux-arm64
make test
DOCKER_BUILDKIT=1 make integration_test
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: pganalyze-collector-linux-arm64
path: pganalyze-collector-linux-arm64
build_packages:
# Use older Ubuntu release to ensure availability of CGroupsv1 (which are necessary
# currently to support older systemd on some of the test containers)
runs-on: ubuntu-20.04
permissions: {}
# ensure we don't release on create events for branches (only tags)
if: ${{ startsWith( github.ref, 'refs/tags' ) }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build packages
run: |
DOCKER_BUILDKIT=1 make -C packages build
- name: Test packages
run: |
DOCKER_BUILDKIT=1 make -C packages test
- name: Upload packages as artifacts
uses: actions/upload-artifact@v4
with:
name: packages
path: |
packages/tmp/pganalyze-collector-*.aarch64.rpm
packages/tmp/pganalyze-collector-*.x86_64.rpm
packages/tmp/pganalyze-collector_*_amd64.deb
packages/tmp/pganalyze-collector_*_arm64.deb
if-no-files-found: error
build_charts:
runs-on: ubuntu-latest
# ensure we don't release on create events for branches (only tags)
if: ${{ startsWith( github.ref, 'refs/tags' ) }}
steps:
- name: Install Helm
uses: azure/setup-helm@v4
- name: Check out code
uses: actions/checkout@v4
with:
submodules: true
- name: Create helm package
run: helm package contrib/helm/pganalyze-collector
- name: Upload packages as artifacts
uses: actions/upload-artifact@v4
with:
name: charts
path: |
pganalyze-collector-*.tgz
if-no-files-found: error
release:
needs: [build, build_arm, build_packages, build_charts]
runs-on: ubuntu-latest
# ensure we don't release on create events for branches (only tags)
if: ${{ startsWith( github.ref, 'refs/tags' ) }}
steps:
- name: Download build
uses: actions/download-artifact@v4
with:
name: pganalyze-collector-linux-amd64
- name: Download arm build
uses: actions/download-artifact@v4
with:
name: pganalyze-collector-linux-arm64
- name: Download build packages
uses: actions/download-artifact@v4
with:
name: packages
- name: Download helm package
uses: actions/download-artifact@v4
with:
name: charts
- name: Get version and git version from tag
id: get_version
run: |
echo "git_version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.git_version }}
release_name: ${{ steps.get_version.outputs.git_version }}
draft: false
prerelease: false
- name: Upload release build
id: upload-release-build
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pganalyze-collector-linux-amd64
asset_name: pganalyze-collector-linux-amd64
asset_content_type: application/octet-stream
- name: Upload release build (arm)
id: upload-release-build-arm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pganalyze-collector-linux-arm64
asset_name: pganalyze-collector-linux-arm64
asset_content_type: application/octet-stream
- name: Upload release build package (RPM, x86-64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pganalyze-collector-${{ steps.get_version.outputs.version }}-1.x86_64.rpm
asset_name: pganalyze-collector-${{ steps.get_version.outputs.version }}-1.x86_64.rpm
asset_content_type: application/octet-stream
- name: Upload release build package (RPM, arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pganalyze-collector-${{ steps.get_version.outputs.version }}-1.aarch64.rpm
asset_name: pganalyze-collector-${{ steps.get_version.outputs.version }}-1.aarch64.rpm
asset_content_type: application/octet-stream
- name: Upload release build package (DEB, x86-64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pganalyze-collector_${{ steps.get_version.outputs.version }}_amd64.deb
asset_name: pganalyze-collector_${{ steps.get_version.outputs.version }}_amd64.deb
asset_content_type: application/octet-stream
- name: Upload release build package (DEB, arm64)
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./pganalyze-collector_${{ steps.get_version.outputs.version }}_arm64.deb
asset_name: pganalyze-collector_${{ steps.get_version.outputs.version }}_arm64.deb
asset_content_type: application/octet-stream
release_charts:
needs: [release]
runs-on: ubuntu-latest
permissions:
id-token: write # for AWS credentials
# ensure we don't release on create events for branches (only tags)
if: ${{ startsWith( github.ref, 'refs/tags' ) }}
steps:
- name: Download helm package
uses: actions/download-artifact@v4
with:
name: charts
- name: Install Helm
uses: azure/setup-helm@v4
- name: Get version from tag
id: get_version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Load the current index.yaml
run: curl -o index.yaml https://charts.pganalyze.com/index.yaml
continue-on-error: true
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::793741702295:role/CollectorChartsPackage
aws-region: us-east-1
- name: Upload package to S3
run: |
aws s3 cp --acl public-read \
pganalyze-collector-${{ steps.get_version.outputs.version }}.tgz s3://charts.pganalyze.com/pganalyze-collector-${{ steps.get_version.outputs.version }}.tgz
- name: Create or update index.yaml
run: helm repo index . --merge index.yaml --url https://charts.pganalyze.com/
- name: Upload index.yaml to S3
run: |
aws s3 cp --acl public-read --content-type application/yaml --cache-control no-cache \
index.yaml s3://charts.pganalyze.com/index.yaml