-
Notifications
You must be signed in to change notification settings - Fork 121
107 lines (91 loc) · 2.62 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Build and Release
on:
workflow_dispatch:
pull_request:
types: [opened, reopened]
push:
branches: "**"
tags:
- "v*.*.*"
jobs:
build:
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
- macos-13
runs-on: ${{ matrix.os }}
env:
MATRIX_OS: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install libudev-dev on Ubuntu
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libudev-dev
- name: Install Latest Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
default: true
override: true
- name: Install rustfmt, and clippy
run: |
rustup component add rustfmt clippy
- name: Build
id: build
shell: bash
run: |
binary_extension=""
if [[ "${RUNNER_OS}" == "Windows" ]]; then
binary_extension=".exe"
binary_path="sugar-windows-latest${binary_extension}"
elif [[ "${RUNNER_OS}" == "macOS" ]]; then
if [[ "${MATRIX_OS}" == "macos-13" ]]; then
binary_path="sugar-macos-intel-latest"
else
binary_path="sugar-macos-m1-latest"
fi
elif [[ "${RUNNER_OS}" == "Linux" ]]; then
binary_path="sugar-ubuntu-latest"
else
echo "error: unknown OS: ${RUNNER_OS}"
exit 1
fi
echo "::set-output name=binary_path::${binary_path}"
# clean build for release
if [[ "${GITHUB_REF}" = refs/tags/* ]]; then
cargo clean
fi
cargo build --all --release
cp "target/release/sugar${binary_extension}" "${binary_path}"
strip "${binary_path}"
- name: Test
uses: actions-rs/cargo@v1
with:
command: test
- name: Rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
- name: Publish Artifacts
uses: actions/upload-artifact@v3
if: "!startsWith(github.ref, 'refs/tags/')"
with:
name: ${{ matrix.os }}
path: ${{ steps.build.outputs.binary_path }}
- name: Release Tags
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ${{ steps.build.outputs.binary_path }}