-
Notifications
You must be signed in to change notification settings - Fork 2
193 lines (169 loc) · 5.27 KB
/
rust.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: CI
on:
push:
paths-ignore:
- "docs/**"
- "**.md"
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
jobs:
# Check for formatting
rustfmt:
name: Formatter check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
components: rustfmt
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
# Run compile check on Linux, macOS, and Windows
compile:
name: Compile
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
# Checkout the branch being tested
- uses: actions/checkout@v4
# Install rust stable
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
# Cache the built dependencies
- uses: Swatinem/rust-cache@v2.7.0
with:
save-if: ${{ github.event_name == 'push' }}
# Install cargo-hack
- uses: taiki-e/install-action@cargo-hack
# Compile all feature combinations on the target platform
- name: Compile
run: cargo hack --feature-powerset check
# Build sources for every OS
desktop:
if: startsWith(github.ref, 'refs/tags/')
name: Desktop Build
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: sprite-x86_64-unknown-linux-gnu
- target: x86_64-apple-darwin
os: macOS-latest
name: sprite-x86_64-apple-darwin
- target: x86_64-pc-windows-msvc
os: windows-latest
name: sprite-x86_64-pc-windows-msvc.exe
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: ${{ matrix.target }}
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install -y libx11-dev libxi-dev libgl1-mesa-dev gcc-mingw-w64
- name: Build target
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}
- name: Prepare build artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip sprite.exe
mv sprite.exe ../../../${{ matrix.name }}
cd -
- name: Prepare build artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
strip sprite
mv sprite ../../../${{ matrix.name }}
cd -
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}
# Create GitHub release with Rust build targets and release notes
github_release:
if: startsWith(github.ref, 'refs/tags/')
name: GitHub Release
needs: desktop
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# These can be squashed when https://github.com/actions/download-artifact/issues/6 is closed
- name: Download releases from 'dekstop'
uses: actions/download-artifact@v3
with:
name: sprite-x86_64-unknown-linux-gnu
path: .
- name: Download releases from 'desktop'
uses: actions/download-artifact@v3
with:
name: sprite-x86_64-apple-darwin
path: .
- name: Download releases from 'desktop'
uses: actions/download-artifact@v3
with:
name: sprite-x86_64-pc-windows-msvc.exe
path: .
- name: Generate checksums
run: for file in sprite-*; do openssl dgst -sha256 -r "$file" | awk '{print $1}' > "${file}.sha256"; done
- name: Create GitHub release ${{ matrix.target }}
uses: softprops/action-gh-release@v1
with:
files: |
sprite-*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Build the WASM target & push it to GitHub pages
wasm:
name: WASM build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Install rust stable
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
targets: wasm32-unknown-unknown
# Cache the built dependencies
- uses: Swatinem/rust-cache@v2.7.0
with:
save-if: ${{ github.event_name == 'push' }}
# Build the WASM
- name: Build
run: cargo run --package run-wasm -- --bin sprite --no-default-features --release --build-only
# Deploy to GitHub pages
- name: Deploy to GitHub Pages
uses: s0/git-publish-subdir-action@master
env:
REPO: self
BRANCH: gh-pages
FOLDER: target/wasm-examples/sprite
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}