-
Notifications
You must be signed in to change notification settings - Fork 9
77 lines (68 loc) · 2.2 KB
/
build.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
name: Build and Upload Release Binaries
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag to build for'
required: true
pull_request:
branches:
- '**' # TODO: remove
jobs:
build-and-upload:
name: ${{ matrix.os }} build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
suffix: linux-aarch64
- os: macos-latest
target: x86_64-apple-darwin
suffix: macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
suffix: macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: windows-x86_64.exe
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Get binary name from Cargo.toml
shell: bash
run: |
BINARY_NAME=$(grep -m1 '^name' Cargo.toml | cut -d'"' -f2 | cut -d"'" -f2)
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
- name: Rename binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
if [[ "${{ runner.os }}" == "Windows" ]]; then
mv "${{ env.BINARY_NAME }}.exe" "${{ env.BINARY_NAME }}-${{ matrix.suffix }}"
else
mv "${{ env.BINARY_NAME }}" "${{ env.BINARY_NAME }}-${{ matrix.suffix }}"
fi
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
files: target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}-${{ matrix.suffix }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}