Skip to content

Commit

Permalink
Add msi builder for windows (#50)
Browse files Browse the repository at this point in the history
Tells playit program to use platform specific config path by default unless a local playit.toml file is present

* Use config path and add wix to build msi

* Move Directory def

* wix: Try fixes

* wix: register key for app data folder

* wix: set product id and ref component

* wix: add start menu shortcut

* wix: fix path name for shortcut

* wix: fix shortcut?

* github actions: add wix builder for windows

* Fix install command

* github actions: fix windows msi asset path
  • Loading branch information
loriopatrick authored Aug 31, 2023
1 parent 81988b8 commit f1a0d5c
Show file tree
Hide file tree
Showing 11 changed files with 421 additions and 28 deletions.
69 changes: 53 additions & 16 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ jobs:
apt_install: gcc-arm-linux-gnueabihf
artifact: playit-linux-armv7

- name: windows 32bit
os: windows-latest
arch: i686-pc-windows-msvc
artifact: playit-windows-i686.exe

- name: windows 64bit
os: windows-latest
arch: x86_64-pc-windows-msvc
artifact: playit-windows-amd64.exe

runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -72,24 +62,71 @@ jobs:
command: build
args: --target ${{ matrix.platform.arch }} --release --all

- name: Upload Binary
if: matrix.platform.os != 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.arch }}/release/playit-cli
asset_name: ${{ matrix.platform.artifact }}
asset_content_type: application/octet-stream
windows_build:
strategy:
fail-fast: false
matrix:
platform:
- name: windows 32bit
os: windows-latest
arch: i686-pc-windows-msvc
artifact: playit-windows-x86
arch_code: x86
- name: windows 64bit
os: windows-latest
arch: x86_64-pc-windows-msvc
artifact: playit-windows-x86_64
arch_code: x86_64
runs-on: ${{ matrix.platform.os }}
steps:
- uses: actions/checkout@v3

- name: Get release
id: get_release
uses: bruceadams/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

- name: Set path for candle and light
run: echo "C:\Program Files (x86)\WiX Toolset v3.11\bin" >> $GITHUB_PATH
shell: bash

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.arch }}

- run: cargo install cargo-wix
- run: cargo wix --target ${{ matrix.platform.arch }} --package playit-cli --nocapture

- name: Upload .exe
if: matrix.platform.os == 'windows-latest'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.arch }}/release/playit-cli.exe
asset_name: ${{ matrix.platform.artifact }}
asset_name: ${{ matrix.platform.artifact }}.exe
asset_content_type: application/octet-stream

- name: Upload Binary
if: matrix.platform.os != 'windows-latest'
- name: Upload .msi
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/${{ matrix.platform.arch }}/release/playit-cli
asset_name: ${{ matrix.platform.artifact }}
asset_path: ./target/wix/playit-cli-*-${{ matrix.platform.arch_code }}.msi
asset_name: ${{ matrix.platform.artifact }}.msi
asset_content_type: application/octet-stream
95 changes: 91 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions packages/agent_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playit-cli"
version = "1.0.0-rc7"
version = "0.10.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -20,6 +20,10 @@ clap = { version = "4.4", features = ["derive"] }
urlencoding = "2.1"
serde_yaml = "0.9"
crossterm = "0.26"
dirs = "5.0.1"

playit-agent-core = { path = "../agent_core" }
playit-agent-proto = { path = "../agent_proto" }
playit-agent-proto = { path = "../agent_proto" }

[target.'cfg(windows)'.build-dependencies]
winres = "0.1"
10 changes: 10 additions & 0 deletions packages/agent_cli/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#[cfg(windows)]
fn main() {
let mut res = winres::WindowsResource::new();
res.set_icon("wix/Product.ico");
res.compile().unwrap();
}

#[cfg(not(windows))]
fn main() {
}
2 changes: 1 addition & 1 deletion packages/agent_cli/src/autorun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{match_ip::MatchIp, playit_secret::PlayitSecret, ui::UI, CliError};

pub async fn autorun(ui: &mut UI, mut secret: PlayitSecret) -> Result<(), CliError> {
let secret_code = secret
.with_default_path()
.with_default_path().await
.ensure_valid(ui)
.await?
.get_or_setup(ui)
Expand Down
2 changes: 0 additions & 2 deletions packages/agent_cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ use crate::ui::UI;

pub const API_BASE: &'static str = "https://api.playit.gg";

// pub mod launch;
pub mod util;
pub mod autorun;
pub mod playit_secret;
pub mod playit_agent;
pub mod match_ip;
pub mod ui;

Expand Down
Empty file.
22 changes: 19 additions & 3 deletions packages/agent_cli/src/playit_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,26 @@ impl PlayitSecret {
Ok(PlayitApi::create(API_BASE.to_string(), Some(secret)))
}

pub fn with_default_path(&mut self) -> &mut Self {
if self.path.is_none() {
self.path.replace("playit.toml".to_string());
pub async fn with_default_path(&mut self) -> &mut Self {
if self.path.is_some() {
return self;
}

let config_path = dirs::config_local_dir();

if config_path.is_none() || tokio::fs::try_exists("playit.toml").await.unwrap_or(false) {
self.path = Some("playit.toml".to_string());
return self;
}

let config_folder = format!("{}/playit_gg", config_path.unwrap().to_string_lossy());
if let Err(error) = tokio::fs::create_dir_all(&config_folder).await {
tracing::error!(?error, "failed to create configuration folder");
self.path = Some("playit.toml".to_string());
return self;
}

self.path = Some(format!("{}/playit.toml", config_folder));
self
}

Expand Down
Binary file added packages/agent_cli/wix/Banner.bmp
Binary file not shown.
Binary file added packages/agent_cli/wix/Product.ico
Binary file not shown.
Loading

0 comments on commit f1a0d5c

Please sign in to comment.