-
Notifications
You must be signed in to change notification settings - Fork 5
131 lines (130 loc) · 5.19 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# This file is part of simple-crosshair-overlay and is licenced under the GNU GPL v3.0.
# See LICENSE file for full text.
# Copyright © 2023 Michael Ripley
name: Build
on:
push:
paths-ignore: # ignore files that can't alter build output
- '**.md'
- .github/dependabot.yml
- .github/workflows/ci.yml
- .github/workflows/publish.yml
- .gitignore
- docs/**
- LICENSE
- screenshots/**
jobs:
cargo-deny:
# only run for pushes to tags or non-dependabot branches
if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/dependabot/'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
cargo-fmt:
# only run for pushes to tags or non-dependabot branches
if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/dependabot/'))
runs-on: ubuntu-latest
steps:
- name: Install Cargo
run: rustup component add cargo
- name: Install Clippy
run: rustup component add rustfmt
- uses: actions/checkout@v4
- name: Format
run: cargo fmt --check
build:
# only run for pushes to tags or non-dependabot branches
if: startsWith(github.ref, 'refs/tags/') || (startsWith(github.ref, 'refs/heads/') && !startsWith(github.ref, 'refs/heads/dependabot/'))
strategy:
matrix:
target:
- runs-on: windows-latest
triple: x86_64-pc-windows-msvc
build-name: Windows
artifact-suffix: ''
suffix: .exe
path-separator: '\'
runner-can-execute: true
# - runs-on: ubuntu-latest
# triple: x86_64-unknown-linux-gnu
# build-name: Linux
# artifact-suffix: -linux
# suffix: ''
# path-separator: '/'
# runner-can-execute: true
- runs-on: macos-latest
triple: x86_64-apple-darwin
build-name: macOS x86
artifact-suffix: -mac-x86
suffix: ''
path-separator: '/'
runner-can-execute: true
- runs-on: macos-latest
triple: aarch64-apple-darwin
build-name: macOS ARM
artifact-suffix: -mac-arm
suffix: ''
path-separator: '/'
runner-can-execute: false
fail-fast: false
name: Build ${{ matrix.target.build-name }}
runs-on: ${{ matrix.target.runs-on }}
steps:
- name: git checkout
uses: actions/checkout@v4
- name: Setup workflow cache
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target.triple }}
- name: Setup Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: rust-src
target: ${{ matrix.target.triple }}
- name: Install extra Linux dependencies
if: matrix.target.runs-on == 'ubuntu-latest'
run: | # gdk-sys needs {libgtk-3-dev}.
sudo apt-get update
sudo apt-get install -y libgtk-3-dev
- name: Check
run: cargo check --target ${{ matrix.target.triple }}
- name: Test
if: matrix.target.runner-can-execute
run: cargo test --target ${{ matrix.target.triple }}
- name: Build
run: cargo +nightly build -Z build-std=std --release --target ${{ matrix.target.triple }}
- name: Upload workflow artifact
uses: actions/upload-artifact@v4
with:
name: simple-crosshair-overlay-${{ matrix.target.triple }}
path: ./target/${{ matrix.target.triple }}/release/simple-crosshair-overlay${{ matrix.target.suffix }}
if-no-files-found: error
- name: Rename artifact for release # action-gh-release is incapable of renaming files, so I have to do it manually
if: startsWith(github.ref, 'refs/tags/') # only run for pushes to tags
run: |
cp "./target/${{ matrix.target.triple }}/release/simple-crosshair-overlay${{ matrix.target.suffix }}" "${{ runner.temp }}/simple-crosshair-overlay${{ matrix.target.artifact-suffix }}${{ matrix.target.suffix }}"
ls "${{ runner.temp }}"
file "${{ runner.temp }}${{ matrix.target.path-separator }}simple-crosshair-overlay${{ matrix.target.artifact-suffix }}${{ matrix.target.suffix }}"
shell: bash
- name: Upload release artifact
uses: softprops/[email protected]
if: startsWith(github.ref, 'refs/tags/') # only run for pushes to tags
with:
draft: true
files: ${{ runner.temp }}${{ matrix.target.path-separator }}simple-crosshair-overlay${{ matrix.target.artifact-suffix }}${{ matrix.target.suffix }}
fail_on_unmatched_files: true