Skip to content

Commit 60cd990

Browse files
Proper GitHub CI (#10)
* Add rust.yml workflow * Update rust.yml * Update rust.yml * Update rust.yml * Update rust.yml * Fix formatting * Update github workflow * Fix clippy * Rename CI workflow * Add release workflow * Update release workflow * Update target * Update workflow * Attempt fix CI * Remove itch * Remove comments * Improve dmg step * Get rid of wasm * Update binary matrix * Update release yml
1 parent 4f0d5ca commit 60cd990

File tree

6 files changed

+289
-13
lines changed

6 files changed

+289
-13
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
8+
jobs:
9+
test:
10+
name: Test Suite
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 30
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@v4
16+
- name: Cache
17+
uses: actions/cache@v4
18+
with:
19+
path: |
20+
~/.cargo/bin/
21+
~/.cargo/registry/index/
22+
~/.cargo/registry/cache/
23+
~/.cargo/git/db/
24+
target/
25+
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.toml') }}
26+
- name: Install stable toolchain
27+
uses: dtolnay/rust-toolchain@stable
28+
- name: Install Dependencies
29+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
30+
- name: Run cargo test
31+
run: cargo test
32+
33+
clippy_check:
34+
name: Clippy
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 30
37+
steps:
38+
- name: Checkout sources
39+
uses: actions/checkout@v4
40+
- name: Cache
41+
uses: actions/cache@v4
42+
with:
43+
path: |
44+
~/.cargo/bin/
45+
~/.cargo/registry/index/
46+
~/.cargo/registry/cache/
47+
~/.cargo/git/db/
48+
target/
49+
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.toml') }}
50+
- name: Install stable toolchain
51+
uses: dtolnay/rust-toolchain@stable
52+
with:
53+
components: clippy
54+
- name: Install Dependencies
55+
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
56+
- name: Run clippy
57+
run: cargo clippy -- -D warnings
58+
59+
format:
60+
name: Format
61+
runs-on: ubuntu-latest
62+
timeout-minutes: 30
63+
steps:
64+
- name: Checkout sources
65+
uses: actions/checkout@v4
66+
- name: Install stable toolchain
67+
uses: dtolnay/rust-toolchain@stable
68+
with:
69+
components: rustfmt
70+
- name: Run cargo fmt
71+
run: cargo fmt --all -- --check

.github/workflows/release.yml

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
add_binaries_to_github_release: true
10+
use_git_lfs: true
11+
12+
jobs:
13+
release-linux:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
binary: [client, server]
18+
19+
steps:
20+
- uses: olegtarasov/get-tag@v2.1.2
21+
id: get_version
22+
- uses: actions/checkout@v4
23+
with:
24+
lfs: ${{ env.use_git_lfs }}
25+
- uses: dtolnay/rust-toolchain@stable
26+
with:
27+
targets: x86_64-unknown-linux-gnu
28+
- name: install dependencies
29+
run: |
30+
sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
31+
32+
- name: Build
33+
run: |
34+
cargo build --release --target x86_64-unknown-linux-gnu --bin ${{ matrix.binary }}
35+
36+
- name: Prepare package
37+
run: |
38+
mkdir linux
39+
cp target/x86_64-unknown-linux-gnu/release/${{ matrix.binary }} linux/
40+
cp -r assets linux/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
41+
42+
- name: Package as a zip
43+
working-directory: ./linux
44+
run: |
45+
zip --recurse-paths ../${{ matrix.binary }}.zip .
46+
47+
- name: Upload binaries to artifacts
48+
uses: actions/upload-artifact@v3
49+
with:
50+
path: ${{ matrix.binary }}.zip
51+
name: linux-${{ matrix.binary }}
52+
retention-days: 1
53+
54+
- name: Upload binaries to release
55+
if: ${{ env.add_binaries_to_github_release == 'true' }}
56+
uses: svenstaro/upload-release-action@v2
57+
with:
58+
repo_token: ${{ secrets.GITHUB_TOKEN }}
59+
file: ${{ matrix.binary }}.zip
60+
asset_name: ${{ matrix.binary }}-linux-${{ steps.get_version.outputs.tag }}.zip
61+
tag: ${{ github.ref }}
62+
overwrite: true
63+
64+
release-windows:
65+
runs-on: windows-latest
66+
strategy:
67+
matrix:
68+
binary: [client, server]
69+
70+
steps:
71+
- uses: olegtarasov/get-tag@v2.1.2
72+
id: get_version
73+
- uses: actions/checkout@v4
74+
with:
75+
lfs: ${{ env.use_git_lfs }}
76+
- uses: dtolnay/rust-toolchain@stable
77+
with:
78+
targets: x86_64-pc-windows-msvc
79+
80+
- name: Build
81+
run: |
82+
cargo build --release --target x86_64-pc-windows-msvc --bin ${{ matrix.binary }}
83+
84+
- name: Prepare package
85+
run: |
86+
mkdir windows
87+
cp target/x86_64-pc-windows-msvc/release/${{ matrix.binary }}.exe windows/
88+
mkdir assets -ea 0 # create the assets directory if it does not exist, it will get ignored in the zip if empty
89+
cp -r assets windows/
90+
91+
- name: Package as a zip
92+
run: |
93+
Compress-Archive -Path windows/* -DestinationPath ${{ matrix.binary }}.zip
94+
95+
- name: Upload binaries to artifacts
96+
uses: actions/upload-artifact@v3
97+
with:
98+
path: ${{ matrix.binary }}.zip
99+
name: windows-${{ matrix.binary }}
100+
retention-days: 1
101+
102+
- name: Upload binaries to release
103+
if: ${{ env.add_binaries_to_github_release == 'true' }}
104+
uses: svenstaro/upload-release-action@v2
105+
with:
106+
repo_token: ${{ secrets.GITHUB_TOKEN }}
107+
file: ${{ matrix.binary }}.zip
108+
asset_name: ${{ matrix.binary }}-windows-${{ steps.get_version.outputs.tag }}.zip
109+
tag: ${{ github.ref }}
110+
overwrite: true
111+
112+
release-macOS-intel:
113+
runs-on: macOS-latest
114+
strategy:
115+
matrix:
116+
binary: [client, server]
117+
118+
steps:
119+
- uses: olegtarasov/get-tag@v2.1.2
120+
id: get_version
121+
- uses: actions/checkout@v4
122+
with:
123+
lfs: ${{ env.use_git_lfs }}
124+
- uses: dtolnay/rust-toolchain@stable
125+
with:
126+
targets: x86_64-apple-darwin
127+
- name: Environment Setup
128+
run: |
129+
export CFLAGS="-fno-stack-check"
130+
export MACOSX_DEPLOYMENT_TARGET="10.9"
131+
132+
- name: Build
133+
run: |
134+
cargo build --release --target x86_64-apple-darwin --bin ${{ matrix.binary }}
135+
136+
- name: Prepare Package
137+
run: |
138+
mkdir -p ${{ matrix.binary }}.app/Contents/MacOS
139+
cp target/x86_64-apple-darwin/release/${{ matrix.binary }} ${{ matrix.binary }}.app/Contents/MacOS/
140+
cp -r assets ${{ matrix.binary }}.app/Contents/MacOS/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
141+
hdiutil create -fs HFS+ -volname "${{ matrix.binary }}" -srcfolder ${{ matrix.binary }}.app ${{ matrix.binary }}-macOS-intel.dmg
142+
143+
- name: Upload binaries to artifacts
144+
uses: actions/upload-artifact@v3
145+
with:
146+
path: ${{ matrix.binary }}-macOS-intel.dmg
147+
name: macOS-intel-${{ matrix.binary }}
148+
retention-days: 1
149+
150+
- name: Upload binaries to release
151+
if: ${{ env.add_binaries_to_github_release == 'true' }}
152+
uses: svenstaro/upload-release-action@v2
153+
with:
154+
repo_token: ${{ secrets.GITHUB_TOKEN }}
155+
file: ${{ matrix.binary }}-macOS-intel.dmg
156+
asset_name: ${{ matrix.binary }}-macOS-intel-${{ steps.get_version.outputs.tag }}.dmg
157+
tag: ${{ github.ref }}
158+
overwrite: true
159+
160+
release-macOS-apple-silicon:
161+
runs-on: macOS-latest
162+
strategy:
163+
matrix:
164+
binary: [client, server]
165+
166+
steps:
167+
- uses: olegtarasov/get-tag@v2.1.2
168+
id: get_version
169+
- uses: actions/checkout@v4
170+
with:
171+
lfs: ${{ env.use_git_lfs }}
172+
- uses: dtolnay/rust-toolchain@stable
173+
with:
174+
targets: aarch64-apple-darwin
175+
- name: Environment
176+
run: |
177+
export MACOSX_DEPLOYMENT_TARGET="11"
178+
179+
- name: Build
180+
run: |
181+
cargo build --release --target aarch64-apple-darwin --bin ${{ matrix.binary }}
182+
183+
- name: Prepare Package
184+
run: |
185+
mkdir -p ${{ matrix.binary }}.app/Contents/MacOS
186+
cp target/aarch64-apple-darwin/release/${{ matrix.binary }} ${{ matrix.binary }}.app/Contents/MacOS/
187+
cp -r assets ${{ matrix.binary }}.app/Contents/MacOS/ || true # Try to copy, but ignore if it can't copy if source directory does not exist
188+
- name: Create DMG
189+
run: |
190+
hdiutil create -fs HFS+ -volname "${{ matrix.binary }}-macOS-apple-silicon" -srcfolder ${{ matrix.binary }}.app ${{ matrix.binary }}-macOS-apple-silicon.dmg
191+
192+
- name: Verify DMG
193+
run: |
194+
hdiutil verify ${{ matrix.binary }}-macOS-apple-silicon.dmg
195+
- name: Upload binaries to artifacts
196+
uses: actions/upload-artifact@v3
197+
with:
198+
path: ${{ matrix.binary }}-macOS-apple-silicon.dmg
199+
name: macOS-apple-silicon-${{ matrix.binary }}
200+
retention-days: 1
201+
202+
- name: Upload binaries to release
203+
if: ${{ env.add_binaries_to_github_release == 'true' }}
204+
uses: svenstaro/upload-release-action@v2
205+
with:
206+
repo_token: ${{ secrets.GITHUB_TOKEN }}
207+
file: ${{ matrix.binary }}-macOS-apple-silicon.dmg
208+
asset_name: ${{ matrix.binary }}-macOS-apple-silicon-${{ steps.get_version.outputs.tag }}.dmg
209+
tag: ${{ github.ref }}
210+
overwrite: true

src/client/player/systems/keyboard.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ pub fn handle_keyboard_events_system(
66
mut collider_events: EventWriter<collider_events::ColliderUpdateEvent>,
77
) {
88
for event in keyboard_events.read() {
9-
if event.state.is_pressed() {
10-
match event.key_code {
11-
bevy::input::keyboard::KeyCode::KeyC => {
12-
let controller_transform = camera_query.single();
13-
println!("Handling event: {:?}", controller_transform.translation);
14-
collider_events.send(collider_events::ColliderUpdateEvent {
15-
position: controller_transform.translation.into(),
16-
});
17-
}
18-
_ => {}
19-
}
9+
if event.state.is_pressed() && event.key_code == bevy::input::keyboard::KeyCode::KeyC {
10+
let controller_transform = camera_query.single();
11+
println!("Handling event: {:?}", controller_transform.translation);
12+
collider_events.send(collider_events::ColliderUpdateEvent {
13+
position: controller_transform.translation.into(),
14+
});
2015
}
2116
}
2217
}

src/client/terrain/components.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ use bevy::ecs::component::Component;
44
pub struct ChunkMesh {
55
pub key: [i32; 3],
66
}
7-

src/server/player/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::prelude::*;
22

3-
pub mod systems;
43
pub mod resources;
4+
pub mod systems;
55

66
pub struct PlayerPlugin;
77

src/server/terrain/systems.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)