forked from filipecabaco/ex_tauri
-
Notifications
You must be signed in to change notification settings - Fork 0
303 lines (259 loc) · 10 KB
/
elixir-tauri-ci.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
name: "Elixir CI"
# @link https://fly.io/docs/elixir/advanced-guides/github-actions-elixir-ci-cd/
# @link https://fly.io/phoenix-files/github-actions-for-elixir-ci/
on:
push:
branches: ["dev-ci-test"]
# pull_request:
# branches: [ "main"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
cancel-in-progress: ${{ !contains(github.ref, 'release/')}}
permissions:
contents: read
jobs:
tests:
runs-on: ubuntu-latest
name: Tests on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: ['26.2.3']
elixir: ['1.16.2']
env:
MIX_ENV: test
steps:
# Step: Setup Elixir + Erlang image as the base.
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
# Step: Check out the code.
- name: Checkout code
uses: actions/checkout@v4
# Step: Define how to cache deps. Restores existing cache if present.
- name: Mix Cache deps
id: cache-deps
uses: actions/cache@v4
env:
cache-name: cache-elixir-deps
with:
path: example/deps
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-
# Step: Define how to cache the `_build` directory. After the first run,
# this speeds up tests runs a lot. This includes not re-compiling our
# project's downloaded deps every run.
- name: Mix Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: example/_build
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lockkk') }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}--mix-
# Step: Conditionally bust the cache when job is re-run.
# Sometimes, we may have issues with incremental builds that are fixed by
# doing a full recompile. In order to not waste dev time on such trivial
# issues (while also reaping the time savings of incremental builds for
# *most* day-to-day development), force a full recompile only on builds
# that are retried.
- name: Mix Clean to rule out incremental build as a source of flakiness
if: github.run_attempt != '1'
run: |
cd example
mix deps.clean --all
mix clean
shell: sh
# Step: Download project dependencies. If unchanged, uses
# the cached version.
- name: Mix Install dependencies
run: |
cd example
mix deps.get
# Step: Compile the project treating any warnings as errors.
# Customize this step if a different behavior is desired.
- name: Mix Compiles without warnings
run: |
cd example
mix compile
# mix compile --warnings-as-errors
# Step: Check that the checked in code has already been formatted.
# This step fails if something was found unformatted.
# Customize this step as desired.
- name: Mix Check Formatting
run: |
cd example
mix format --check-formatted
# Step: Execute the tests.
- name: Run tests
run: |
cd example
mix test --trace --slowest 10
burrito-release:
runs-on: ubuntu-latest
name: Build Releases with Burrito on OTP ${{matrix.otp}} / Elixir ${{matrix.elixir}}
strategy:
matrix:
otp: ['26.2.3']
elixir: ['1.16.2']
needs:
- tests
permissions:
contents: write
env:
MIX_ENV: prod
ZIG_VERSION: 0.11.0
steps:
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}
- name: install dependencies (ubuntu only)
run: |
sudo apt update
sudo apt -y install --no-install-recommends p7zip-full curl xz-utils
curl https://ziglang.org/download/"${ZIG_VERSION}"/zig-linux-x86_64-"${ZIG_VERSION}".tar.xz -o zig.tar.xz
tar -xf zig.tar.xz
mv zig-linux-x86_64-"${ZIG_VERSION}" /opt/zig-"${ZIG_VERSION}"
export PATH=/opt/zig-"${ZIG_VERSION}":$PATH
echo $PATH
zig version
xz --version
- name: Checkout code
uses: actions/checkout@v4
# Step: Define how to cache deps. Restores existing cache if present.
- name: Mix Cache deps
id: burrito-cache-deps
uses: actions/cache@v4
env:
cache-name: burrito-cache-elixir-deps
with:
path: example/deps
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-
# Step: Define how to cache the `_build` directory. After the first run,
# this speeds up tests runs a lot. This includes not re-compiling our
# project's downloaded deps every run.
- name: Mix Cache compiled build
id: burrito-cache-build
uses: actions/cache@v3
env:
cache-name: burrito-cache-compiled-build
with:
path: example/_build
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lockkk') }}
restore-keys: |
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ env.cache-name }}-
${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}--mix-
# Step: Conditionally bust the cache when job is re-run.
# Sometimes, we may have issues with incremental builds that are fixed by
# doing a full recompile. In order to not waste dev time on such trivial
# issues (while also reaping the time savings of incremental builds for
# *most* day-to-day development), force a full recompile only on builds
# that are retried.
- name: Mix Clean to rule out incremental build as a source of flakiness
if: github.run_attempt != '1'
run: |
cd example
mix deps.clean --all
mix clean
shell: sh
- name: Mix Install dependencies
run: |
cd example
mix deps.get --only prod
- name: Mix Compile # without warnings
# run: mix compile --warnings-as-errors
run: |
cd example
mix compile
- name: Mix Check Formatting
run: |
cd example
mix format --check-formatted
- name: Burrito Releases
run: |
cd example
export PATH=/opt/zig-"${ZIG_VERSION}":$PATH
echo $PATH
zig version
xz --version
mix ex_tauri.install
mix ex_tauri build
# - name: Display artifacts to upload
# run: ls -al example/burrito_out
- name: Temporarily Save the Burrito Release
uses: actions/upload-artifact@v4
with:
name: burrito-releases
path: example/burrito_out
retention-days: 1
overwrite: true
tauri-release:
needs:
- tests
- burrito-release
permissions:
contents: write
strategy:
fail-fast: false
matrix:
settings:
# - platform: 'macos-latest' # for Arm based macs (M1 and above).
# args: '--target aarch64-apple-darwin'
# - platform: 'macos-latest' # for Intel based macs.
# args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04.
args: ''
# - platform: 'windows-latest'
# args: ''
runs-on: ${{ matrix.settings.platform }}
steps:
- uses: actions/checkout@v4
- name: install dependencies (ubuntu only)
if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above.
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf
# sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2.
# You can remove the one that doesn't apply to your app to speed up the workflow a bit.
# - name: setup node
# uses: actions/setup-node@v4
# with:
# node-version: lts/*
# cache: 'yarn' # Set this to npm, yarn or pnpm.
- name: install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
# Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds.
targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }}
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: './src-tauri -> target'
- name: Retrieve Saved Burrito Releases
uses: actions/download-artifact@v4
with:
name: burrito-releases
path: example/burrito_out
- name: Display downloaded artifacts
run: ls -al example/burrito_out
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version.
releaseName: 'App v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
args: ${{ matrix.settings.args }}