From d1a123c154624b35160f0571c9b5a4fbeaddfb0d Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Sun, 7 Jul 2024 21:15:34 +0100 Subject: [PATCH 1/4] add windows builds to pipeline --- .github/workflows/build.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index e51ad83..740ad25 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -47,3 +47,19 @@ jobs: - uses: actions/checkout@v4 - name: Build run: cargo build --verbose + build-windows-amd64: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --target=x86_64-pc-windows-msvc --verbose + - name: Run tests + run: cargo test --verbose + build-windows-arm64: + runs-on: windows-2022 + steps: + - uses: actions/checkout@v4 + - name: Add aarch64-pc-windows-msvc target + run: rustup target add aarch64-pc-windows-msvc + - name: Build + run: cargo build --target=aarch64-pc-windows-msvc --verbose From c662d7e9f9fcd8ce13be65848b8c1fd461af7923 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Mon, 8 Jul 2024 10:00:11 +0100 Subject: [PATCH 2/4] add windows build support --- Cargo.toml | 5 +++-- src/restic.rs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a4e7e75..7bfde44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ flexi_logger = "0.28" humansize = "2" indicatif = "0.17" log = "0.4" -nix = { version = "0.28", features = ["process"] } rand = "0.8" ratatui = { version = "0.26", features = ["unstable-rendered-line-info", "unstable-widget-ref"] } rusqlite = { version = "0.31", features = ["bundled", "functions", "trace"] } @@ -30,9 +29,11 @@ serde = { version = "1", features = ["derive"] } serde_json = "1" thiserror = "1" unicode-segmentation = "1" - uuid = { version = "1", features = ["v4"], optional = true } +[target.'cfg(unix)'.dependencies] +nix = { version = "0.28", features = ["process"] } + [lib] path = "src/lib.rs" diff --git a/src/restic.rs b/src/restic.rs index 4c800c8..1e6fa8d 100644 --- a/src/restic.rs +++ b/src/restic.rs @@ -1,3 +1,5 @@ +#[cfg(not(target_os = "windows"))] +use std::os::unix::process::CommandExt; use std::{ borrow::Cow, ffi::OsStr, @@ -5,7 +7,6 @@ use std::{ io::{BufRead, BufReader, Lines, Read}, iter::Step, marker::PhantomData, - os::unix::process::CommandExt, process::{Child, ChildStdout, Command, ExitStatusError, Stdio}, str::Utf8Error, }; @@ -179,6 +180,7 @@ impl Restic { ) -> Result { let mut cmd = Command::new("restic"); // Need to detach process from terminal + #[cfg(not(target_os = "windows"))] unsafe { cmd.pre_exec(|| { nix::unistd::setsid()?; From 69883d5530a0e40cd21377a02b1db311f10f5564 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Mon, 8 Jul 2024 11:33:30 +0100 Subject: [PATCH 3/4] rename some jobs to use x86_64 rather than amd64 --- .github/workflows/build.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 740ad25..0077deb 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -10,7 +10,7 @@ env: CARGO_TERM_COLOR: always jobs: - build-linux-amd64: + build-linux-x86_64: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -35,7 +35,7 @@ jobs: run: cargo install cross - name: Build run: cross build --target aarch64-unknown-linux-musl --verbose - build-darwin-amd64: + build-darwin-x86_64: runs-on: macos-13 steps: - uses: actions/checkout@v4 @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v4 - name: Build run: cargo build --verbose - build-windows-amd64: + build-windows-x86_64: runs-on: windows-2022 steps: - uses: actions/checkout@v4 From 473016ed457366026dabe3c391703de3c39081a1 Mon Sep 17 00:00:00 2001 From: Daniel Oliveira Date: Mon, 8 Jul 2024 10:16:19 +0100 Subject: [PATCH 4/4] add windows to the release workflow --- .github/workflows/release.yaml | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ef9dacb..2a99586 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -91,3 +91,66 @@ jobs: uses: diamondburned/action-upload-release@v0.0.1 with: files: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-darwin-arm64.bz2 + build-windows-x86_64: + needs: set-env + runs-on: windows-2022 + steps: + - uses: actions/checkout@v4 + - name: Build + run: cargo build --release --verbose + - name: Run tests + run: cargo test --verbose + - name: Compress + run: > + Compress-Archive + target/release/${{needs.set-env.outputs.name}}.exe + ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-x86_64.zip + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: windows-x86_64-release + path: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-x86_64.zip + upload-windows-x86_64: + needs: [set-env, build-windows-x86_64] + runs-on: ubuntu-24.04 + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: windows-x86_64-release + - name: Upload + uses: diamondburned/action-upload-release@v0.0.1 + with: + files: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-x86_64.zip + build-windows-arm64: + needs: set-env + runs-on: windows-2022 + steps: + - uses: actions/checkout@v4 + - name: Add aarch64-pc-windows-msvc target + run: | + rustup target add aarch64-pc-windows-msvc + - name: Build + run: cargo build --release --target=aarch64-pc-windows-msvc --verbose + - name: Compress + run: > + Compress-Archive + target/aarch64-pc-windows-msvc/release/${{needs.set-env.outputs.name}}.exe + ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-arm64.zip + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: windows-arm64-release + path: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-arm64.zip + upload-windows-arm64: + needs: [set-env, build-windows-arm64] + runs-on: ubuntu-24.04 + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: windows-arm64-release + - name: Upload + uses: diamondburned/action-upload-release@v0.0.1 + with: + files: ${{needs.set-env.outputs.name}}-${{needs.set-env.outputs.version}}-windows-arm64.zip \ No newline at end of file