Skip to content

Commit

Permalink
portable windows build (first CI attempt)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drewol committed Oct 30, 2024
1 parent 7b4be80 commit 0c62ab8
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
24 changes: 23 additions & 1 deletion .github/workflows/game_msi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Game Installer
on:
push:
branches: [master]
branches: [master, windows-portable]
jobs:
bundle:
strategy:
Expand Down Expand Up @@ -62,3 +62,25 @@ jobs:
with:
name: Windows installer
path: target/**/*.msi
windows_portable:
runs-on: windows-latest
steps:
- uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-portable-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: cargo build --release --features portable
- name: Make zip
run: |
mkdir kson-win-portable
Copy-Item ${{ github.workspace }}/game/fonts -Destination ${{ github.workspace }}/kson-win-portable -Recurse
Copy-Item ${{ github.workspace }}/game/skins -Destination ${{ github.workspace }}/kson-win-portable -Recurse
Copy-Item ${{ github.workspace }}/target/release/rusc.exe -Destination ${{ github.workspace }}/kson-win-portable
Copy-Item ${{ github.workspace }}/target/release/kson-editor.exe -Destination ${{ github.workspace }}/kson-win-portable
Compress-Archive -Path ${{ github.workspace }}/kson-win-portable ${{ github.workspace }}/kson-win-portable.zip
- run: aws s3 sync . s3://${{ secrets.R2_BUCKET }}/${{ github.ref_name }} --endpoint-url ${{ secrets.S3_ENDPOINT }} --exclude "*" --include "*.zip"
- uses: actions/upload-artifact@v3
with:
name: Windows portable
path: ${{ github.workspace }}/kson-win-portable.zip
4 changes: 4 additions & 0 deletions game/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,7 @@ resources = ["game/skins", "game/fonts"]
[package.metadata.bundle.bin.kson-editor]
name = "KSON-Editor"
identifier = "dev.kson.editor"

[features]
default = []
portable = []
15 changes: 14 additions & 1 deletion game/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub type InnerRuscMixer = DynamicMixerController<f32>;
pub type RuscMixer = Arc<InnerRuscMixer>;

//TODO: Move to platform files
#[cfg(target_os = "windows")]
#[cfg(all(target_os = "windows", not(feature = "portable")))]
pub fn default_game_dir() -> PathBuf {
let mut game_dir = directories::UserDirs::new()
.expect("Failed to get directories")
Expand All @@ -102,6 +102,14 @@ pub fn default_game_dir() -> PathBuf {
game_dir.push("USC");
game_dir
}

#[cfg(all(target_os = "windows", feature = "portable"))]
pub fn default_game_dir() -> PathBuf {
let mut game_dir = std::env::current_exe().expect("Could not get exe path");
game_dir.pop();
game_dir
}

#[cfg(not(target_os = "windows"))]
pub fn default_game_dir() -> PathBuf {
let mut game_dir = directories::UserDirs::new()
Expand All @@ -113,6 +121,11 @@ pub fn default_game_dir() -> PathBuf {
}

pub fn init_game_dir(game_dir: impl AsRef<Path>) -> anyhow::Result<()> {
#[cfg(feature = "portable")]
{
return Ok(());
}

let cargo_dir = std::env::var("CARGO_MANIFEST_DIR");

let mut install_dir = if let Ok(manifest_dir) = &cargo_dir {
Expand Down

0 comments on commit 0c62ab8

Please sign in to comment.