-
Notifications
You must be signed in to change notification settings - Fork 10
77 lines (76 loc) · 2.75 KB
/
cd.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: CD
on:
push:
jobs:
cd:
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
filename: bita-x86_64-unknown-linux-musl
extension: ""
cargo-flags: "--no-default-features --features rustls-tls" # Since this is the "maximum-compatible" release, link statically against rustls
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
filename: bita-x86_64-unknown-linux-gnu
extension: ""
cargo-flags: ""
- os: windows-latest
target: x86_64-pc-windows-msvc
filename: bita-x86_64-pc-windows-msvc.exe
extension: ".exe"
cargo-flags: ""
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: benjlevesque/[email protected]
id: short-sha
- name: Determine filename
shell: bash
run: |
if [[ ${{ github.ref_type }} == "branch" ]]; then
VERSION="${{ steps.short-sha.outputs.sha }}"
else
VERSION="${{ github.ref_name }}"
fi
echo "filename=bita-$VERSION-${{ matrix.target }}${{matrix.extension}}" >> $GITHUB_ENV
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
targets: ${{ matrix.target }}
- name: Enable static CRT linkage (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
mkdir .cargo
echo '[target.x86_64-pc-windows-msvc]' >> .cargo/config
echo 'rustflags = ["-Ctarget-feature=+crt-static"]' >> .cargo/config
- name: Install musl-tools (musl)
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
run: |
sudo apt-get update
sudo apt-get install -y musl-tools
- name: Build binary
env:
MACOSX_DEPLOYMENT_TARGET: 10.14 # For future OSX pipelines, this will ensure the binary is backwards-compatible with 10.14 and newer
run: |
cargo build --verbose --release --target ${{ matrix.target }} ${{ matrix.cargo-flags }}
mv target/${{ matrix.target }}/release/bita${{ matrix.extension }} ${{ env.filename }}
- name: Strip binary (Linux)
if: ${{ matrix.os != 'windows-latest' }}
run: |
strip ${{ env.filename }}
- name: Upload binary
uses: actions/[email protected]
with:
name: ${{ env.filename }}
path: ${{ env.filename }}
- name: Release binary
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: |
${{ env.filename }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}