forked from nikiforov-soft/ble-to-mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (69 loc) · 2.83 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
name: Release
on:
workflow_dispatch:
release:
branches: [ master ]
types: [ published ]
env:
CARGO_TERM_COLOR: always
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
jobs:
release:
runs-on: ubuntu-latest
strategy:
matrix:
target: [ x86_64-unknown-linux-gnu, x86_64-pc-windows-gnu, x86_64-apple-darwin, aarch64-apple-darwin ]
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: "Setup Rust"
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'x86_64-pc-windows-gnu' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.80.0
target: ${{ matrix.target }}
- name: "Install dependencies (Linux)"
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
run: sudo apt update && sudo apt install -y libdbus-1-dev pkg-config
- name: "Install dependencies (Windows)"
if: ${{ matrix.target == 'x86_64-pc-windows-gnu' }}
run: sudo apt update && sudo apt install -y pkg-config gcc-mingw-w64-x86-64
- name: "Build target (Linux and Windows)"
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' || matrix.target == 'x86_64-pc-windows-gnu' }}
run: cargo build --release --target ${{ matrix.target }}
- name: "Build target (macOS amd64)"
if: ${{ matrix.target == 'x86_64-apple-darwin' }}
run: |
docker run --rm \
-v ${{ github.workspace }}:/src \
-w /src \
-e CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \
-e CC=o64-clang \
-e CXX=o64-clang++ \
-e LIBZ_SYS_STATIC=1 \
joseluisq/rust-linux-darwin-builder:1.79.0 \
sh -c "cargo build --release --target x86_64-apple-darwin"
- name: "Build target (macOS arm64)"
if: ${{ matrix.target == 'aarch64-apple-darwin' }}
run: |
docker run --rm \
-v $PWD:/src \
-w /src \
-e CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \
-e CC=oa64-clang \
-e CXX=oa64-clang++ \
-e LIBZ_SYS_STATIC=1 \
joseluisq/rust-linux-darwin-builder:1.79.0 \
sh -c "cargo build --release --target aarch64-apple-darwin"
- name: "Package"
shell: bash
run: |
cd ${{ github.workspace }}/target/${{ matrix.target }}/release
tar czf ${{ github.workspace }}/${{ github.event.repository.name }}-${{ matrix.target }}.tar.gz $([ -f "${{ github.event.repository.name }}.exe" ] && echo "${{ github.event.repository.name }}.exe" || echo "${{ github.event.repository.name }}")
cd -
- name: "Publish"
uses: softprops/action-gh-release@v2
with:
files: '${{ github.event.repository.name }}-*'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}