Skip to content

Commit f1d09e7

Browse files
Move build commands from justfile to build.yml
Use `actions-rs/cargo` to run clippy lints so that the output is shown on GitHub `build.yml` should no longer run when tags are pushed
1 parent 14e077c commit f1d09e7

File tree

3 files changed

+78
-78
lines changed

3 files changed

+78
-78
lines changed

.github/workflows/build.yml

Lines changed: 73 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ name: Build
22

33
on:
44
push:
5-
commits:
5+
# Do not run on tag pushes
6+
branches: '**'
67
paths:
78
- "**.rs"
89
- ".github/workflows/build.yml"
910
- "Cargo.lock"
10-
- "Cargo.toml"
11-
- "justfile"
1211
workflow_dispatch:
1312

1413
jobs:
@@ -21,7 +20,8 @@ jobs:
2120
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2221
steps:
2322
- uses: actions/checkout@v3
24-
- uses: extractions/setup-just@v1
23+
- name: Create `out/`
24+
run: mkdir out
2525

2626
- name: Install Rust for macOS
2727
if: matrix.os == 'macos-latest'
@@ -59,14 +59,18 @@ jobs:
5959
if: matrix.os == 'ubuntu-latest'
6060
run: |
6161
sudo apt-get update
62-
# install clang-14 on focal
62+
sudo apt-get upgrade
63+
sudo apt-get install gcc-mingw-w64-x86-64 musl musl-tools gcc-aarch64-linux-gnu
64+
# Install Clang 14
6365
wget https://apt.llvm.org/llvm.sh
6466
chmod +x llvm.sh
6567
sudo ./llvm.sh 14
66-
sudo apt-get install gcc-mingw-w64-x86-64 musl musl-tools gcc-aarch64-linux-gnu
6768
6869
- name: Lint code
69-
run: just lint
70+
uses: actions-rs/cargo@v1
71+
with:
72+
command: clippy
73+
args: -- -D clippy::all -D clippy::exit -D clippy::perf -D clippy::cargo -D clippy::style -D clippy::nursery -D clippy::pedantic -D clippy::dbg_macro -D clippy::suspicious -D clippy::unwrap_used -D clippy::complexity -D clippy::create_dir -D clippy::correctness -W clippy::expect_used -A clippy::too-many-lines -A clippy::must-use-candidate -A clippy::multiple-crate-versions
7074

7175
- name: Run tests
7276
if: matrix.os != 'ubuntu-latest'
@@ -83,35 +87,87 @@ jobs:
8387

8488
- name: Build macOS Intel
8589
if: matrix.os == 'macos-latest'
86-
run: just build-mac-intel
90+
uses: actions-rs/cargo@v1
91+
with:
92+
command: build
93+
args: --target=x86_64-apple-darwin --release
8794

8895
- name: Build macOS ARM
8996
if: matrix.os == 'macos-latest'
90-
run: just build-mac-arm
97+
uses: actions-rs/cargo@v1
98+
with:
99+
command: build
100+
args: --target=aarch64-apple-darwin --release
101+
102+
- name: Zip macOS outputs
103+
if: matrix.os == 'macos-latest'
104+
run: |
105+
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
106+
zip -r out/ferium-macos-arm.zip -j target/aarch64-apple-darwin/release/ferium
91107
92108
- name: Build Windows
93109
if: matrix.os == 'windows-latest'
94-
run: just build-win
110+
uses: actions-rs/cargo@v1
111+
with:
112+
command: build
113+
args: --target=x86_64-pc-windows-msvc --release
114+
- name: Zip Windows output
115+
if: matrix.os == 'windows-latest'
116+
run: Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\ferium.exe" -DestinationPath "out\ferium-windows-msvc.zip"
95117

96118
- name: Build Linux
97119
if: matrix.os == 'ubuntu-latest'
98-
run: just build-linux
120+
uses: actions-rs/cargo@v1
121+
with:
122+
command: build
123+
args: --target=x86_64-unknown-linux-musl --release
99124

