-
Notifications
You must be signed in to change notification settings - Fork 114
78 lines (65 loc) · 2.29 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
name: build
on:
push:
branches:
- main
tags:
- '**'
pull_request:
types: [opened, synchronize, reopened]
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full
jobs:
crate_metadata:
name: Extract crate metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Extract crate information
id: crate_metadata
run: |
cargo metadata --no-deps --format-version 1 | jq -r '"name=" + .packages[0].name' | tee -a $GITHUB_OUTPUT
cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT
outputs:
name: ${{ steps.crate_metadata.outputs.name }}
version: ${{ steps.crate_metadata.outputs.version }}
build:
needs: [crate_metadata]
strategy:
fail-fast: false
max-parallel: 3
matrix:
job:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu, short_target: linux-amd64 }
- { os: macos-latest, target: universal2-apple-darwin, short_target: macos-universal }
- { os: windows-latest, target: x86_64-pc-windows-msvc, short_target: windows-amd64 }
runs-on: ${{ matrix.job.os }}
steps:
- name: Install build dependencies (Linux)
if: matrix.job.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libudev-dev
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Build
run: make build-release
- name: Run tests
run: make test
- name: Run executable
run: ./target/release/display_switch --version
- name: Package
id: package
run: |
PACKAGE_DIR="target/package"
mkdir -p "$PACKAGE_DIR"
PACKAGE_NAME="display_switch-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.short_target }}.zip"
PACKAGE_FILE="$PACKAGE_DIR/PACKAGE_NAME"
zip -j $PACKAGE_FILE target/release/display_switch* README.md LICENSE
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_OUTPUT
echo "PACKAGE_FILE=$PACKAGE_FILE" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4
with:
name: ${{ steps.package.outputs.PACKAGE_NAME }}
path: ${{ steps.package.outputs.PACKAGE_FILE }}