mirror of
https://github.com/Ap0dexMe0/unixtract.git
synced 2026-07-15 21:00:03 +02:00
released
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
name: rust
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.target }}
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
artifact: unixtract-linux
|
||||
bin: unixtract
|
||||
- target: x86_64-pc-windows-gnu
|
||||
artifact: unixtract-windows.exe
|
||||
bin: unixtract.exe
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Rust toolchain
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.target }}
|
||||
|
||||
- name: Install mingw-w64 (Windows target)
|
||||
if: matrix.target == 'x86_64-pc-windows-gnu'
|
||||
run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64
|
||||
|
||||
- name: Cache cargo
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Build
|
||||
run: cargo build --release --target ${{ matrix.target }}
|
||||
|
||||
- name: Rename binary
|
||||
run: cp "target/${{ matrix.target }}/release/${{ matrix.bin }}" "${{ matrix.artifact }}"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.artifact }}
|
||||
path: ${{ matrix.artifact }}
|
||||
if-no-files-found: error
|
||||
@@ -1,71 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Cross-compile unixtract for multiple targets and collect the binaries into
|
||||
# ./dist. Run from the repository root:
|
||||
#
|
||||
# ./build.sh # build the default target set
|
||||
# ./build.sh <target> ... # build only the given rustc target triples
|
||||
#
|
||||
# Requirements (Debian/Ubuntu example):
|
||||
# rustup # toolchain manager
|
||||
# sudo apt install gcc-mingw-w64-x86-64 # for x86_64-pc-windows-gnu
|
||||
# sudo apt install gcc-aarch64-linux-gnu # for aarch64-unknown-linux-gnu (optional)
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
# --- Target set ------------------------------------------------------------
|
||||
# Override by passing target triples as arguments.
|
||||
DEFAULT_TARGETS=(
|
||||
x86_64-unknown-linux-gnu
|
||||
x86_64-pc-windows-gnu
|
||||
)
|
||||
clear
|
||||
echo "Cleaning target and dist directories..."
|
||||
rm -rf target dist
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
TARGETS=("$@")
|
||||
else
|
||||
TARGETS=("${DEFAULT_TARGETS[@]}")
|
||||
echo "Building unixtract (Linux + Windows)..."
|
||||
|
||||
# Clean using cargo (redundant but safe)
|
||||
cargo clean
|
||||
|
||||
# Build Linux
|
||||
cargo build --target x86_64-unknown-linux-gnu --release
|
||||
|
||||
# Build Windows (GNU)
|
||||
cargo build --target x86_64-pc-windows-gnu --release
|
||||
|
||||
# Prepare dist folder
|
||||
mkdir -p dist
|
||||
|
||||
echo "Collecting binaries..."
|
||||
|
||||
# Linux binary
|
||||
LINUX_BIN="target/x86_64-unknown-linux-gnu/release/unixtract"
|
||||
if [ -f "$LINUX_BIN" ]; then
|
||||
cp "$LINUX_BIN" "dist/unixtract-linux"
|
||||
fi
|
||||
|
||||
BIN_NAME="unixtract"
|
||||
DIST_DIR="dist"
|
||||
|
||||
echo "==> Building ${BIN_NAME} for: ${TARGETS[*]}"
|
||||
|
||||
mkdir -p "$DIST_DIR"
|
||||
|
||||
for target in "${TARGETS[@]}"; do
|
||||
echo
|
||||
echo "==> Target: $target"
|
||||
|
||||
# Ensure the target's std library is installed.
|
||||
if ! rustup target list --installed | grep -qx "$target"; then
|
||||
echo " Installing rust std for $target ..."
|
||||
rustup target add "$target"
|
||||
# Windows binary
|
||||
WINDOWS_BIN="target/x86_64-pc-windows-gnu/release/unixtract.exe"
|
||||
if [ -f "$WINDOWS_BIN" ]; then
|
||||
cp "$WINDOWS_BIN" "dist/unixtract-windows.exe"
|
||||
fi
|
||||
|
||||
cargo build --release --target "$target"
|
||||
echo "Cleaning target directory..."
|
||||
rm -rf target
|
||||
|
||||
# Work out the produced binary name (Windows targets get a .exe suffix).
|
||||
case "$target" in
|
||||
*windows*) src="target/$target/release/${BIN_NAME}.exe" ;;
|
||||
*) src="target/$target/release/${BIN_NAME}" ;;
|
||||
esac
|
||||
|
||||
if [ ! -f "$src" ]; then
|
||||
echo " !! Expected binary not found: $src" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Friendly output name, e.g. unixtract-x86_64-pc-windows-gnu.exe
|
||||
case "$target" in
|
||||
*windows*) dst="$DIST_DIR/${BIN_NAME}-${target}.exe" ;;
|
||||
*) dst="$DIST_DIR/${BIN_NAME}-${target}" ;;
|
||||
esac
|
||||
|
||||
cp "$src" "$dst"
|
||||
echo " -> $dst"
|
||||
done
|
||||
|
||||
echo
|
||||
echo "==> Done. Binaries are in ./${DIST_DIR}"
|
||||
ls -la "$DIST_DIR"
|
||||
echo "Done. Binaries are in ./dist"
|
||||
Reference in New Issue
Block a user