100-
- name: Build Linux nogui
125+
- name: Build ARM Linux
126+
if: matrix.os == 'ubuntu-latest'
127+
uses: actions-rs/cargo@v1
128+
with:
129+
command: rustc
130+
args: --target=aarch64-unknown-linux-musl --release -- -Clink-self-contained=yes -Clinker=rust-lld
131+
env:
132+
CC_aarch64_unknown_linux_musl: clang-14
133+
134+
- name: Zip Linux outputs
101135
if: matrix.os == 'ubuntu-latest'
102-
run: just build-linux-nogui
136+
run: |
137+
zip -r out/ferium-linux.zip -j target/x86_64-unknown-linux-musl/release/ferium
138+
zip -r out/ferium-linux-arm64.zip -j target/aarch64-unknown-linux-musl/release/ferium
103139
104-
- name: Build ARM Linux
140+
- name: Build Linux nogui
105141
if: matrix.os == 'ubuntu-latest'
106-
run: just build-linux-arm64
142+
uses: actions-rs/cargo@v1
143+
with:
144+
command: build
145+
args: --target=x86_64-unknown-linux-musl --release --no-default-features
107146

108147
- name: Build ARM Linux nogui
109148
if: matrix.os == 'ubuntu-latest'
110-
run: just build-linux-arm64-nogui
149+
uses: actions-rs/cargo@v1
150+
with:
151+
command: rustc
152+
args: --target=aarch64-unknown-linux-musl --release --no-default-features -- -Clink-self-contained=yes -Clinker=rust-lld
153+
env:
154+
CC_aarch64_unknown_linux_musl: clang-14
155+
156+
- name: Zip Linux nogui outputs
157+
if: matrix.os == 'ubuntu-latest'
158+
run: |
159+
zip -r out/ferium-linux-nogui.zip -j target/x86_64-unknown-linux-musl/release/ferium
160+
zip -r out/ferium-linux-arm64-nogui.zip -j target/aarch64-unknown-linux-musl/release/ferium
111161
112162
- name: Build Windows GNU
113163
if: matrix.os == 'ubuntu-latest'
114-
run: just build-win-gnu
164+
uses: actions-rs/cargo@v1
165+
with:
166+
command: build
167+
args: --target=x86_64-pc-windows-gnu --release
168+
- name: Zip Windows GNU output
169+
if: matrix.os == 'ubuntu-latest'
170+
run: zip -r out/ferium-windows-gnu.zip -j target/x86_64-pc-windows-gnu/release/ferium.exe
115171

