-
-
Notifications
You must be signed in to change notification settings - Fork 218
701 lines (662 loc) · 26.4 KB
/
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
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
paths-ignore:
- '**.md'
- 'demo/**'
- 'docs/**'
release:
types: [ published ]
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
lint-debug-test:
name: Lint and Unit test
runs-on: ubuntu-latest
env:
PGDATABASE: test
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
services:
postgres:
image: postgis/postgis:16-3.4
ports:
# will assign a random free host port
- 5432/tcp
# Sadly there is currently no way to pass arguments to the service image other than this hack
# See also https://stackoverflow.com/a/62720566/177275
options: >-
-e POSTGRES_DB=test
-e POSTGRES_USER=postgres
-e POSTGRES_PASSWORD=postgres
-e PGDATABASE=test
-e PGUSER=postgres
-e PGPASSWORD=postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--entrypoint sh
postgis/postgis:16-3.4
-c "exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key"
steps:
- uses: taiki-e/install-action@v2
with: { tool: just }
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- run: just env-info
- run: just fmt
- run: just clippy
- run: just check
- run: just check-doc
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
- name: Init database
run: tests/fixtures/initdb.sh
env:
PGPORT: ${{ job.services.postgres.ports[5432] }}
- name: Run cargo test
run: |
set -x
cargo test --package martin-tile-utils
cargo test --package mbtiles --no-default-features
cargo test --package mbtiles
cargo test --package martin
cargo test --doc
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require
docker-build-test:
name: Build and test docker images
runs-on: ubuntu-latest
env:
# PG_* variables are used by psql
PGDATABASE: test
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
# TODO: aarch64-unknown-linux-gnu
services:
postgres:
image: postgis/postgis:15-3.3
ports:
- 5432/tcp
options: >-
-e POSTGRES_DB=test
-e POSTGRES_USER=postgres
-e POSTGRES_PASSWORD=postgres
-e PGDATABASE=test
-e PGUSER=postgres
-e PGPASSWORD=postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--entrypoint sh
postgis/postgis:15-3.3
-c "exec docker-entrypoint.sh postgres -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key"
steps:
- uses: taiki-e/install-action@v2
with: { tool: cross }
- name: Checkout sources
uses: actions/checkout@v4
with:
set-safe-directory: false
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- name: Init database
run: tests/fixtures/initdb.sh
env:
PGPORT: ${{ job.services.postgres.ports[5432] }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-qemu-action
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# https://github.com/docker/setup-buildx-action
with:
install: true
platforms: linux/amd64,linux/arm64
- name: Set up AWS SAM
uses: aws-actions/setup-sam@v2
with:
use-installer: true
- name: Build targets
run: |
for target in "aarch64-unknown-linux-musl" "x86_64-unknown-linux-musl"; do
echo -e "\n----------------------------------------------"
echo "Building $target"
# See https://github.com/cross-rs/cross/issues/1526
# TODO: Remove this once a version after cross 0.2.5 is released
export CROSS_BUILD_OPTS="--output=type=docker"
export "CARGO_TARGET_$(echo $target | tr 'a-z-' 'A-Z_')_RUSTFLAGS"='-C strip=debuginfo'
cross build --release --target $target --workspace
mkdir -p target_releases/$target
mv target/$target/release/martin target_releases/$target
mv target/$target/release/martin-cp target_releases/$target
mv target/$target/release/mbtiles target_releases/$target
done
- name: Save build artifacts to build-${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: cross-build
path: target_releases/*
- name: Reorganize artifacts for docker build
run: |
mkdir -p target_releases/linux/arm64
mv target_releases/aarch64-unknown-linux-musl/* target_releases/linux/arm64/
mkdir -p target_releases/linux/amd64
mv target_releases/x86_64-unknown-linux-musl/* target_releases/linux/amd64/
- name: Start NGINX
uses: nyurik/action-setup-nginx@v1.1
id: nginx
with: { port: '5412', output-unix-paths: 'yes' }
- name: Copy static files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}
- name: Build linux/arm64 Docker image
uses: docker/build-push-action@v6
# https://github.com/docker/build-push-action
with:
context: .
file: .github/files/multi-platform.Dockerfile
load: true
tags: ${{ github.repository }}:linux-arm64
platforms: linux/arm64
- name: Test linux/arm64 Docker image
run: |
PLATFORM=linux/arm64
TAG=${{ github.repository }}:linux-arm64
export MARTIN_BUILD_ALL=-
export MARTIN_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -v $PWD/tests:/tests $TAG"
export MARTIN_CP_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -v $PWD/tests:/tests --entrypoint /usr/local/bin/martin-cp $TAG"
export MBTILES_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -v $PWD/tests:/tests --entrypoint /usr/local/bin/mbtiles $TAG"
tests/test.sh
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require
- name: Build linux/amd64 Docker image
uses: docker/build-push-action@v6
# https://github.com/docker/build-push-action
with:
context: .
file: .github/files/multi-platform.Dockerfile
load: true
tags: ${{ github.repository }}:linux-amd64
platforms: linux/amd64
- name: Test linux/amd64 Docker image
run: |
PLATFORM=linux/amd64
TAG=${{ github.repository }}:linux-amd64
export MARTIN_BUILD_ALL=-
export MARTIN_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -v $PWD/tests:/tests $TAG"
export MARTIN_CP_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -v $PWD/tests:/tests --entrypoint /usr/local/bin/martin-cp $TAG"
export MBTILES_BIN="docker run --rm --net host --platform $PLATFORM -e DATABASE_URL -v $PWD/tests:/tests --entrypoint /usr/local/bin/mbtiles $TAG"
tests/test.sh
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=require
- name: Login to GitHub Docker registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
# https://github.com/docker/login-action
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
# https://github.com/docker/metadata-action
with:
images: ghcr.io/${{ github.repository }}
- name: Push the Docker image
if: github.event_name != 'pull_request'
uses: docker/build-push-action@v6
with:
context: .
file: .github/files/multi-platform.Dockerfile
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest # M-series CPU
- target: debian-x86_64
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-13 # x64 CPU
- target: x86_64-pc-windows-msvc
os: windows-latest
ext: '.exe'
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Rust Versions
run: rustc --version && cargo --version
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- name: Install NASM for rustls/aws-lc-rs on Windows
if: runner.os == 'Windows'
uses: ilammy/setup-nasm@v1
- name: Build (.deb)
if: matrix.target == 'debian-x86_64'
run: |
set -x
sudo apt-get install -y dpkg dpkg-dev liblzma-dev
cargo install cargo-deb --locked
cargo deb -v -p martin --output target/debian/debian-x86_64.deb
mkdir -p target_releases
mv target/debian/debian-x86_64.deb target_releases/
- name: Build
if: matrix.target != 'debian-x86_64'
run: |
set -x
rustup target add "${{ matrix.target }}"
export RUSTFLAGS='-C strip=debuginfo'
cargo build --release --target ${{ matrix.target }} --package mbtiles
cargo build --release --target ${{ matrix.target }} --package martin
mkdir -p target_releases
mv target/${{ matrix.target }}/release/martin${{ matrix.ext }} target_releases/
mv target/${{ matrix.target }}/release/martin-cp${{ matrix.ext }} target_releases/
mv target/${{ matrix.target }}/release/mbtiles${{ matrix.ext }} target_releases/
- name: Save build artifacts to build-${{ matrix.target }}
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.target }}
path: target_releases/*
test-aws-lambda:
name: Test AWS Lambda
runs-on: ubuntu-latest
needs: [ docker-build-test ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download build artifact cross-build
uses: actions/download-artifact@v4
with:
name: cross-build
- run: tests/test-aws-lambda.sh
env:
MARTIN_BIN: x86_64-unknown-linux-musl/martin
test-multi-os:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [ build ]
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-apple-darwin
os: macos-13
- target: x86_64-pc-windows-msvc
os: windows-latest
ext: '.exe'
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
steps:
- name: Install and run Postgis
uses: nyurik/action-setup-postgis@v2
id: pg
with: { username: 'test', password: 'test', database: 'test' }
- name: Start NGINX
uses: nyurik/action-setup-nginx@v1.1
id: nginx
with: { port: '5412', output-unix-paths: 'yes' }
- name: Checkout sources
uses: actions/checkout@v4
- name: Init database
run: |
echo "DATABASE_URL=${{ steps.pg.outputs.connection-uri }}"
echo "Print the same in base64 to bypass Github's obfuscation (uses hardcoded password):"
echo "${{ steps.pg.outputs.connection-uri }}" | base64
tests/fixtures/initdb.sh
env:
PGSERVICE: ${{ steps.pg.outputs.service-name }}
- name: Copy static files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}
- name: Download build artifact build-${{ matrix.target }}
uses: actions/download-artifact@v4
with:
name: build-${{ matrix.target }}
path: target/
- name: Integration Tests
run: |
export MARTIN_BUILD_ALL=-
export MARTIN_BIN=target/martin${{ matrix.ext }}
export MARTIN_CP_BIN=target/martin-cp${{ matrix.ext }}
export MBTILES_BIN=target/mbtiles${{ matrix.ext }}
if [[ "${{ runner.os }}" != "Windows" ]]; then
chmod +x "$MARTIN_BIN" "$MARTIN_CP_BIN" "$MBTILES_BIN"
fi
tests/test.sh
env:
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
- name: Compare test output results (Linux)
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: diff --brief --recursive --new-file tests/output tests/expected
- name: Download Debian package (Linux)
if: matrix.target == 'x86_64-unknown-linux-gnu'
uses: actions/download-artifact@v4
with:
name: build-debian-x86_64
path: target/
- name: Tests Debian package (Linux)
if: matrix.target == 'x86_64-unknown-linux-gnu'
run: |
sudo dpkg -i target/debian-x86_64.deb
export MARTIN_BUILD_ALL=-
export MARTIN_BIN=/usr/bin/martin${{ matrix.ext }}
export MARTIN_CP_BIN=/usr/bin/martin-cp${{ matrix.ext }}
export MBTILES_BIN=/usr/bin/mbtiles${{ matrix.ext }}
tests/test.sh
env:
DATABASE_URL: ${{ steps.pg.outputs.connection-uri }}
- name: Save test output (on error)
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-test-output-${{ runner.os }}
path: |
tests/output/*
target/test_logs/*
retention-days: 5
test-with-svc:
name: Test postgis:${{ matrix.img_ver }} sslmode=${{ matrix.sslmode }}
runs-on: ubuntu-latest
needs: [ build, docker-build-test ]
strategy:
fail-fast: true
matrix:
include:
# These must match the versions of postgres used in the docker-compose.yml
- img_ver: 11-3.0-alpine
args: postgres
sslmode: disable
- img_ver: 14-3.3-alpine
args: postgres
sslmode: disable
# alpine images don't support SSL, so for this we use the debian images
- img_ver: 15-3.3
args: postgres -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
sslmode: require
#
# FIXME!
# DISABLED because Rustls fails to validate name (CN?) with the NotValidForName error
#- img_ver: 15-3.3
# args: postgres -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
# sslmode: verify-ca
#- img_ver: 15-3.3
# args: postgres -c ssl=on -c ssl_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem -c ssl_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
# sslmode: verify-full
env:
PGDATABASE: test
PGHOST: localhost
PGUSER: postgres
PGPASSWORD: postgres
services:
postgres:
image: postgis/postgis:${{ matrix.img_ver }}
ports:
- 5432/tcp
options: >-
-e POSTGRES_DB=test
-e POSTGRES_USER=postgres
-e POSTGRES_PASSWORD=postgres
-e PGDATABASE=test
-e PGUSER=postgres
-e PGPASSWORD=postgres
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--entrypoint sh
postgis/postgis:${{ matrix.img_ver }}
-c "exec docker-entrypoint.sh ${{ matrix.args }}"
steps:
- name: Checkout sources
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
- name: Run NGINX
uses: nyurik/action-setup-nginx@v1.1
id: nginx
with: { port: '5412', output-unix-paths: 'yes' }
- name: Copy static files
run: cp -r tests/fixtures/pmtiles2/* ${{ steps.nginx.outputs.html-dir }}
- name: Init database
run: tests/fixtures/initdb.sh
env:
PGPORT: ${{ job.services.postgres.ports[5432] }}
- name: Get DB SSL cert (sslmode=verify-*)
if: matrix.sslmode == 'verify-ca' || matrix.sslmode == 'verify-full'
run: |
set -x
mkdir -p target/certs
docker cp ${{ job.services.postgres.id }}:/etc/ssl/certs/ssl-cert-snakeoil.pem target/certs/server.crt
docker cp ${{ job.services.postgres.id }}:/etc/ssl/private/ssl-cert-snakeoil.key target/certs/server.key
- name: Download build artifact build-x86_64-unknown-linux-gnu
uses: actions/download-artifact@v4
with:
name: build-x86_64-unknown-linux-gnu
path: target_releases/
- name: Integration Tests
run: |
if [[ "${{ matrix.sslmode }}" == "verify-ca" || "${{ matrix.sslmode }}" == "verify-full" ]]; then
export PGSSLROOTCERT=target/certs/server.crt
fi
export MARTIN_BUILD_ALL=-
export MARTIN_BIN=target_releases/martin
export MARTIN_CP_BIN=target_releases/martin-cp
export MBTILES_BIN=target_releases/mbtiles
chmod +x "$MARTIN_BIN" "$MARTIN_CP_BIN" "$MBTILES_BIN"
tests/test.sh
rm -rf target_releases
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=${{ matrix.sslmode }}
- name: Download Debian package
uses: actions/download-artifact@v4
with:
name: build-debian-x86_64
path: target_releases/
- name: Tests Debian package
run: |
sudo dpkg -i target_releases/debian-x86_64.deb
if [[ "${{ matrix.sslmode }}" == "verify-ca" || "${{ matrix.sslmode }}" == "verify-full" ]]; then
export PGSSLROOTCERT=target/certs/server.crt
fi
export MARTIN_BUILD_ALL=-
export MARTIN_BIN=/usr/bin/martin
export MARTIN_CP_BIN=/usr/bin/martin-cp
export MBTILES_BIN=/usr/bin/mbtiles
tests/test.sh
sudo dpkg -P martin
rm -rf target_releases
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=${{ matrix.sslmode }}
- name: Unit Tests
if: matrix.sslmode != 'verify-ca' && matrix.sslmode != 'verify-full'
run: |
echo "Running unit tests, connecting to DATABASE_URL=$DATABASE_URL"
echo "Same but as base64 to prevent GitHub obfuscation (this is not a secret):"
echo "$DATABASE_URL" | base64
set -x
cargo test --package martin
cargo clean
env:
DATABASE_URL: postgres://${{ env.PGUSER }}:${{ env.PGUSER }}@${{ env.PGHOST }}:${{ job.services.postgres.ports[5432] }}/${{ env.PGDATABASE }}?sslmode=${{ matrix.sslmode }}
- name: Save test output (on error)
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-output
path: |
tests/output/*
target/test_logs/*
retention-days: 5
package:
name: Package
runs-on: ubuntu-latest
needs: [ lint-debug-test, docker-build-test, test-multi-os, test-with-svc ]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download build artifact build-aarch64-apple-darwin
uses: actions/download-artifact@v4
with:
name: build-aarch64-apple-darwin
path: target/aarch64-apple-darwin
- name: Download build artifact build-x86_64-apple-darwin
uses: actions/download-artifact@v4
with:
name: build-x86_64-apple-darwin
path: target/x86_64-apple-darwin
- name: Download build artifact build-x86_64-unknown-linux-gnu
uses: actions/download-artifact@v4
with:
name: build-x86_64-unknown-linux-gnu
path: target/x86_64-unknown-linux-gnu
- name: Download cross-build artifacts
uses: actions/download-artifact@v4
with:
name: cross-build
path: target/cross
- name: Download build artifact build-x86_64-pc-windows-msvc
uses: actions/download-artifact@v4
with:
name: build-x86_64-pc-windows-msvc
path: target/x86_64-pc-windows-msvc
- name: Download build artifact build-debian-x86_64
uses: actions/download-artifact@v4
with:
name: build-debian-x86_64
path: target/debian-x86_64
- name: Package
run: |
set -x
cd target
mkdir files
mv cross/* .
cd aarch64-apple-darwin
chmod +x martin martin-cp mbtiles
tar czvf ../files/martin-aarch64-apple-darwin.tar.gz martin martin-cp mbtiles
cd ..
cd x86_64-apple-darwin
chmod +x martin martin-cp mbtiles
tar czvf ../files/martin-x86_64-apple-darwin.tar.gz martin martin-cp mbtiles
cd ..
cd x86_64-unknown-linux-gnu
chmod +x martin martin-cp mbtiles
tar czvf ../files/martin-x86_64-unknown-linux-gnu.tar.gz martin martin-cp mbtiles
cd ..
cd aarch64-unknown-linux-musl
chmod +x martin martin-cp mbtiles
tar czvf ../files/martin-aarch64-unknown-linux-musl.tar.gz martin martin-cp mbtiles
cd ..
cd x86_64-unknown-linux-musl
chmod +x martin martin-cp mbtiles
tar czvf ../files/martin-x86_64-unknown-linux-musl.tar.gz martin martin-cp mbtiles
cd ..
#
# Special case for Windows
#
cd x86_64-pc-windows-msvc
7z a ../files/martin-x86_64-pc-windows-msvc.zip martin.exe martin-cp.exe mbtiles.exe
cd ..
#
# Special case for Debian .deb package
#
cd debian-x86_64
mv debian-x86_64.deb ../files/martin-Debian-x86_64.deb
cd ..
- name: Create Homebrew config
run: |
set -x
# Extract Github release version only without the "v" prefix
MARTIN_VERSION=$(echo "${{ github.ref }}" | sed -e 's/refs\/tags\/v//')
mkdir -p target/homebrew
cd target
cat << EOF > homebrew_config.yaml
version: "$MARTIN_VERSION"
macos_arm_sha256: "$(shasum -a 256 files/martin-aarch64-apple-darwin.tar.gz | cut -d' ' -f1)"
macos_intel_sha256: "$(shasum -a 256 files/martin-x86_64-apple-darwin.tar.gz | cut -d' ' -f1)"
linux_arm_sha256: "$(shasum -a 256 files/martin-aarch64-unknown-linux-musl.tar.gz | cut -d' ' -f1)"
linux_intel_sha256: "$(shasum -a 256 files/martin-x86_64-unknown-linux-musl.tar.gz | cut -d' ' -f1)"
EOF
- name: Save Homebrew Config
uses: actions/upload-artifact@v4
with:
name: homebrew-config
path: target/homebrew_config.yaml
- name: Publish
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
draft: true
files: 'target/files/*'
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout maplibre/homebrew-martin
if: startsWith(github.ref, 'refs/tags/')
uses: actions/checkout@v4
with:
repository: maplibre/homebrew-martin
token: ${{ secrets.GH_HOMEBREW_MARTIN_TOKEN }}
path: target/homebrew
- name: Create Homebrew formula
uses: cuchi/jinja2-action@master
with:
template: .github/files/homebrew.martin.rb.j2
output_file: target/homebrew/martin.rb
data_file: target/homebrew_config.yaml
- name: Create a PR for maplibre/homebrew-martin
if: startsWith(github.ref, 'refs/tags/')
uses: peter-evans/create-pull-request@v7
with:
# Create a personal access token
# Gen: https://github.com/settings/personal-access-tokens/new
# Set: https://github.com/maplibre/martin/settings/secrets/actions/GH_HOMEBREW_MARTIN_TOKEN
# Docs: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token
# Name: anything descriptive
# One year long (sadly that's max)
# Repository owner and repo: maplibre/homebrew-martin
# Access Contents: Read and write
# Access Metadata: Read-only
# Access Pull requests: Read and write
token: ${{ secrets.GH_HOMEBREW_MARTIN_TOKEN }}
commit-message: 'Update to ${{ github.ref }}'
title: 'Update to ${{ github.ref }}'
body: 'Update to ${{ github.ref }}'
branch: 'update-to-${{ github.ref }}'
branch-suffix: timestamp
base: 'main'
labels: 'auto-update'
assignees: 'nyurik'
draft: false
delete-branch: true
path: target/homebrew
# This final step is needed to mark the whole workflow as successful
# Don't change its name - it is used by the merge protection rules
done:
name: CI Finished
runs-on: ubuntu-latest
needs: [ package ]
steps:
- name: Finished
run: echo "CI finished successfully"