-
Notifications
You must be signed in to change notification settings - Fork 15
95 lines (93 loc) · 3.1 KB
/
release.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
on:
push:
tags: ['*']
name: Release
jobs:
test:
name: Test
runs-on: ubuntu-22.04
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-gnu-gcc
steps:
- uses: actions/checkout@v3
- run: sudo apt-get update
- run: sudo apt-get install -y musl-tools busybox-static
- run: sudo apt-get install -y gcc-aarch64-linux-gnu
if: matrix.target == 'aarch64-unknown-linux-musl'
- run: rustup target add ${{ matrix.target }}
- uses: actions/cache@v3
with:
path: |
target/
~/.cargo/git/db/
~/.cargo/registry/cache/
~/.cargo/registry/index/
key: "${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}"
- run: cargo build --release --all-features --target=${{ matrix.target }} --locked
- uses: actions/upload-artifact@v3
with:
name: musl-executable-${{ matrix.target }}
path: ./target/${{ matrix.target }}/release/magicpak
- run: cargo test --release --all-features --target=${{ matrix.target }}
if: matrix.target == 'x86_64-unknown-linux-musl' # TODO: test aarch64
build_docker_images:
name: Build and push docker images
runs-on: ubuntu-22.04
needs: test
steps:
- name: Free up disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: musl-executable-x86_64-unknown-linux-musl
- run: mkdir -p dist/amd64 && mv ./magicpak ./dist/amd64/magicpak
- uses: actions/download-artifact@v3
with:
name: musl-executable-aarch64-unknown-linux-musl
- run: mkdir -p dist/arm64 && mv ./magicpak ./dist/arm64/magicpak
- uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- uses: docker/setup-buildx-action@v2
- run: docker buildx bake --push --set '*.cache-from=type=gha' --set '*.cache-to=type=gha,mode=max'
env:
BIN_DIR: "./dist"
VERSION: "1.4.0"
release:
name: Release
runs-on: ubuntu-22.04
needs: build_docker_images
strategy:
matrix:
target:
- x86_64-unknown-linux-musl
- aarch64-unknown-linux-musl
steps:
- uses: actions/download-artifact@v3
with:
name: musl-executable-${{ matrix.target }}
- run: mv magicpak magicpak-${{ matrix.target }}
- uses: softprops/action-gh-release@v1
with:
files: magicpak-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
upload:
name: Upload to crates.io
runs-on: ubuntu-22.04
needs: release
steps:
- uses: actions/checkout@v3
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}