diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..96bc864 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,118 @@ +name: Build and upload release binaries + +on: + # push: + # tags: + # - "v*" + workflow_dispatch: + pull_request: + branches: + - '**' # TODO: remove + +permissions: + contents: write + +jobs: + build-and-upload: + name: ${{ matrix.target }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + target: x86_64-unknown-linux-musl + use-cross: true + - os: ubuntu-latest + target: aarch64-unknown-linux-musl + use-cross: true + - os: macos-13 + target: x86_64-apple-darwin + use-cross: false + - os: macos-latest + target: aarch64-apple-darwin + use-cross: false + - os: windows-latest + target: x86_64-pc-windows-msvc + use-cross: false + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get latest tag + shell: bash + run: | + git fetch --tags + LATEST_TAG=$(git tag --sort=committerdate | tail -1) + echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + + - name: Handle Rust dependencies caching + uses: Swatinem/rust-cache@v2 + with: + key: v1-${{ matrix.target }} + + - name: Build binary + uses: clechasseur/rs-cargo@v2 + with: + command: build + args: --release --target ${{ matrix.target }} + use-cross: ${{ matrix.use-cross }} + + - name: Get binary name from Cargo.toml + shell: bash + run: | + BINARY_NAME=$(grep -m1 '^name' Cargo.toml | cut -d'"' -f2 | cut -d"'" -f2) + echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV + + - name: Create release archive + shell: bash + run: | + cd target/${{ matrix.target }}/release + if [ "${{ runner.os }}" = "Windows" ]; then + ARCHIVE="${{ env.BINARY_NAME }}-${{ env.LATEST_TAG }}-${{ matrix.target }}.zip" + mv "${{ env.BINARY_NAME }}.exe" "${{ env.BINARY_NAME }}-${{ matrix.target }}.exe" + 7z a "$ARCHIVE" "${{ env.BINARY_NAME }}-${{ matrix.target }}.exe" + else + ARCHIVE="${{ env.BINARY_NAME }}-${{ env.LATEST_TAG }}-${{ matrix.target }}.tar.gz" + mv "${{ env.BINARY_NAME }}" "${{ env.BINARY_NAME }}-${{ matrix.target }}" + tar -czvf "$ARCHIVE" "${{ env.BINARY_NAME }}-${{ matrix.target }}" + fi + + # Generate checksums + openssl dgst -r -sha256 -out "$ARCHIVE.sha256" "$ARCHIVE" + openssl dgst -r -sha512 -out "$ARCHIVE.sha512" "$ARCHIVE" + + echo "ASSET=$ARCHIVE" >> $GITHUB_ENV + + - name: Verify binary + shell: bash + run: | + cd target/${{ matrix.target }}/release + case "${{ matrix.target }}" in + *windows*) + 7z x -y "$ASSET" + ./${{ env.BINARY_NAME }}-${{ matrix.target }}.exe --version ;; + aarch64*) + echo "Can't test an ARM binary on a AMD64 runner" ;; + *) + tar -xvzf "$ASSET" + ./${{ env.BINARY_NAME }}-${{ matrix.target }} --version ;; + esac + + - name: Upload to release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.LATEST_TAG }} + files: | + target/${{ matrix.target }}/release/${{ env.ASSET }} + target/${{ matrix.target }}/release/${{ env.ASSET }}.sha256 + target/${{ matrix.target }}/release/${{ env.ASSET }}.sha512 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 2544f28..2912793 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,19 @@ Ensure you have cargo installed (see [here](https://doc.rust-lang.org/cargo/gett cargo install scooter ``` +### Prebuilt binaries + +You can download binaries from the releases page (note that you'll need to unzip after downloading): + +- **Linux** + - Intel/AMD: `*-x86_64-unknown-linux-musl.tar.gz` + - ARM64: `*-aarch64-unknown-linux-musl.tar.gz` +- **macOS** + - Apple Silicon: `*-aarch64-apple-darwin.tar.gz` + - Intel: `*-x86_64-apple-darwin.tar.gz` +- **Windows** + - `*-x86_64-pc-windows-msvc.zip` + ### Building from source Ensure you have cargo installed (see [here](https://doc.rust-lang.org/cargo/getting-started/installation.html)), then run the following commands: diff --git a/src/main.rs b/src/main.rs index 1321ee0..7143f66 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,11 @@ use ratatui::{backend::CrosstermBackend, Terminal}; use std::{io, path::PathBuf, str::FromStr}; use tui::Tui; +use crate::{ + app::App, + event::{Event, EventHandler}, +}; + mod app; mod event; mod fields; @@ -11,13 +16,10 @@ mod logging; mod tui; mod ui; mod utils; -use crate::{ - app::App, - event::{Event, EventHandler}, -}; #[derive(Parser, Debug)] #[command(about = "Interactive find and replace TUI.")] +#[command(version)] struct Args { /// Directory in which to search #[arg(index = 1)]