-
Notifications
You must be signed in to change notification settings - Fork 47
269 lines (238 loc) · 8.62 KB
/
master.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
name: CI
on:
push:
branches: [ master ]
tags:
- v[0-9]+.[0-9]+.[0-9]+
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
unittests-python:
name: Python unit tests
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v2
# Build package
- name: Run Python unit tests
run: make run-tests-python
unittests-angular:
name: Angular unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Build package
- name: Run Angular unit tests
run: make run-tests-angular
build-deb:
name: Build Deb
runs-on: ubuntu-latest
needs: [ unittests-python, unittests-angular ]
steps:
- name: Checkout
uses: actions/checkout@v2
# Sets up build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: |
image=moby/buildkit:master
network=host
- name: Show buildx builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Show buildx available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
# Build package
- name: Build deb package
run: make deb
# Upload package
- name: Publish artifact
uses: actions/upload-artifact@v2
with:
path: ${{ github.workspace }}/build/*.deb
name: deb-${{ github.run_number }}
# Post build steps
- name: List built packages
if: ${{ success() }}
run: ls -l $GITHUB_WORKSPACE/build/
build-docker-image:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [ unittests-python, unittests-angular ]
steps:
- name: Checkout
uses: actions/checkout@v2
# Sets up build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: |
image=moby/buildkit:master
network=host
- name: Show buildx builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Show buildx available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
# Login using a PAT with write:packages scope
- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
# Set staging registry
- name: Set staging registry env variable
run: echo "staging_registry=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
# Build docker image
- name: Build docker image
run: make docker-image STAGING_REGISTRY=${{ env.staging_registry }} STAGING_VERSION=${{ github.run_number }}
e2etests-deb:
name: End-to-end tests on Deb
runs-on: ubuntu-latest
needs: [ build-deb ]
strategy:
matrix:
oscode: [ ubu1604, ubu1804, ubu2004 ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download deb package artifact
uses: actions/download-artifact@v2
with:
name: deb-${{ github.run_number }}
path: build/
# Run e2e test
- name: Run e2e test
run: make run-tests-e2e SEEDSYNC_DEB=`readlink -f build/*.deb` SEEDSYNC_OS=${{ matrix.oscode }}
e2etests-docker-image:
name: End-to-end tests on Docker Image
runs-on: ubuntu-latest
needs: [ build-docker-image ]
strategy:
matrix:
arch: [ amd64, arm64, arm/v7 ]
steps:
- name: Checkout
uses: actions/checkout@v2
# Sets up build environment
- name: Enable Docker experimental features
run: |
echo $'{\n "experimental": true\n}' | sudo tee /etc/docker/daemon.json
sudo service docker restart
docker version
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: |
image=moby/buildkit:master
network=host
- name: Show buildx builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Show buildx available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
# Login using a PAT with write:packages scope
- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
# Set staging registry
- name: Set staging registry env variable
run: echo "staging_registry=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
# Run e2e test
- name: Run e2e test
run: make run-tests-e2e \
STAGING_REGISTRY=${{ env.staging_registry }} \
STAGING_VERSION=${{ github.run_number }} \
SEEDSYNC_ARCH=${{ matrix.arch }}
publish-docker-image:
name: Publish Docker Image
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [ e2etests-deb, e2etests-docker-image ]
steps:
- name: Set release env variable
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
# Sets up build environment
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
driver-opts: |
image=moby/buildkit:master
network=host
- name: Show buildx builder instance name
run: echo ${{ steps.buildx.outputs.name }}
- name: Show buildx available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
# Login to GHCR using a PAT with write:packages scope
- name: Log into GitHub Container Registry
run: echo "${{ secrets.CR_PAT }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin
# Login to Dockerhub
- name: Log into Dockerhub registry
run: echo "${{ secrets.DOCKER_PASSWORD }}" |
docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
# Set staging registry
- name: Set staging registry env variable
run: echo "staging_registry=ghcr.io/${{ github.repository }}" >> $GITHUB_ENV
# Push image to dockerhub
- name: Push to Dockerhub (tag vX.X.X)
run: make docker-image-release \
STAGING_REGISTRY=${{ env.staging_registry }} \
STAGING_VERSION=${{ github.run_number }} \
RELEASE_REGISTRY=docker.io/ipsingh06 \
RELEASE_VERSION=${{ env.RELEASE_VERSION }}
- name: Push to Dockerhub (tag latest)
run: make docker-image-release \
STAGING_REGISTRY=${{ env.staging_registry }} \
STAGING_VERSION=${{ github.run_number }} \
RELEASE_REGISTRY=docker.io/ipsingh06 \
RELEASE_VERSION=latest
publish-deb:
name: Publish Deb package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: [ e2etests-deb, e2etests-docker-image ]
steps:
- name: Set release env variable
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV
- name: Download deb package artifact
uses: actions/download-artifact@v2
with:
name: deb-${{ github.run_number }}
path: build/
- name: Set deb file path and name env variable
run: |
echo "DEB_PATH=$(readlink -f ./build/*.deb)" >> $GITHUB_ENV
echo "DEB_NAME=$(basename $(readlink -f ./build/*.deb))" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: ${{ github.event.head_commit.message }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.DEB_PATH }}
asset_name: ${{ env.DEB_NAME }}
asset_content_type: application/x-deb