Skip to content

Commit 0813da2

Browse files
authored
Merge pull request #177 from deavid:dev-deavid
Fixes for release
2 parents 816a4f7 + 83f33fb commit 0813da2

21 files changed

Lines changed: 383 additions & 95 deletions

File tree

.github/workflows/release-alpha.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,23 @@ jobs:
3030
toolchain: stable
3131
target: x86_64-pc-windows-gnu,wasm32-unknown-unknown
3232

33+
- name: Restore Cargo cache
34+
uses: Swatinem/rust-cache@v2
35+
3336
- name: Install just
3437
uses: extractions/setup-just@v3
3538

36-
- name: Build and Package Artifacts
37-
run: just package-all
39+
- name: Build and Package Linux
40+
run: just package-linux
41+
42+
- name: Build and Package Windows
43+
run: just package-windows
44+
45+
- name: Build and Package WASM
46+
run: just package-wasm
47+
48+
- name: Build and Package Server
49+
run: just package-server
3850

3951
- name: Overwrite alpha-latest rolling release
4052
env:

.github/workflows/release-beta.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,23 @@ jobs:
3939
toolchain: stable
4040
target: x86_64-pc-windows-gnu,wasm32-unknown-unknown
4141

42+
- name: Restore Cargo cache
43+
uses: Swatinem/rust-cache@v2
44+
4245
- name: Install just
4346
uses: extractions/setup-just@v3
4447

45-
- name: Build and Package Artifacts (justfile)
46-
run: just package-all
48+
- name: Build and Package Linux
49+
run: just package-linux
50+
51+
- name: Build and Package Windows
52+
run: just package-windows
53+
54+
- name: Build and Package WASM
55+
run: just package-wasm
56+
57+
- name: Build and Package Server
58+
run: just package-server
4759

4860

4961
- name: Create GitHub Pre-Release and Upload Artifacts

.github/workflows/release-main.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,20 @@ jobs:
6262
echo "RELEASE_NOTES=$NOTES" >> $GITHUB_OUTPUT
6363
shell: bash
6464

65-
- name: Build and Package Artifacts (justfile)
66-
run: just package-all
65+
- name: Restore Cargo cache
66+
uses: Swatinem/rust-cache@v2
67+
68+
- name: Build and Package Linux
69+
run: just package-linux
70+
71+
- name: Build and Package Windows
72+
run: just package-windows
73+
74+
- name: Build and Package WASM
75+
run: just package-wasm
76+
77+
- name: Build and Package Server
78+
run: just package-server
6779

6880
- name: Create GitHub Release and Upload Artifacts
6981
env:

Cargo.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ members = [
77
"crates/tools/unhub",
88
"crates/tools/unprocman",
99
"crates/tools/text_to_speech/walkie_voice_generator",
10+
"crates/tools/assetidx_updater",
1011

1112
# ── Portable Libraries ─────────────────────────────────────────────────
1213
# Game-agnostic Bevy plugins. Zero Unhaunter-specific knowledge.
@@ -20,6 +21,7 @@ members = [
2021
# Zero internal game dependencies. Dependency arrow points here.
2122
# ════════════════════════════════════════════════════════════════════════
2223
"crates/uncommon-app-core", # Base platform utilities and basic types
24+
"crates/unassetidx-updater", # Asset index file generator
2325
"crates/uncommon-states-core",
2426
"crates/unspatial-core", # Coordinate math (isometric, Position, Direction)
2527
"crates/unnoise-core", # Procedural noise math (Perlin)
@@ -286,6 +288,7 @@ unfps-plugin = { path = "crates/unfps-plugin" } # Frame-rate limiter via std::th
286288
# Zero internal game dependencies. Dependency arrow points here.
287289
# ════════════════════════════════════════════════════════════════════════════
288290
uncommon-app-core = { path = "crates/uncommon-app-core" } # Binary-level base tools
291+
unassetidx-updater = { path = "crates/unassetidx-updater" } # Asset index updater
289292
unspatial-core = { path = "crates/unspatial-core" } # Coordinate math (isometric)
290293
unnoise-core = { path = "crates/unnoise-core" } # Procedural noise math (Perlin)
291294
unmetrics-core = { path = "crates/unmetrics-core" } # Performance diagnostic data
@@ -467,6 +470,7 @@ getrandom_02 = { workspace = true }
467470
uncommon-states-core = { workspace = true }
468471
undifficulty-core = { workspace = true }
469472
uncommon-app-core = { workspace = true }
473+
unassetidx-updater = { workspace = true }
470474
unmission-core = { workspace = true }
471475
unvitals-plugin = { workspace = true }
472476
uninventory-plugin = { workspace = true }

Justfile

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,85 +30,170 @@ upscale-assets:
3030

3131
# Build Linux Release Binary
3232
build-linux:
33+
#!/usr/bin/env bash
34+
set -euo pipefail
35+
recipe_start=$SECONDS
36+
echo "::group::build-linux"
3337
echo "Building Linux release..."
38+
step_start=$SECONDS
3439
cargo build --release --target x86_64-unknown-linux-gnu
40+
echo "[timing] build-linux:cargo-build=$((SECONDS - step_start))s"
3541
echo "Linux build complete."
42+
echo "[timing] build-linux:total=$((SECONDS - recipe_start))s"
43+
echo "::endgroup::"
3644
3745
# Build Windows Release Binary (GNU toolchain)
3846
# Assumes mingw-w64 is installed (either locally or in GH Actions runner)
3947
build-windows:
48+
#!/usr/bin/env bash
49+
set -euo pipefail
50+
recipe_start=$SECONDS
51+
echo "::group::build-windows"
4052
echo "Building Windows release..."
53+
step_start=$SECONDS
4154
cargo build --release --target x86_64-pc-windows-gnu
55+
echo "[timing] build-windows:cargo-build=$((SECONDS - step_start))s"
4256
echo "Windows build complete."
57+
echo "[timing] build-windows:total=$((SECONDS - recipe_start))s"
58+
echo "::endgroup::"
4359
4460
# Build WASM Package
4561
build-wasm:
62+
#!/usr/bin/env bash
63+
set -euo pipefail
64+
recipe_start=$SECONDS
65+
echo "::group::build-wasm"
4666
echo "Building WASM package..."
67+
step_start=$SECONDS
4768
cargo install wasm-pack # Ensure wasm-pack is available
69+
echo "[timing] build-wasm:install-wasm-pack=$((SECONDS - step_start))s"
70+
step_start=$SECONDS
4871
wasm-pack build --release --target web
72+
echo "[timing] build-wasm:wasm-pack-build=$((SECONDS - step_start))s"
4973
echo "WASM build complete."
74+
echo "[timing] build-wasm:total=$((SECONDS - recipe_start))s"
75+
echo "::endgroup::"
5076
5177
# Build Dedicated Server Binary (Linux only)
5278
build-server:
79+
#!/usr/bin/env bash
80+
set -euo pipefail
81+
recipe_start=$SECONDS
82+
echo "::group::build-server"
5383
echo "Building server release..."
84+
step_start=$SECONDS
5485
cargo build --release --target x86_64-unknown-linux-gnu --bin unhaunter_dedicated
86+
echo "[timing] build-server:cargo-build=$((SECONDS - step_start))s"
5587
echo "Server build complete."
88+
echo "[timing] build-server:total=$((SECONDS - recipe_start))s"
89+
echo "::endgroup::"
5690
5791
# == Packaging Recipes ==
5892

5993
package-common: ensure-dist-dir upscale-assets
94+
#!/usr/bin/env bash
95+
set -euo pipefail
96+
recipe_start=$SECONDS
97+
echo "::group::package-common"
6098
echo "Packaging Common artifacts for {{_version}}..."
99+
step_start=$SECONDS
100+
cargo run -p assetidx_updater --release
101+
echo "[timing] package-common:update-assetidx=$((SECONDS - step_start))s"
102+
step_start=$SECONDS
61103
rm -rf {{_dist_dir}}/common/*
62104
cp -r {{_assets_dir}} {{_dist_dir}}/common/assets
63105
cp {{_readme}} {{_dist_dir}}/common/README.md
64106
cp {{_license}} {{_dist_dir}}/common/LICENSE
65107
cp {{_changelog}} {{_dist_dir}}/common/CHANGELOG.md
66108
cp favicon*.png favicon*.ico {{_dist_dir}}/common/
67109
cp screenshots {{_dist_dir}}/common/screenshots -R
110+
echo "[timing] package-common:copy-assets-and-docs=$((SECONDS - step_start))s"
111+
echo "[timing] package-common:total=$((SECONDS - recipe_start))s"
112+
echo "::endgroup::"
68113
69114
# Package Linux Artifacts into .tar.gz
70115
package-linux: build-linux package-common
116+
#!/usr/bin/env bash
117+
set -euo pipefail
118+
recipe_start=$SECONDS
119+
echo "::group::package-linux"
71120
echo "Packaging Linux artifact for {{_version}}..."
121+
step_start=$SECONDS
72122
rm -rf {{_dist_dir}}/linux/*
73123
cp {{_dist_dir}}/common/* {{_dist_dir}}/linux/ -R
74124
cp {{_target_dir}}/x86_64-unknown-linux-gnu/release/unhaunter_game {{_dist_dir}}/linux/unhaunter_game
125+
echo "[timing] package-linux:prepare-files=$((SECONDS - step_start))s"
126+
step_start=$SECONDS
75127
unlink {{_releases_dir}}/unhaunter-{{_version}}-linux-x86_64.tar.gz || true
76-
tar -czvf {{_releases_dir}}/unhaunter-{{_version}}-linux-x86_64.tar.gz -C {{_dist_dir}}/linux .
128+
tar -czf {{_releases_dir}}/unhaunter-{{_version}}-linux-x86_64.tar.gz -C {{_dist_dir}}/linux .
129+
echo "[timing] package-linux:create-tarball=$((SECONDS - step_start))s"
77130
echo "Linux package created: {{_releases_dir}}/unhaunter-{{_version}}-linux-x86_64.tar.gz"
131+
echo "[timing] package-linux:total=$((SECONDS - recipe_start))s"
132+
echo "::endgroup::"
78133
79134
# Package Windows Artifacts into .zip
80135
package-windows: build-windows package-common
136+
#!/usr/bin/env bash
137+
set -euo pipefail
138+
recipe_start=$SECONDS
139+
echo "::group::package-windows"
81140
echo "Packaging Windows artifact for {{_version}}..."
141+
step_start=$SECONDS
82142
rm -rf {{_dist_dir}}/windows/*
83143
cp {{_dist_dir}}/common/* {{_dist_dir}}/windows/ -R
84144
cp {{_target_dir}}/x86_64-pc-windows-gnu/release/unhaunter_game.exe {{_dist_dir}}/windows/unhaunter_game.exe
145+
echo "[timing] package-windows:prepare-files=$((SECONDS - step_start))s"
146+
step_start=$SECONDS
85147
unlink {{_releases_dir}}/unhaunter-{{_version}}-windows-x86_64.zip || true
86148
cd {{_dist_dir}}/windows && zip -r ../../{{_releases_dir}}/unhaunter-{{_version}}-windows-x86_64.zip *
87149
cd ../../
150+
echo "[timing] package-windows:create-zip=$((SECONDS - step_start))s"
88151
echo "Windows package created: {{_releases_dir}}/unhaunter-{{_version}}-windows-x86_64.zip"
152+
echo "[timing] package-windows:total=$((SECONDS - recipe_start))s"
153+
echo "::endgroup::"
89154
90155
# Package WASM Artifacts into .zip
91156
package-wasm: build-wasm package-common
157+
#!/usr/bin/env bash
158+
set -euo pipefail
159+
recipe_start=$SECONDS
160+
echo "::group::package-wasm"
92161
echo "Packaging WASM artifact for {{_version}}..."
162+
step_start=$SECONDS
93163
rm -rf {{_dist_dir}}/wasm/*
94164
cp {{_dist_dir}}/common/* {{_dist_dir}}/wasm/ -R
95165
cp -r pkg {{_dist_dir}}/wasm/pkg
96166
cp index.html {{_dist_dir}}/wasm/index.html
167+
echo "[timing] package-wasm:prepare-files=$((SECONDS - step_start))s"
168+
step_start=$SECONDS
97169
unlink {{_releases_dir}}/unhaunter-{{_version}}-wasm.zip || true
98170
cd {{_dist_dir}}/wasm && zip -r ../../{{_releases_dir}}/unhaunter-{{_version}}-wasm.zip *
99171
cd ../../
172+
echo "[timing] package-wasm:create-zip=$((SECONDS - step_start))s"
100173
echo "WASM package created: {{_releases_dir}}/unhaunter-{{_version}}-wasm.zip"
174+
echo "[timing] package-wasm:total=$((SECONDS - recipe_start))s"
175+
echo "::endgroup::"
101176
102177
# Package Dedicated Server Artifacts into .tar.gz
103178
package-server: ensure-dist-dir build-server
179+
#!/usr/bin/env bash
180+
set -euo pipefail
181+
recipe_start=$SECONDS
182+
echo "::group::package-server"
104183
echo "Packaging server artifact for {{_version}}..."
184+
step_start=$SECONDS
105185
rm -rf {{_dist_dir}}/server
106186
mkdir -p {{_dist_dir}}/server
107187
cp {{_target_dir}}/x86_64-unknown-linux-gnu/release/unhaunter_dedicated {{_dist_dir}}/server/unhaunter_dedicated
108188
cp -r {{_assets_dir}} {{_dist_dir}}/server/assets
189+
echo "[timing] package-server:prepare-files=$((SECONDS - step_start))s"
190+
step_start=$SECONDS
109191
unlink {{_releases_dir}}/unhaunter-{{_version}}-server-linux-x86_64.tar.gz || true
110-
tar -czvf {{_releases_dir}}/unhaunter-{{_version}}-server-linux-x86_64.tar.gz -C {{_dist_dir}}/server .
192+
tar -czf {{_releases_dir}}/unhaunter-{{_version}}-server-linux-x86_64.tar.gz -C {{_dist_dir}}/server .
193+
echo "[timing] package-server:create-tarball=$((SECONDS - step_start))s"
111194
echo "Server package created: {{_releases_dir}}/unhaunter-{{_version}}-server-linux-x86_64.tar.gz"
195+
echo "[timing] package-server:total=$((SECONDS - recipe_start))s"
196+
echo "::endgroup::"
112197
113198
114199
# == Combined Recipes ==
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "assetidx_updater"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[dependencies]
8+
unassetidx-updater = { workspace = true }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn main() {
2+
if let Err(e) = unassetidx_updater::update_assetidx_files() {
3+
eprintln!("Failed to update assetidx files: {}", e);
4+
std::process::exit(1);
5+
}
6+
}

crates/tools/text_to_speech/walkie_voice_generator/src/utils.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ pub(crate) fn generate_sample_ron() -> String {
106106
/// A `Result` containing the hex-encoded SHA256 hash string if successful,
107107
/// or an `anyhow::Error` if the file cannot be read or hashing fails.
108108
pub(crate) fn calculate_script_hash(script_path: &str) -> Result<String, anyhow::Error> {
109+
use std::io::Read;
109110
let mut file = File::open(script_path).map_err(|e| {
110111
anyhow::anyhow!(
111112
"Failed to open script file {} for hashing: {}",
@@ -114,14 +115,20 @@ pub(crate) fn calculate_script_hash(script_path: &str) -> Result<String, anyhow:
114115
)
115116
})?;
116117
let mut hasher = Sha256::new();
117-
std::io::copy(&mut file, &mut hasher).map_err(|e| {
118+
let mut buffer = Vec::new();
119+
file.read_to_end(&mut buffer).map_err(|e| {
118120
anyhow::anyhow!(
119121
"Failed to read script file {} for hashing: {}",
120122
script_path,
121123
e
122124
)
123125
})?;
124-
Ok(format!("{:x}", hasher.finalize())) // Format hash as a hex string.
126+
hasher.update(&buffer);
127+
Ok(hasher
128+
.finalize()
129+
.iter()
130+
.map(|b| format!("{:02x}", b))
131+
.collect()) // Format hash as a hex string.
125132
}
126133

127134
/// Calculates a combined SHA256 signature for a voice line.
@@ -138,7 +145,11 @@ pub(crate) fn calculate_combined_signature(tts_text: &str, script_hash: &str) ->
138145
let mut hasher = Sha256::new();
139146
hasher.update(tts_text.as_bytes());
140147
hasher.update(script_hash.as_bytes());
141-
format!("{:x}", hasher.finalize())
148+
hasher
149+
.finalize()
150+
.iter()
151+
.map(|b| format!("{:02x}", b))
152+
.collect()
142153
}
143154

144155
/// Scans a directory for RON files (`.ron` extension).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "unassetidx-updater"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
walkdir = { workspace = true }

0 commit comments

Comments
 (0)