-
Notifications
You must be signed in to change notification settings - Fork 51
285 lines (249 loc) · 9.35 KB
/
main.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
# Build and publish packages, docker images and documentation
name: main
on:
push:
tags: ['v*.*.*']
branches: ['develop']
# to run this workflow manually from the Actions tab
# the init job fails if branch is different from 'releases/*.*.*' or 'develop'
# TODO: Add inputs to select a part of the workflow to run (e.g. build docs only)
workflow_dispatch:
# allow one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
jobs:
init:
runs-on: ubuntu-latest
outputs:
savant-version: ${{ steps.get-savant-version.outputs.savant-version }}
savant-rs-version: ${{ steps.get-savant-version.outputs.savant-rs-version }}
deepstream-version: ${{ steps.get-savant-version.outputs.deepstream-version }}
savant-deepstream-tag: ${{ steps.get-docker-vars.outputs.deepstream-tag }}
savant-adapters-tag: ${{ steps.get-docker-vars.outputs.adapters-tag }}
docs-docker-image: ${{ steps.get-docker-vars.outputs.docs-docker-image }}
steps:
- uses: actions/checkout@v4
- id: get-savant-version
uses: ./.github/actions/get-savant-version
- id: get-docker-vars
run: |
DEEPSTREAM_TAG=latest
ADAPTERS_TAG=latest
if [ "${{ github.ref_name }}" != "develop" ]; then
TAG=${{ github.ref_name }}
if [ "${{ github.ref_type }}" == "branch" ]; then
if [[ "$TAG" != releases/* ]]; then
echo "::error::Wrong branch"
exit 1
fi
TAG="v${TAG/releases\//}"
fi
echo "detected tag $TAG"
if [ "$TAG" != "v${{ steps.get-savant-version.outputs.savant-version }}" ]; then
echo "::error::Tag and Savant version mismatch"
exit 1
fi
DEEPSTREAM_TAG=${{ steps.get-savant-version.outputs.savant-version }}-${{ steps.get-savant-version.outputs.deepstream-version }}
ADAPTERS_TAG=${{ steps.get-savant-version.outputs.savant-version }}
fi
echo "deepstream-tag=$DEEPSTREAM_TAG" >> $GITHUB_OUTPUT
echo "adapters-tag=$ADAPTERS_TAG" >> $GITHUB_OUTPUT
echo "docs-docker-image=${{ env.REGISTRY }}/${{ github.repository_owner }}/savant-deepstream:$DEEPSTREAM_TAG" >> $GITHUB_OUTPUT
shell: bash
# build deepstream dockers
build-savant-deepstream:
needs: init
runs-on: self-hosted
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- docker_file: docker/Dockerfile.deepstream
docker_image_suffix: deepstream
arch: linux/amd64
- docker_file: docker/Dockerfile.deepstream
docker_image_suffix: deepstream-l4t
arch: linux/arm64
steps:
- uses: actions/checkout@v4
# setup-docker action ---
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
# --- setup-docker action
# base image
- name: Build and push savant-deepstream docker image
uses: docker/build-push-action@v5
with:
file: ${{ matrix.docker_file }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/savant-${{ matrix.docker_image_suffix }}:${{ needs.init.outputs.savant-deepstream-tag }}
build-args: |
SAVANT_VERSION=${{ needs.init.outputs.savant-version }}
SAVANT_RS_VERSION=${{ needs.init.outputs.savant-rs-version }}
DEEPSTREAM_VERSION=${{ needs.init.outputs.deepstream-version }}
platforms: ${{ matrix.arch }}
target: base
push: true
# adapters image
- name: Build and push savant-adapters-deepstream docker image
uses: docker/build-push-action@v5
with:
file: ${{ matrix.docker_file }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/savant-adapters-${{ matrix.docker_image_suffix }}:${{ needs.init.outputs.savant-deepstream-tag }}
build-args: |
SAVANT_VERSION=${{ needs.init.outputs.savant-version }}
SAVANT_RS_VERSION=${{ needs.init.outputs.savant-rs-version }}
DEEPSTREAM_VERSION=${{ needs.init.outputs.deepstream-version }}
platforms: ${{ matrix.arch }}
target: adapters
push: true
# extra image
- name: Build and push savant-deepstream-extra docker image
uses: docker/build-push-action@v5
with:
file: ${{ matrix.docker_file }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/savant-${{ matrix.docker_image_suffix }}-extra:${{ needs.init.outputs.savant-deepstream-tag }}
build-args: |
SAVANT_VERSION=${{ needs.init.outputs.savant-version }}
SAVANT_RS_VERSION=${{ needs.init.outputs.savant-rs-version }}
DEEPSTREAM_VERSION=${{ needs.init.outputs.deepstream-version }}
platforms: ${{ matrix.arch }}
target: ${{ matrix.docker_image_suffix }}-extra
push: true
# build adapter's dockers (except deepstream adapters)
build-savant-adapters:
needs: init
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- docker_file: docker/Dockerfile.adapters-gstreamer
docker_image: savant-adapters-gstreamer
arch: linux/amd64
- docker_file: docker/Dockerfile.adapters-gstreamer
docker_image: savant-adapters-gstreamer-l4t
arch: linux/arm64
- docker_file: docker/Dockerfile.adapters-py
docker_image: savant-adapters-py
arch: linux/amd64
- docker_file: docker/Dockerfile.adapters-py
docker_image: savant-adapters-py-l4t
arch: linux/arm64
steps:
- uses: actions/checkout@v4
# setup-docker action ---
- name: Log in to the container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
# --- setup-docker action
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
file: ${{ matrix.docker_file }}
tags: |
${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.docker_image }}:${{ needs.init.outputs.savant-adapters-tag }}
build-args: |
SAVANT_VERSION=${{ needs.init.outputs.savant-version }}
SAVANT_RS_VERSION=${{ needs.init.outputs.savant-rs-version }}
DEEPSTREAM_VERSION=${{ needs.init.outputs.deepstream-version }}
platforms: ${{ matrix.arch }}
push: true
# build documentation
build-docs:
needs: [init, build-savant-deepstream]
runs-on: ubuntu-latest
container:
image: ${{ needs.init.outputs.docs-docker-image }}
permissions:
contents: write
env:
MODE: ${{ github.ref_name == 'develop' && 'develop' || 'release' }}
steps:
- name: Install git-lfs
run: |
apt update && apt install --no-install-recommends -y git-lfs
- uses: actions/checkout@v4
with:
lfs: true
- name: Install dependencies
run: |
apt update && apt install --no-install-recommends -y graphviz
python -m pip install --upgrade pip
python -m pip install -r docs/requirements.txt
- name: Build documentation
run: |
cd docs
make clean html
# release ---
- name: Archive documentation
if: github.ref_name != 'develop'
run: |
tar \
--dereference --hard-dereference \
--directory docs/build/html \
-cvf docs.tar \
.
- name: Attach to release
if: github.ref_name != 'develop'
uses: softprops/action-gh-release@v1
with:
files: docs.tar
# --- release
# develop ---
- name: Compose docs
if: github.ref_name == 'develop'
run: |
./docs/source/gh_script.py ${{ github.repository }} ${{ github.token }} docs/root
mv docs/build/html docs/root/develop
mv docs/root/versions.js docs/root/develop/_static/js/versions.js
- name: Upload pages artifact
if: github.ref_name == 'develop'
uses: actions/upload-pages-artifact@v2
with:
path: docs/root
# --- develop
# develop ---
deploy-docs:
if: github.ref_name == 'develop'
runs-on: ubuntu-latest
needs: build-docs
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
# --- develop