ci: compile for macOS and Windows

This commit is contained in:
iff 2024-11-18 15:29:45 +01:00
parent 409b8245e6
commit 508e61a451
3 changed files with 78 additions and 29 deletions

View file

@ -7,26 +7,34 @@ on:
jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: build
run: |
cargo build --release --all-features
- name: Zipping files
- name: Zipping files (exe)
if: matrix.os == 'windows-latest'
run: |
7z a ./pay-respects-ubuntu-latest.zip ./target/release/pay-respects
7z a pay-respects-${{ matrix.os }}.zip ./target/release/pay-respects.exe
- name: Zipping files (unix)
if: matrix.os != 'windows-latest'
run: |
7z a pay-respects-${{ matrix.os }}.zip ./target/release/pay-respects
- name: Uploading to release
uses: ncipollo/release-action@v1
with:
artifacts: pay-respects-ubuntu-latest.zip
artifacts: pay-respects-${{ matrix.os }}.zip
allowUpdates: true
makeLatest: true

View file

@ -19,14 +19,14 @@ Please follow the instruction for your shell:
<summary>Bash / Zsh / Fish</summary>
> Manual aliasing:
> ``` shell
> ```shell
> alias f="$(pay-respects bash)"
> alias f="$(pay-respects zsh)"
> alias f="$(pay-respects fish)"
> ```
> Auto aliasing (optional custom alias can be added after `--alias argument`):
> ``` shell
> ```shell
> eval "$(pay-respects bash --alias)"
> eval "$(pay-respects zsh --alias)"
> pay-respects fish --alias | source
@ -61,6 +61,8 @@ Install from your package manager if available:
[![Packaging status](https://repology.org/badge/vertical-allrepos/pay-respects.svg)](https://repology.org/project/pay-respects/versions)
Compiled binaries can be found at [GitHub releases](https://github.com/iffse/pay-respects/releases).
<details>
<summary>Generic x86 Desktop Linux</summary>

View file

@ -1,5 +1,4 @@
use std::io::stderr;
use std::os::fd::AsFd;
use std::process::{exit, Stdio};
use std::time::{Duration, Instant};
@ -224,17 +223,7 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
command = expand_alias_multiline(shell, &command);
let now = Instant::now();
let process = std::process::Command::new(p)
.arg(shell)
.arg("-c")
.arg(&command)
// .stdout(Stdio::inherit())
.stdout(stderr().as_fd().try_clone_to_owned().unwrap())
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap();
let process = run_suggestion_p(shell, p, &command);
if process.success() {
let cd = shell_evaluated_commands(shell, &command);
@ -262,16 +251,7 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
let command = expand_alias_multiline(shell, command);
let now = Instant::now();
let process = std::process::Command::new(shell)
.arg("-c")
.arg(&command)
// .stdout(Stdio::inherit())
.stdout(stderr().as_fd().try_clone_to_owned().unwrap())
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap();
let process = run_suggestion(shell, &command);
if process.success() {
let cd = shell_evaluated_commands(shell, &command);
@ -296,3 +276,62 @@ pub fn confirm_suggestion(shell: &str, command: &str, highlighted: &str) -> Resu
Err(error_msg.to_string())
}
}
#[cfg(not(target_os = "windows"))]
fn run_suggestion_p (shell: &str, p: &str, command: &str) -> std::process::ExitStatus {
use std::os::fd::AsFd;
std::process::Command::new(p)
.arg(shell)
.arg("-c")
.arg(command)
.stdout(stderr().as_fd().try_clone_to_owned().unwrap())
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap()
}
#[cfg(not(target_os = "windows"))]
fn run_suggestion (shell: &str, command: &str) -> std::process::ExitStatus {
use std::os::fd::AsFd;
std::process::Command::new(shell)
.arg("-c")
.arg(command)
// .stdout(Stdio::inherit())
.stdout(stderr().as_fd().try_clone_to_owned().unwrap())
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap()
}
#[cfg(target_os = "windows")]
fn run_suggestion_p (shell: &str, p: &str, command: &str) -> std::process::ExitStatus {
use std::os::windows::io::AsHandle;
std::process::Command::new(p)
.arg(shell)
.arg("-c")
.arg(command)
.stdout(stderr().as_handle().try_clone_to_owned().unwrap())
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap()
}
#[cfg(target_os = "windows")]
fn run_suggestion (shell: &str, command: &str) -> std::process::ExitStatus {
use std::os::windows::io::AsHandle;
std::process::Command::new(shell)
.arg("-c")
.arg(command)
.stdout(stderr().as_handle().try_clone_to_owned().unwrap())
.stderr(Stdio::inherit())
.spawn()
.expect("failed to execute process")
.wait()
.unwrap()
}