-
Notifications
You must be signed in to change notification settings - Fork 29
executable file
·314 lines (280 loc) · 9.27 KB
/
prepare_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
303
304
305
306
307
308
309
310
311
312
313
314
name: Prepare Release
on:
workflow_dispatch:
# on:
# push:
# tags:
# - v*
jobs:
gather-build-info:
name: Gather Build Info
runs-on: ubuntu-latest
outputs:
is-prerelease: ${{ startsWith(steps.get_version.outputs.prerelease, 'rc') }}
version: ${{ steps.get_version.outputs.version }}
steps:
- id: get_version
uses: battila7/get-version-action@master
test-code:
name: ${{ matrix.test.name }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.test.experimental }}
needs:
- gather-build-info
strategy:
fail-fast: false
matrix:
test:
- name: Unit Tests (Code)
command: npm run test:code
experimental: true
artifact: ""
enabled: true
- name: Snyk (Security)
command: npm run test:security
experimental: true
enabled: true
- name: Lint (Quality)
command: npm run lint
experimental: true
enabled: true
- name: Coverage (Quality)
command: npm run test:coverage
experimental: true
enabled: false
exclude:
- test:
enabled: false
steps:
- uses: actions/checkout@v2
- name: Install Npm Dependencies
run: npm install --ignore-scripts
- name: Run Test
run: ${{ matrix.test.command }}
build:
name: ${{ matrix.build.name }}
runs-on: ubuntu-latest
needs:
- gather-build-info
strategy:
fail-fast: false
matrix:
build:
- name: Build docker image
os: ubuntu-latest
enabled: true
artifact: ixo-chain
docker:
file: .infra/dockerfiles/Dockerfile
target: dist-stable
outputs:
type: "image"
# post-build:
# enabled: false
- name: Build debian package
os: ubuntu-latest
artifact: "ixod_linux_amd64"
enabled: true
docker:
file: .infra/dockerfiles/Dockerfile
target: build-binary
outputs:
type: file
path: /dist/app/ixo-blockchain_linux_amd64.tar.gz
# post-build:
# enabled: false
- name: Build darwin binary
os: ubuntu-latest
artifact: "ixod_darwin_amd64"
enabled: true
docker:
file: .infra/dockerfiles/Dockerfile
target: build-binary
outputs:
type: file
path: /dist/app/ixo-blockchain_darwin_amd64.tar.gz
exclude:
- build:
enabled: false
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
if: matrix.build.outputs.type == 'image'
uses: docker/setup-buildx-action@v1
- name: Build Docker Image and Save
if: matrix.build.outputs.type == 'image'
uses: docker/build-push-action@v2
with:
push: false
context: .
tags: ${{ matrix.build.artifact }}:tmp
target: ${{ matrix.build.docker.target }}
file: ${{ matrix.build.docker.file }}
outputs: type=docker,dest=/tmp/${{ matrix.build.artifact }}.tar
- name: Build Docker Image
if: matrix.build.outputs.type == 'file'
uses: docker/build-push-action@v2
with:
push: false
context: .
tags: ${{ matrix.build.artifact }}:tmp
target: ${{ matrix.build.docker.target }}
file: ${{ matrix.build.docker.file }}
- name: Extract files from Docker Image
id: extracted-files
if: matrix.build.outputs.type == 'file'
uses: shrink/actions-docker-extract@v1
with:
image: ${{ matrix.build.artifact }}:tmp
path: ${{ matrix.build.outputs.path }}
- name: Upload Docker Image
if: matrix.build.outputs.type == 'image'
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.build.artifact }}
path: /tmp/${{ matrix.build.artifact }}.tar
- name: Upload File
if: matrix.build.outputs.type == 'file'
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.build.artifact }}
path: ${{ steps.extracted-files.outputs.destination }}
test-artifact:
name: ${{ matrix.test.name }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.test.experimental }}
needs:
- build
strategy:
matrix:
test:
- name: Scan Docker image (Security)
os: ubuntu-latest
artifact: ixo-chain
enabled: true
experimental: true
command: docker scan --file .infra/dockerfiles/Dockerfile ixo-chain:tmp
- name: Integration Tests (Quality)
os: ubuntu-latest
artifact: ixo-chain
enabled: false
experimental: true
exclude:
- test:
enabled: false
steps:
- uses: actions/checkout@v2
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.test.artifact }}
- name: Load image
run: docker load --input ${{ matrix.test.artifact }}.tar
- name: Run ${{matrix.test.name }}
run: ${{ matrix.test.command }}
publish-release:
name: ${{ matrix.release.name }}
runs-on: ubuntu-latest
outputs:
upload-url: ${{ steps.release.outputs.upload_url}}
needs:
- gather-build-info
- test-code
- build
- test-artifact
strategy:
fail-fast: false
matrix:
release:
- name: Publish Release
enabled: ${{ !needs.gather-build-info.outputs.is-prerelease }}
config: release-config.yaml
- name: Publish Pre-Release
enabled: ${{ needs.gather-build-info.outputs.is-prerelease }}
config: prerelease-config.yaml
exclude:
- release:
enabled: false
steps:
- name: Create Release
id: release
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config-name: ${{ matrix.release.config }}
tag: ${{ needs.gather-build-info.outputs.version }}
publish: true
commitish: ${{ github.sha }}
publish-release-artifacts:
name: ${{ matrix.artifact.name }}
runs-on: ubuntu-latest
needs:
- gather-build-info
- build
- publish-release
strategy:
matrix:
artifact:
- name: Publish Docker Image
os: ubuntu-latest
artifact: ixo-chain
enabled: true
type: docker
docker:
registry: ghcr.io
owner: ${{ github.repository_owner }}
image: ${{ github.event.repository.name }}
username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.gather-build-info.outputs.version }}
- name: Publish Linux Binary
os: ubuntu-latest
artifact: "ixod_linux_amd64"
enabled: true
type: file
file:
path: ixo-blockchain_linux_amd64.tar.gz
extention: .tar.gz
- name: Publish Darwin Binary
os: ubuntu-latest
artifact: "ixod_darwin_amd64"
enabled: true
type: file
file:
path: ixo-blockchain_darwin_amd64.tar.gz
extention: .tar.gz
exclude:
- artifact:
enabled: false
steps:
- name: Login to DockerHub
if: matrix.artifact.type == 'docker'
uses: docker/login-action@v1
with:
registry: ${{ matrix.artifact.docker.registry }}
username: ${{ matrix.artifact.docker.username }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: ${{ matrix.artifact.artifact }}
- name: Upload Release Asset
if: matrix.artifact.type == 'file'
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.publish-release.outputs.upload-url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./${{ matrix.artifact.file.path }}
asset_name: ${{ matrix.artifact.artifact }}.${{ matrix.artifact.file.extention }}
asset_content_type: application/tar+gzip
- name: Publish Docker Image
if: matrix.artifact.type == 'docker'
env:
image: ${{ matrix.artifact.docker.registry }}/${{ matrix.artifact.docker.owner }}/${{ matrix.artifact.docker.image }}:${{ matrix.artifact.docker.tag }}
run: |
docker load --input ${{ matrix.artifact.artifact }}.tar
docker tag ${{ matrix.artifact.artifact }}:tmp ${{ env.image }}
docker push ${{ env.image }}