Skip to content

Commit c0a28e2

Browse files
authored
Rewrite Rust CI file (#27)
Fixes macos binary release issues by compiling on a mac runner instead of trying to cross-compile the binary Introduces more checks, like docs, msrv and semver Merges together the rust.yml and release.yml workflows into one. Publishing and binary release now depend on all the other checks passing before they are run. The binary release is built using an runner of the corresponding target instead of cross-compiling. More targets are added: - x86_64-unknown-linux-gnu - aarch64-apple-darwin - x86_64-pc-windows-msvc - aarch64-pc-windows-msvc License and readme are now packaged as part as the binary release
1 parent 25cb518 commit c0a28e2

5 files changed

Lines changed: 233 additions & 63 deletions

File tree

.github/workflows/release.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/rust.yml

Lines changed: 223 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,254 @@
1-
name: Rust
1+
name: Build and upload Rust crate
22

33
on:
44
push:
55
pull_request:
66

77
env:
88
CARGO_TERM_COLOR: always
9+
RUSTFLAGS: "-D warnings"
10+
RUSTDOCFLAGS: "-D warnings"
11+
CI: "true"
912

1013
jobs:
11-
rustfmt:
12-
name: Check formatting
14+
check_fmt:
15+
name: Check format
1316
runs-on: ubuntu-latest
17+
1418
steps:
1519
- name: Checkout reposistory
1620
uses: actions/checkout@main
1721

18-
- name: Run cargo fmt
19-
run: cargo fmt --all -- --check
22+
- name: Setup Rust toolchain
23+
uses: dtolnay/rust-toolchain@stable
24+
25+
- name: Setup rustfmt
26+
run: rustup component add rustfmt
2027

21-
clippy:
28+
- name: Check format
29+
run: cargo fmt --all --check
30+
31+
check_clippy:
2232
name: Check clippy
2333
runs-on: ubuntu-latest
34+
2435
steps:
2536
- name: Checkout reposistory
2637
uses: actions/checkout@main
2738

28-
- name: Run cargo clippy
39+
- name: Setup Rust toolchain
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Setup clippy
43+
run: rustup component add clippy
44+
45+
- name: Run clippy
2946
run: |
3047
cargo clippy --version
31-
cargo clippy --all --all-targets --all-features -- -D warnings
48+
cargo clippy --all --all-targets
49+
50+
check_doc:
51+
name: Check doc
52+
runs-on: ubuntu-latest
3253

33-
macos-check:
34-
runs-on: macos-latest
3554
steps:
36-
- uses: actions/checkout@main
37-
- name: Test
55+
- name: Checkout reposistory
56+
uses: actions/checkout@main
57+
58+
- name: Setup Rust toolchain
59+
uses: dtolnay/rust-toolchain@stable
60+
61+
- name: Run doc tets
62+
run: cargo test --doc
63+
64+
- name: Run doc
65+
run: cargo doc
66+
67+
run_tests:
68+
name: Run tests (${{ matrix.runner }})
69+
runs-on: ${{ matrix.runner }}
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
include:
74+
- runner: ubuntu-latest
75+
- runner: macos-latest
76+
- runner: windows-latest
77+
78+
steps:
79+
- name: Checkout reposistory
80+
uses: actions/checkout@main
81+
82+
- name: Setup Rust toolchain
83+
uses: dtolnay/rust-toolchain@stable
84+
85+
- name: Run tests
3886
run: cargo test
3987

40-
ubuntu-check:
88+
check_msrv:
89+
name: Check MSRV
4190
runs-on: ubuntu-latest
4291
steps:
43-
- uses: actions/checkout@main
44-
- name: Test
45-
run: cargo test
92+
- name: Checkout reposistory
93+
uses: actions/checkout@main
94+
95+
- name: Setup MSRV checker
96+
uses: taiki-e/install-action@cargo-hack
4697

47-
windows-check:
48-
runs-on: windows-latest
98+
- name: Run MSRV checker
99+
run: cargo hack check --rust-version --workspace --all-targets --ignore-private
100+
101+
check_semver:
102+
name: Check semver
103+
runs-on: ubuntu-latest
49104
steps:
50-
- uses: actions/checkout@main
51-
- name: Test
52-
run: cargo test
105+
- name: Checkout reposistory
106+
uses: actions/checkout@main
107+
108+
# Locally:
109+
# ```
110+
# cargo install cargo-semver-checks --locked
111+
# cargo semver-checks
112+
# ```
113+
- name: Check semver
114+
uses: obi1kenobi/cargo-semver-checks-action@v2
115+
with:
116+
feature-group: default-features
117+
118+
publish_pigment64:
119+
name: Publish to crates.io
120+
runs-on: ubuntu-latest
121+
needs:
122+
- check_fmt
123+
- check_clippy
124+
- check_doc
125+
- run_tests
126+
- check_msrv
127+
- check_semver
128+
129+
steps:
130+
- name: Checkout reposistory
131+
uses: actions/checkout@main
132+
133+
- name: Setup Rust toolchain
134+
uses: dtolnay/rust-toolchain@stable
135+
136+
- name: Build Rust package
137+
run: cargo build --locked --release
138+
139+
- name: Publish pigment64 (dry run)
140+
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/')
141+
run: cargo publish --dry-run
142+
143+
- name: Publish pigment64 crate
144+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
145+
run: cargo publish --token ${{ secrets.CRATE_AUTH_TOKEN }}
146+
147+
github_binary_release:
148+
name: ${{ matrix.binaries.package }} (${{ matrix.builder.target }}) binary release
149+
runs-on: ${{ matrix.builder.runner }}
150+
needs:
151+
- check_fmt
152+
- check_clippy
153+
- check_doc
154+
- run_tests
155+
- check_msrv
156+
- check_semver
157+
158+
strategy:
159+
fail-fast: false
160+
matrix:
161+
builder: [
162+
{
163+
name: linux,
164+
target: x86_64-unknown-linux-musl,
165+
runner: ubuntu-22.04,
166+
cp_cmd: cp,
167+
extension: "",
168+
},
169+
{
170+
name: linux,
171+
target: x86_64-unknown-linux-gnu,
172+
runner: ubuntu-22.04,
173+
cp_cmd: cp,
174+
extension: "",
175+
},
176+
{
177+
name: mac,
178+
target: x86_64-apple-darwin,
179+
runner: macos-15-intel,
180+
cp_cmd: cp,
181+
extension: "",
182+
},
183+
{
184+
name: mac,
185+
target: aarch64-apple-darwin,
186+
runner: macos-14,
187+
cp_cmd: cp,
188+
extension: "",
189+
},
190+
{
191+
name: windows,
192+
target: x86_64-pc-windows-gnu,
193+
runner: windows-2022,
194+
cp_cmd: Copy-Item,
195+
extension: ".exe",
196+
},
197+
{
198+
name: windows,
199+
target: x86_64-pc-windows-msvc,
200+
runner: windows-2022,
201+
cp_cmd: Copy-Item,
202+
extension: ".exe",
203+
},
204+
{
205+
name: windows,
206+
target: aarch64-pc-windows-msvc,
207+
runner: windows-2022,
208+
cp_cmd: Copy-Item,
209+
extension: ".exe",
210+
},
211+
]
212+
binaries: [
213+
{
214+
package: pigment64_cli,
215+
},
216+
]
217+
218+
steps:
219+
- name: Checkout repo
220+
uses: actions/checkout@main
221+
222+
- name: Setup Rust toolchain
223+
uses: dtolnay/rust-toolchain@stable
224+
with:
225+
targets: ${{ matrix.builder.target }}
226+
227+
- name: Build ${{ matrix.binaries.package }}
228+
run: |
229+
cargo build --release --locked --target ${{ matrix.builder.target }}
230+
231+
- name: Move files for packaging
232+
run: |
233+
mkdir -p package/
234+
${{ matrix.builder.cp_cmd }} target/${{ matrix.builder.target }}/release/${{ matrix.binaries.package }}${{ matrix.builder.extension }} package/
235+
${{ matrix.builder.cp_cmd }} README.md package/${{ matrix.binaries.package }}.README.md
236+
${{ matrix.builder.cp_cmd }} LICENSE package/${{ matrix.binaries.package }}.LICENSE
237+
238+
- name: Package .tar.gz
239+
run: |
240+
cd package/ && tar -czf ../${{ matrix.binaries.package }}-${{ matrix.builder.target }}.tar.gz *
241+
242+
- name: Upload .tar.gz artifact
243+
uses: actions/upload-artifact@main
244+
with:
245+
name: ${{ matrix.binaries.package }}-${{ matrix.builder.target }}
246+
path: |
247+
${{ matrix.binaries.package }}-${{ matrix.builder.target }}.tar.gz
248+
if-no-files-found: error
249+
250+
- name: Publish .tar.gz release
251+
uses: softprops/action-gh-release@v1
252+
if: startsWith(github.ref, 'refs/tags/')
253+
with:
254+
files: ${{ matrix.binaries.package }}-${{ matrix.builder.target }}.tar.gz

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pigment64"
3-
version = "0.6.2"
3+
version = "0.6.3"
44
edition = "2024"
55
description = "A library for handling conversion between N64 texture formats and modern image formats"
66
repository = "https://github.com/decompals/pigment64"
@@ -9,6 +9,13 @@ keywords = ["nintendo64", "texture", "conversion", "n64", "image"]
99
categories = ["multimedia", "encoding", "game-development"]
1010
readme = "README.md"
1111

12+
# Use https://github.com/foresterre/cargo-msrv to check the MSRV
13+
# ```
14+
# cargo install cargo-msrv --locked --force
15+
# cargo msrv find
16+
# ```
17+
rust-version = "1.85.0"
18+
1219
[lib]
1320
name = "pigment64"
1421
path = "src/lib.rs"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[project]
22
name = "pigment64"
33
# Version should be synced with lib/Cargo.toml and lib/pigment64/__init__.py
4-
version = "0.6.2"
4+
version = "0.6.3"
55
description = "A library for handling conversion between N64 texture formats and modern image formats"
66
readme = "README.md"
77
requires-python = ">=3.9"

0 commit comments

Comments
 (0)