Skip to content

Commit

Permalink
Add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasschafer committed Nov 18, 2024
1 parent b534136 commit da1daea
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 4 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 6 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,22 @@ 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;
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)]
Expand Down

0 comments on commit da1daea

Please sign in to comment.