-
Notifications
You must be signed in to change notification settings - Fork 3
183 lines (146 loc) · 5.45 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
name: Rust
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
JGENESIS_VERSION: 0.8.4
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest stable Rust toolchain
run: |
rustup update
- name: Install latest nightly Rust toolchain
run: |
rustup toolchain add nightly --component rustfmt --component rust-src
- name: Install system library dependencies
run: |
sudo apt update && sudo apt install -y libsdl2-dev
- name: Check formatting
run: |
cargo +nightly fmt --check
- name: Build
run: |
cargo build
- name: Check Clippy warnings
run: |
cargo clippy -- -D warnings
- name: Run tests
run: |
cargo test
build-web:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest stable Rust toolchain
run: |
rustup update
- name: Install latest nightly Rust toolchain
run: |
rustup toolchain add nightly --component rust-src --component clippy
- name: Install wasm-pack
run: |
cargo install wasm-pack
- name: Build web
run: |
cd frontend/jgenesis-web && ./build.sh --dev
- name: Check Clippy warnings for web
run: |
cd frontend/jgenesis-web && cargo +nightly clippy --target wasm32-unknown-unknown
linux-release-appimage:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install latest stable Rust toolchain
run: |
rustup update
- name: Install system library dependencies
run: |
sudo apt-get update && sudo apt-get install -y libsdl2-dev
- name: Get latest cargo-packager version
id: get-packager-version
run: |
cargo search cargo-packager | head -1 | cut -d' ' -f3 | sed -re 's/"(.*)"/version=\1/g' >> $GITHUB_OUTPUT
- name: Cache cargo-packager binary
id: packager-cache
uses: actions/cache@v4
with:
path: ~/.cargo/bin/cargo-packager
key: ${{ runner.os }}-${{ steps.get-packager-version.outputs.version }}
- name: Install cargo-packager
if: steps.packager-cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-packager --version ${{ steps.get-packager-version.outputs.version }}
- name: Build AppImage packages
run: |
RUST_LOG=debug cargo packager --profile release-lto -f appimage
- name: Upload CLI AppImage
uses: actions/upload-artifact@v4
with:
name: linux-x86_64-cli-appimage
path: target/release-lto/jgenesis-cli_${{ env.JGENESIS_VERSION }}_x86_64.AppImage
- name: Upload GUI AppImage
uses: actions/upload-artifact@v4
with:
name: linux-x86_64-gui-appimage
path: target/release-lto/jgenesis-gui_${{ env.JGENESIS_VERSION }}_x86_64.AppImage
windows-release:
runs-on: ubuntu-latest
env:
SDL_VERSION: 2.30.9
DXC_RELEASE_TAG: v1.7.2308
DXC_ZIP_FILE: dxc_2023_08_14.zip
steps:
- uses: actions/checkout@v4
- name: Install latest stable Rust toolchain
run: |
rustup update
- name: Install mingw32
run: |
sudo apt-get update && sudo apt-get install -y mingw-w64
- name: Install Windows x64 Rust build target
run: |
rustup target add x86_64-pc-windows-gnu
- name: Download & extract Windows SDL2 libraries
run: |
wget https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-devel-$SDL_VERSION-mingw.tar.gz && \
wget https://github.com/libsdl-org/SDL/releases/download/release-$SDL_VERSION/SDL2-$SDL_VERSION-win32-x64.zip && \
tar -xzvf SDL2-devel-$SDL_VERSION-mingw.tar.gz && \
unzip SDL2-$SDL_VERSION-win32-x64.zip
- name: Download & extract DirectX shader compiler
run: |
mkdir dxcompiler && \
cd dxcompiler && \
wget https://github.com/microsoft/DirectXShaderCompiler/releases/download/$DXC_RELEASE_TAG/$DXC_ZIP_FILE && \
unzip $DXC_ZIP_FILE
- name: Build CLI release
run: |
RUSTFLAGS=" \
-C target-cpu=x86-64-v2 \
-C link-arg=-ISDL2-$SDL_VERSION/x86_64-w64-mingw32/include \
-C link-arg=-LSDL2-$SDL_VERSION/x86_64-w64-mingw32/lib" \
cargo build --profile release-lto --target x86_64-pc-windows-gnu -p jgenesis-cli
- name: Build GUI release
run: |
RUSTFLAGS=" \
-C target-cpu=x86-64-v2 \
-C link-arg=-ISDL2-$SDL_VERSION/x86_64-w64-mingw32/include \
-C link-arg=-LSDL2-$SDL_VERSION/x86_64-w64-mingw32/lib" \
cargo build --profile release-lto --target x86_64-pc-windows-gnu -p jgenesis-gui
- name: Compress binaries
run: |
mv LICENSE LICENSE-jgenesis.txt && \
mv target/x86_64-pc-windows-gnu/release-lto/*.exe ./ && \
mv dxcompiler/bin/x64/*.dll ./ && \
mv dxcompiler/LICENSE* ./ && \
zip -r jgenesis-${JGENESIS_VERSION}-windows-x86_64.zip LICENSE* README-SDL.txt *.dll jgenesis-cli.exe jgenesis-gui.exe
- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: windows-x86_64-exe
path: jgenesis-${{ env.JGENESIS_VERSION }}-windows-x86_64.zip