116172
- name: Upload build artefacts
117173
uses: actions/upload-artifact@v3

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,10 @@ If you would like to make a feature request, check the [issues](https://github.c
250250
## Building from Source or Working on ferium
251251

252252
Firstly, you need the Rust toolchain which includes `cargo`, `rustup`, etc. You can install these from [the Rust website](https://www.rust-lang.org/tools/install).
253-
You'll also need the [`just`](https://github.com/casey/just#installation) command runner, which is basically a much better version of `make`.
253+
You can manually run cargo commands, but I recommend [`just`](https://github.com/casey/just#installation), a command runner that's basically a much better version of `make`.
254254

255-
To build the project and install it to your Cargo binary directory, clone the project and run `just install`. If you want to install it for testing a development version, run `just` (alias for `just install-dev`).
255+
To build the project and install it to your Cargo binary directory, clone the project and run `just install`. If you want to install it for testing purposes run `just` (alias to `just install-dev`), which builds in debug mode.
256256

257-
If you want to obtain executables for specific targets, you can run `just build-<target>` and replace `<target>` with `mac-intel`, `mac-arm` `win`, `win-gnu`, `linux`, or `linux-nogui`. The produced binaries will be zipped and moved to `out/`. `just build-linux-nogui` is for building binaries that don't need GTK, but they will not have a GUI file dialogue.
257+
You can run clippy lints using `just lint`, integration tests using `cargo test`, and delete all build and test artefacts using `just clean`.
258258

259-
You can run clippy lints using `just lint`, integration tests using `cargo test`, and delete all the build and test artefacts using `just clean`.
259+
If you would like to see instructions for building for specific targets (e.g. Linux ARM), head over to the [workflow file](.github/workflows/build.yml).

justfile

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,6 @@
11
default: install-dev
22
set windows-powershell := true
33

4-
# Build for macOS Intel
5-
build-mac-intel:
6-
rm -f out/ferium-macos-x64.zip
7-
mkdir -p out
8-
cargo build --target=x86_64-apple-darwin --release
9-
zip -r out/ferium-macos-x64.zip -j target/x86_64-apple-darwin/release/ferium
10-
11-
# Build for macOS Apple Silicon
12-
build-mac-arm:
13-
rm -f out/ferium-macos-arm.zip
14-
mkdir -p out
15-
cargo build --target=aarch64-apple-darwin --release
16-
zip -r out/ferium-macos-arm.zip -j target/aarch64-apple-darwin/release/ferium
17-
18-
# Build for Windows MSVC
19-
build-win:
20-
if (Test-Path -Path ".\out\ferium-windows-msvc.zip") { Remove-Item -Path ".\out\ferium-windows-msvc.zip" }
21-
if (-Not (Test-Path -Path ".\out")) { New-Item -Name "out" -ItemType Directory }
22-
cargo build --target=x86_64-pc-windows-msvc --release
23-
Compress-Archive -Path "target\x86_64-pc-windows-msvc\release\ferium.exe" -DestinationPath "out\ferium-windows-msvc.zip"
24-
25-
# Build for Windows GNU (e.g. Cygwin, MinGW)
26-
build-win-gnu:
27-
rm -f out/ferium-windows-gnu.zip
28-
mkdir -p out
29-
cargo build --target=x86_64-pc-windows-gnu --release
30-
zip -r out/ferium-windows-gnu.zip -j target/x86_64-pc-windows-gnu/release/ferium.exe
31-
32-
# Build for Linux
33-
build-linux:
34-
rm -f out/ferium-linux.zip
35-
mkdir -p out
36-
cargo build --target=x86_64-unknown-linux-musl --release
37-
zip -r out/ferium-linux.zip -j target/x86_64-unknown-linux-musl/release/ferium
38-
39-
# Build for Linux without a GUI
40-
build-linux-nogui:
41-
rm -f out/ferium-linux-nogui.zip
42-
mkdir -p out
43-
cargo build --target=x86_64-unknown-linux-musl --release --no-default-features
44-
zip -r out/ferium-linux-nogui.zip -j target/x86_64-unknown-linux-musl/release/ferium
45-
46-
# Build for Linux ARM64
47-
build-linux-arm64:
48-
rm -f out/ferium-linux-arm64.zip
49-
mkdir -p out
50-
CC_aarch64_unknown_linux_musl=clang-14 CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=rust-lld cargo rustc --target=aarch64-unknown-linux-musl --release -- -Clink-self-contained=yes -Clinker=rust-lld
51-
zip -r out/ferium-linux-arm64.zip -j target/aarch64-unknown-linux-musl/release/ferium
52-
53-
# Build for Linux ARM64 without a GUI
54-
build-linux-arm64-nogui:
55-
rm -f out/ferium-linux-arm64-nogui.zip
56-
mkdir -p out
57-
CC_aarch64_unknown_linux_musl=clang-14 CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=rust-lld cargo rustc --target=aarch64-unknown-linux-musl --release --no-default-features -- -Clink-self-contained=yes -Clinker=rust-lld
58-
zip -r out/ferium-linux-arm64-nogui.zip -j target/aarch64-unknown-linux-musl/release/ferium
59-
604
# Run clippy lints
615
lint:
626
cargo clippy -- \
@@ -89,7 +33,7 @@ install-dev:
8933
# Delete all build and test artefacts
9034
clean:
9135
cargo clean
92-
rm -rf out
36+
rm -rf
9337
rm -rf tests/mods
9438
rm -rf tests/md_modpack
9539
rm -rf tests/cf_modpack

0 commit comments

Comments
 (0)