-
Notifications
You must be signed in to change notification settings - Fork 44
329 lines (317 loc) · 12.6 KB
/
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: Maybe release
on:
push:
branches:
- main
jobs:
docker:
strategy:
fail-fast: false
matrix:
flavour: ["classic", "community"] # , "cooperation"]
platforms: ["linux/amd64"] #, "linux/arm/v7,linux/arm64,linux/amd64"] # , "linux/arm64"
include:
- platforms: "linux/amd64"
tag_extra: "-amd64"
name: ${{ matrix.flavour }} - Docker on ${{ matrix.platforms }}
runs-on: ubuntu-latest
permissions: write-all
env:
FLAVOUR: ${{ matrix.flavour }}
DOCKER_REPO: bonfire
ALPINE_VERSION: "3.20.3"
ERLANG_VERSION: "27.1.2"
ELIXIR_VERSION: "1.17.3"
# TODO: read these ^ from .tool-versions.env
WITH_IMAGE_VIX: 0
ENABLE_AI: 0
WITH_LV_NATIVE: 0
# ^ TEMP workaround for evision_nif crash on app start
steps:
-
name: Cancel any already running releases workflows
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
-
name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 2 # needed for action-detect-and-tag-new-version
-
name: Detect version
id: version
uses: salsify/action-detect-and-tag-new-version@v2
with:
create-tag: false # can't do here because it runs multiple times with the matrix (doing in docs.yaml instead)
version-command: |
grep -m 1 'version:' mix.exs | cut -d '"' -f2
-
if: steps.version.outputs.current-version == steps.version.outputs.previous-version
name: Cancel workflow if the version has not changed
uses: andymckay/[email protected]
# -
# name: Get branch names
# id: branch-name
# uses: tj-actions/branch-names@v4
# - name: Set up env
# run: cp .tool-versions.env .env
# - id: dotenv
# uses: falti/[email protected]
# with:
# export-variables: true
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Install tools
run: sudo apt-get update -y && sudo apt-get install -y cargo && cargo install just && echo "/github/home/.cargo/bin" >> $GITHUB_PATH
-
name: Pre-build prep
run: just _rel-prepare
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
env:
FLAVOUR_PATH: data/current_flavour
with:
context: .
file: Dockerfile.release
platforms: ${{ matrix.platforms }}
push: true
tags: |
bonfirenetworks/${{ env.DOCKER_REPO }}:latest-${{ env.FLAVOUR }}${{ matrix.tag_extra }}
bonfirenetworks/${{ env.DOCKER_REPO }}:${{steps.version.outputs.current-version}}-${{ env.FLAVOUR }}${{ matrix.tag_extra }}
# ghcr.io/bonfire-networks/bonfire-app:latest-${{ env.FLAVOUR }}${{ matrix.tag_extra }}
# ghcr.io/bonfire-networks/bonfire-app:${{steps.version.outputs.current-version}}-${{ env.FLAVOUR }}${{ matrix.tag_extra }}
build-args: |
"ENABLE_AI=${{ env.ENABLE_AI }}"
"WITH_LV_NATIVE=${{ env.WITH_LV_NATIVE }}"
"WITH_IMAGE_VIX=${{ env.WITH_IMAGE_VIX }}"
"ALPINE_VERSION=${{ env.ALPINE_VERSION }}"
"ELIXIR_DOCKER_IMAGE=${{env.ELIXIR_VERSION}}-erlang-${{env.ERLANG_VERSION}}-alpine-${{env.ALPINE_VERSION}}"
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
elixir_release_amd64:
name: ${{ matrix.flavour }} - OTP on amd64 bullseye # i.e. what's required by Yunohost
strategy:
matrix:
flavour: ["classic"] # , "cooperation"]
runs-on: ubuntu-latest
container: debian:bullseye
# container: debian:bullseye-slim
env:
FLAVOUR: ${{ matrix.flavour }}
WITH_DOCKER: no
MIX_ENV: prod
TERM: linux
ENABLE_AI: 0
WITH_LV_NATIVE: 0
steps:
-
name: Cancel any already running releases workflows
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Install git # needed for checkout with fetch-depth
run: apt-get update -q -y && apt-get install -q -y git
- uses: actions/checkout@v2
with:
fetch-depth: 2 # needed for action-detect-and-tag-new-version
- name: Trust my repo
run: export GIT_CEILING_DIRECTORIES=/__w && git config --global --add safe.directory $(realpath .) # see https://github.com/actions/checkout/issues/760
-
name: Maybe tag/release new version
id: version
uses: salsify/action-detect-and-tag-new-version@v2
with:
create-tag: true # NOTE: can only create tag here if it's a matrix of 1
version-command: grep -m 1 'version:' mix.exs | cut -d '"' -f2
# -
# if: steps.version.outputs.current-version == steps.version.outputs.previous-version
# name: Cancel workflow if the version has not changed
# uses: andymckay/[email protected]
-
name: Add path
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH
-
name: Install system deps & tools
run: |
chmod +x deps-debian-build.sh && ./deps-debian-build.sh
echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH
-
name: Check tools
run: |
echo $PATH
whoami
which erl
elixir -v
just --version
yarn -v
-
name: Install Bonfire deps
run: |
mix local.hex --force
mix local.rebar --force
just rel-config
just mix "deps.get --only prod"
-
name: Build app
uses: gacts/run-and-post-run@v1
with:
# TODO: figure out why Surface compiler is failing to create assets and remove the workaround (of using the ones already in the repo)
run: |
ls -la data/current_flavour/config/flavour_assets/
ls -la data/current_flavour/config/flavour_assets/hooks/
cp -r data/current_flavour/config/flavour_assets data/current_flavour/config/flavour_assets_bak
just _rel-compile-OTP remote
rm -rf data/current_flavour/config/flavour_assets
mv data/current_flavour/config/flavour_assets_bak data/current_flavour/config/flavour_assets
just _rel-compile-assets remote
just _rel-release-OTP remote
cd _build/prod/rel && tar -czvf bonfire-${{ env.FLAVOUR }}-amd64-debian-bullseye.tar.gz bonfire
post: |
ls -la data/current_flavour/config/flavour_assets/
ls -la data/current_flavour/config/flavour_assets/hooks/
- name: Release to github
uses: softprops/action-gh-release@v2
with:
files: _build/prod/rel/bonfire-*.tar.gz
name: Unstable - ${{ steps.version.outputs.tag }}
tag_name: ${{ steps.version.outputs.tag }}
# - name: Publish release
# uses: mayel/actions/bin/ghr@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# RELEASE_PATH: _build/prod/rel
# CI: 1
# elixir_release_extra_architectures:
# # The host should always be linux
# runs-on: ubuntu-latest
# name: ${{ matrix.flavour }} - OTP on ${{ matrix.arch }} ${{ matrix.distro }}
# # Run steps on a matrix of several arch/distro combinations
# strategy:
# matrix:
# flavour: ["classic"] # , "cooperation"]
# arch: ["aarch64"] # "armv7"] # NOTE: run-on-arch-action does not support amd64
# distro: ["bullseye"]
# include:
# - arch: aarch64
# family: debian
# distro: bullseye
# # base_image: hexpm/elixir:1.17.0-erlang-27.0-debian-bullseye-20240408 # use bare debian so we build with same versions as in Yunohost recipe
# # - arch: armv7
# # family: debian
# # distro: bullseye
# # # base_image: elixir:1.14-slim
# # - arch: aarch64
# # distro: alpine_latest
# # - arch: none
# # distro: none
# # base_image: debian:bullseye-slim # Error: run-on-arch: If arch and distro are not specified, base_image is required
# # family: debian
# # arch_alt: amd64
# # distro_alt: bullseye
# env:
# FLAVOUR: ${{ matrix.flavour }}
# WITH_DOCKER: no
# MIX_ENV: prod
# TERM: linux
# steps:
# -
# name: Checkout
# uses: actions/checkout@v2
# with:
# fetch-depth: 2 # needed for action-detect-and-tag-new-version
# -
# name: Detect version
# id: version
# uses: salsify/action-detect-and-tag-new-version@v2
# with:
# create-tag: false # tag already created in other job
# version-command: |
# grep -m 1 'version:' mix.exs | cut -d '"' -f2
# -
# if: steps.version.outputs.current-version == steps.version.outputs.previous-version
# name: Cancel workflow if the version has not changed
# uses: andymckay/[email protected]
# - uses: uraimo/[email protected]
# name: Build artifact
# id: build
# with:
# arch: ${{ matrix.arch }}
# distro: ${{ matrix.distro }}
# # Not required, but speeds up builds
# githubToken: ${{ github.token }}
# # Create an artifacts directory
# setup: |
# echo "Setup!..."
# mkdir -p "${PWD}/artifacts"
# # cp .tool-versions "${PWD}/artifacts/"
# # Mount the artifacts directory as /artifacts in the container
# dockerRunArgs: |
# --volume "${PWD}/artifacts:/artifacts"
# # Pass some environment variables to the container
# env: | # YAML, but pipe character is necessary
# artifact_name: bonfire-${{ env.FLAVOUR }}-${{ matrix.arch || matrix.arch_alt }}-${{ matrix.family }}-${{ matrix.distro || matrix.distro_alt }}.tar.gz
# # The shell to run commands with in the container
# shell: /bin/bash
# # Install some dependencies in the container. This speeds up builds if
# # you are also using githubToken. Any dependencies installed here will
# # be part of the container image that gets cached, so subsequent
# # builds don't have to re-install them. The image layer is cached
# # publicly in your project's package repository, so it is vital that
# # no secrets are present in the container state or logs.
# install: |
# echo "Install!..."
# export TERM=${{ env.TERM }}
# case "${{ matrix.distro }}" in
# ubuntu*|jessie|stretch|buster|bullseye)
# # chmod +x deps-debian-build.sh && ./deps-debian-build.sh
# # TODO ^ how to use the script here? (checked out files not available in install step)
# ;;
# alpine*)
# # chmod +x deps-alpine-build.sh && ./deps-alpine-build.sh
# ;;
# esac
# # Produce a binary artifact and place it in the mounted volume
# run: |
# echo "Run!..."
# case "${{ matrix.distro }}" in
# ubuntu*|jessie|stretch|buster|bullseye)
# chmod +x deps-debian-build.sh && ./deps-debian-build.sh
# # TODO ^ do in install step instead
# ;;
# alpine*)
# chmod +x deps-alpine-build.sh && ./deps-alpine-build.sh
# ;;
# esac
# # . "/opt/asdf/asdf.sh"
# just config
# just mix "deps.get --only prod"
# just rel-build
# cd _build/prod/rel && tar -czvf /artifacts/${artifact_name} bonfire
# echo "Produced artifact at /artifacts/${artifact_name}"
# - name: List the artifacts
# # Items placed in /artifacts in the container will be in
# # ${PWD}/artifacts on the host.
# run: |
# ls -al "${PWD}/artifacts"
# - name: Release to github
# uses: softprops/action-gh-release@v1
# with:
# files: "${PWD}/artifacts/*"
# name: Unstable - ${{ steps.version.outputs.tag }}
# tag_name: ${{ steps.version.outputs.tag }}