-
Notifications
You must be signed in to change notification settings - Fork 2
302 lines (290 loc) · 9.08 KB
/
build-and-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
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
296
297
298
299
300
301
302
name: Build & Release
on:
workflow_dispatch:
push:
branches: [ main ]
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
pull_request:
branches: [ main ]
env:
GO_VERSION: 1.19.8
RUBY_VERSION: 3.1.2
BUNDLER_VERSION: 2.3.7
jobs:
build:
if: |
!contains(github.event.pull_request.labels.*.name, 'skip:ci')
name: "build"
runs-on: ubuntu-latest
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/omnibus/Gemfile
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler: ${{ env.BUNDLER_VERSION}}
bundler-cache: true
- name: Unit test
run: |
sudo mkdir -p /opt/gemfast/etc/gemfast/
sudo chown -R $USER: /opt/gemfast
make test
- name: Get version
id: get-version
run: |
v=$(cat VERSION)
echo "version=${v}" >> "$GITHUB_OUTPUT"
- name: Build omnibus package
run: |
sudo mkdir -p /var/cache/omnibus
sudo chown -R $USER: /var/cache/omnibus
cd omnibus
bundle exec omnibus build gemfast
sha512sum pkg/*.deb > "pkg/gemfast-${{ steps.get-version.outputs.VERSION }}-checksums.txt"
- name: Upload omnibus package
uses: actions/upload-artifact@v3
with:
name: gemfast-omnibus
path: omnibus/pkg/
if-no-files-found: error
- name: Build docker image
run: |
docker build -t server:${{ steps.get-version.outputs.VERSION }}-pre .
docker tag server:${{ steps.get-version.outputs.VERSION }}-pre server:latest
docker save server:latest > gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
- name: Upload docker image
uses: actions/upload-artifact@v3
with:
name: gemfast-docker
path: gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
if-no-files-found: error
smoke-test:
name: "smoke"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
repository: rails/rails
path: clones/rails
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Smoke test
run: ./scripts/run_smoke_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
cve-test:
name: "cve"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: CVE test
run: ./scripts/run_cve_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
filter-test:
name: "filter"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Filter test
run: ./scripts/run_filter_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
private-gems-test:
name: "private-gems"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Private gems test
run: ./scripts/run_private_gem_tests.sh "${{ matrix.pkg }}"
env:
BUILD_TYPE: "${{ matrix.pkg }}"
auth-test:
name: "auth"
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
pkg: [omnibus, docker]
steps:
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
- uses: actions/download-artifact@v3
with:
name: gemfast-${{ matrix.pkg }}
- name: Private gems test
run: ./scripts/run_auth_tests.sh
env:
BUILD_TYPE: "${{ matrix.pkg }}"
pre-release:
name: "pre-release"
permissions: write-all
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: "ubuntu-latest"
needs:
- build
- smoke-test
- cve-test
- filter-test
- private-gems-test
- auth-test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
with:
name: gemfast-omnibus
- uses: actions/download-artifact@v3
with:
name: gemfast-docker
- name: Get version
id: get-version
run: |
v=$(cat VERSION)
echo "version=${v}" >> "$GITHUB_OUTPUT"
- name: Rename omnibus artifact
run: |
mv *.deb "gemfast-${{ steps.get-version.outputs.VERSION }}-pre-amd64.deb"
mv *.txt "gemfast-${{ steps.get-version.outputs.VERSION }}-pre-checksums.txt"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push docker image
run: |
docker load < gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
docker tag server:latest ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}-pre
docker push ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}-pre
- name: Create pre-release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create --prerelease --generate-notes --title "${{ steps.get-version.outputs.VERSION }} Pre-Release" \
"v${{ steps.get-version.outputs.VERSION }}-pre" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-pre-amd64.deb" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-pre-checksums.txt"
tagged-release:
if: startsWith(github.ref, 'refs/tags/v')
name: "release"
permissions: write-all
runs-on: "ubuntu-latest"
needs:
- build
- smoke-test
- cve-test
- filter-test
- private-gems-test
- auth-test
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
with:
name: gemfast-omnibus
- uses: actions/download-artifact@v3
with:
name: gemfast-docker
- name: Get version
id: get-version
run: |
v=$(cat VERSION)
echo "version=${v}" >> "$GITHUB_OUTPUT"
- name: Rename omnibus artifact
run: |
mv *.deb "gemfast-${{ steps.get-version.outputs.VERSION }}-amd64.deb"
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push docker image
run: |
docker load < gemfast-${{ steps.get-version.outputs.VERSION }}-pre.tar
docker tag server:latest ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}
docker push ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }}
docker tag ghcr.io/gemfast/server:${{ steps.get-version.outputs.VERSION }} ghcr.io/gemfast/server:latest
docker push ghcr.io/gemfast/server:latest
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create --latest --generate-notes --title "${{ steps.get-version.outputs.VERSION }}" \
"v${{ steps.get-version.outputs.VERSION }}" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-amd64.deb" \
"gemfast-${{ steps.get-version.outputs.VERSION }}-checksums.txt"
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
title: "${{ steps.get-version.outputs.VERSION }}"
files: |
*.deb
*.txt
cleanup:
runs-on: ubuntu-latest
needs:
- build
- smoke-test
- cve-test
- filter-test
- private-gems-test
- auth-test
- pre-release
- tagged-release
if: ${{ always() && !cancelled() && needs.build.result == 'success' }}
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: gemfast-${{ matrix.pkg }}