-
Notifications
You must be signed in to change notification settings - Fork 36
74 lines (62 loc) · 2.02 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
name: Build release binaries
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
env:
PROJECT_NAME: mtk_uartboot
RUSTFLAGS: -C target-feature=+crt-static
jobs:
build-and-upload:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- name: linux-amd64
runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
- name: win-amd64
runner: windows-latest
target: x86_64-pc-windows-msvc
- name: macos-amd64
runner: macos-latest
target: x86_64-apple-darwin
- name: macos-arm64
runner: macos-latest
target: aarch64-apple-darwin
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: "${{ matrix.target }}"
- name: Setup Cache
uses: Swatinem/rust-cache@v2
- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Build Binary
run: cargo build --verbose --locked --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
dirname="${PROJECT_NAME}-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.runner }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/${PROJECT_NAME}.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/${PROJECT_NAME}" "$dirname"
fi
if [ "${{ matrix.runner }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload the binaries
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.ASSET }}