From 5abbcc79008efc99614410a306d24bc71b8831a3 Mon Sep 17 00:00:00 2001 From: Amin Atabiev Date: Sun, 11 Oct 2026 13:43:26 +0300 Subject: [PATCH 1/4] ci: build Linux and Windows on GitHub-hosted runners - add Linux build (tar.gz + AppImage) for x86_64 and arm64 - cross-compile Windows build with MinGW on Linux runner - move CI and release creation off the self-hosted runner - allow manual release dry run via workflow_dispatch --- .cargo/config.toml | 4 + .github/workflows/ci.yml | 66 ++++++---- .github/workflows/release.yml | 173 +++++++++++++++++++-------- Makefile | 5 +- README.md | 19 ++- assets/linux/commit-rewriter.desktop | 8 ++ assets/linux/commit-rewriter.svg | 8 ++ scripts/build-linux.sh | 172 ++++++++++++++++++++++++++ scripts/build-windows.sh | 33 ++++- 9 files changed, 403 insertions(+), 85 deletions(-) create mode 100644 assets/linux/commit-rewriter.desktop create mode 100644 assets/linux/commit-rewriter.svg create mode 100755 scripts/build-linux.sh diff --git a/.cargo/config.toml b/.cargo/config.toml index 856a365..0e04ae8 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,7 @@ [target.x86_64-pc-windows-gnu] linker = "x86_64-w64-mingw32-gcc" rustflags = ["-C", "link-arg=-Wl,--subsystem,windows"] + +# Link the C runtime statically so the .exe runs without Visual C++ Redistributable +[target.x86_64-pc-windows-msvc] +rustflags = ["-C", "target-feature=+crt-static"] diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a77d95..617b545 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,47 +11,67 @@ env: RUST_BACKTRACE: 1 jobs: - # Quick compilation check - check: - name: Check Compilation - runs-on: self-hosted - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Rust - run: | - rustup component add rustfmt || true - rustc --version - cargo --version - - - name: Check code compiles - run: cargo check --all-targets - # Formatting check fmt: name: Check Formatting - runs-on: self-hosted + runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Setup Rust - run: rustup component add rustfmt || true + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt - name: Check formatting run: cargo fmt -- --check - # Tests + # Compilation and tests on Linux test: - name: Run Tests - runs-on: self-hosted + name: Test (Linux) + runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4 + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential pkg-config libgtk-3-dev libssl-dev + - name: Setup Rust - run: rustc --version && cargo --version + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + + - name: Check code compiles + run: cargo check --all-targets - name: Run tests run: cargo test --verbose --all-targets + + # Windows cross-compilation check (same toolchain as release builds) + windows: + name: Check Windows Build + runs-on: ubuntu-22.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install MinGW + run: | + sudo apt-get update + sudo apt-get install -y gcc-mingw-w64-x86-64 + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-gnu + + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + + - name: Build for Windows + run: cargo build --release --target x86_64-pc-windows-gnu diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9c36a7..6eb28ed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,7 @@ on: push: tags: - 'v*.*.*' # Only semantic versions: v1.0.0, v2.1.3, etc. + workflow_dispatch: # Manual dry run: builds artifacts without creating a release env: CARGO_TERM_COLOR: always @@ -20,7 +21,11 @@ jobs: - name: Get version from tag id: version run: | - VERSION=${GITHUB_REF#refs/tags/v} + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + else + VERSION=$(grep -m 1 "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/' | tr -d ' ') + fi echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Building version: $VERSION" @@ -59,10 +64,10 @@ jobs: path: ${{ steps.verify_dmg.outputs.DMG_FILE }} retention-days: 7 - # Build Windows EXE + # Build Windows EXE (cross-compiled with MinGW on GitHub-hosted Linux runner) build-windows: name: Build Windows EXE - runs-on: self-hosted + runs-on: ubuntu-22.04 steps: - name: Checkout code uses: actions/checkout@v4 @@ -70,89 +75,128 @@ jobs: - name: Get version from tag id: version run: | - VERSION=${GITHUB_REF#refs/tags/v} - echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - echo "Building version: $VERSION" - - - name: Setup Rust - run: rustc --version && cargo --version - - - name: Install MinGW for cross-compilation - run: | - if ! command -v x86_64-w64-mingw32-gcc &> /dev/null; then - echo "Installing MinGW..." - if command -v brew &> /dev/null; then - brew install mingw-w64 || { - echo "⚠️ Warning: Failed to install MinGW via Homebrew" - echo "Cross-compilation may fail. Install manually: brew install mingw-w64" - } - else - echo "⚠️ Warning: Homebrew not found. Install MinGW manually." - fi + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} else - echo "✅ MinGW already installed" - x86_64-w64-mingw32-gcc --version + VERSION=$(grep -m 1 "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/' | tr -d ' ') fi + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "Building version: $VERSION" - - name: Setup Rust Windows target + - name: Install MinGW run: | - rustup target add x86_64-pc-windows-gnu || true - rustup target list --installed | grep windows || echo "⚠️ Windows target not installed" + sudo apt-get update + sudo apt-get install -y gcc-mingw-w64-x86-64 zip - - name: Configure cross-compilation - run: | - mkdir -p .cargo - cat > .cargo/config.toml << EOF - [target.x86_64-pc-windows-gnu] - linker = "x86_64-w64-mingw32-gcc" - EOF - echo "✅ Cross-compilation configured" + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-pc-windows-gnu - - name: Make scripts executable - run: chmod +x scripts/*.sh + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 - name: Build Windows EXE run: ./scripts/build-windows.sh env: VERSION: ${{ steps.version.outputs.VERSION }} - continue-on-error: true - name: Verify Windows ZIP file id: verify_zip run: | ZIP_FILE=$(find releases -name "*windows-portable.zip" -type f | head -1) - if [ -z "$ZIP_FILE" ]; then - echo "⚠️ Warning: Windows ZIP file not found" - echo "This may be due to missing MinGW or cross-compilation failure" - echo "ZIP_FILE=" >> $GITHUB_OUTPUT - exit 0 # Don't fail the job, but mark as optional + if [ -z "$ZIP_FILE" ] || [ ! -s "$ZIP_FILE" ]; then + echo "❌ Error: Windows ZIP file not found or empty" + exit 1 fi echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_OUTPUT echo "✅ Windows ZIP file found: $ZIP_FILE" ls -lh "$ZIP_FILE" - if [ ! -s "$ZIP_FILE" ]; then - echo "❌ Error: ZIP file is empty" - exit 1 - fi - name: Upload Windows ZIP artifact - if: steps.verify_zip.outputs.ZIP_FILE != '' uses: actions/upload-artifact@v4 with: name: windows-exe path: ${{ steps.verify_zip.outputs.ZIP_FILE }} retention-days: 7 + # Build Linux tarball and AppImage (native, GitHub-hosted runners) + build-linux: + name: Build Linux (${{ matrix.arch }}) + runs-on: ${{ matrix.runner }} + strategy: + fail-fast: false + matrix: + include: + - arch: x86_64 + runner: ubuntu-22.04 + - arch: arm64 + runner: ubuntu-22.04-arm + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Get version from tag + id: version + run: | + if [[ "$GITHUB_REF" == refs/tags/v* ]]; then + VERSION=${GITHUB_REF#refs/tags/v} + else + VERSION=$(grep -m 1 "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/' | tr -d ' ') + fi + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT + echo "Building version: $VERSION" + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y build-essential pkg-config libgtk-3-dev libssl-dev + + - name: Setup Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + + - name: Build Linux packages + run: ./scripts/build-linux.sh + env: + VERSION: ${{ steps.version.outputs.VERSION }} + + - name: Verify Linux files + run: | + for PATTERN in "*linux-${{ matrix.arch }}.tar.gz" "*linux-${{ matrix.arch }}.AppImage"; do + FILE=$(find releases -name "$PATTERN" -type f | head -1) + if [ -z "$FILE" ] || [ ! -s "$FILE" ]; then + echo "❌ Error: $PATTERN not found or empty" + exit 1 + fi + echo "✅ Found: $FILE" + ls -lh "$FILE" + done + + - name: Upload Linux artifacts + uses: actions/upload-artifact@v4 + with: + name: linux-${{ matrix.arch }} + path: | + releases/*.tar.gz + releases/*.AppImage + retention-days: 7 + # Create GitHub Release create-release: name: Create GitHub Release - runs-on: self-hosted - needs: [build-macos, build-windows] + runs-on: ubuntu-latest + needs: [build-macos, build-windows, build-linux] + if: startsWith(github.ref, 'refs/tags/v') permissions: contents: write steps: - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Get version from tag id: version @@ -172,13 +216,20 @@ jobs: with: name: windows-exe path: artifacts/ - continue-on-error: true + + - name: Download Linux artifacts + uses: actions/download-artifact@v4 + with: + pattern: linux-* + path: artifacts/ + merge-multiple: true - name: Prepare release files id: prepare_files run: | DMG_FILE=$(find artifacts -name "*.dmg" -type f | head -1) ZIP_FILE=$(find artifacts -name "*.zip" -type f | head -1) + LINUX_FILES=$(find artifacts \( -name "*linux-*.tar.gz" -o -name "*linux-*.AppImage" \) -type f | sort | tr '\n' ' ') if [ -z "$DMG_FILE" ]; then echo "❌ Error: DMG file not found in artifacts" @@ -195,8 +246,11 @@ jobs: ls -lh "$ZIP_FILE" else echo "ZIP_FILE=" >> $GITHUB_OUTPUT - echo "⚠️ Windows ZIP not available (cross-compilation may have failed)" + echo "⚠️ Windows ZIP not available" fi + + echo "LINUX_FILES=$LINUX_FILES" >> $GITHUB_OUTPUT + echo "✅ Linux: $LINUX_FILES" - name: Generate release notes id: release_notes @@ -216,7 +270,9 @@ jobs: ## Downloads - **macOS (Apple Silicon)**: [commit-rewriter-$VERSION-macos-arm64.dmg](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-macos-arm64.dmg) - $([ -n "${{ steps.prepare_files.outputs.ZIP_FILE }}" ] && echo "- **Windows**: [commit-rewriter-$VERSION-windows-portable.zip](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-windows-portable.zip)" || echo "- **Windows**: Not available (cross-compilation failed)") + $([ -n "${{ steps.prepare_files.outputs.ZIP_FILE }}" ] && echo "- **Windows**: [commit-rewriter-$VERSION-windows-portable.zip](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-windows-portable.zip)" || echo "- **Windows**: Not available") + - **Linux (x86_64)**: [AppImage](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-x86_64.AppImage) · [tar.gz](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-x86_64.tar.gz) + - **Linux (ARM64)**: [AppImage](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-arm64.AppImage) · [tar.gz](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-arm64.tar.gz) ## Installation @@ -234,6 +290,13 @@ jobs: 2. Extract the archive 3. Run \`Git Commit Rewriter.exe\` + ### Linux + 1. Download the AppImage for your architecture + 2. Make it executable: \`chmod +x commit-rewriter-$VERSION-linux-*.AppImage\` + 3. Run it: \`./commit-rewriter-$VERSION-linux-*.AppImage\` + + Or extract the tar.gz and run \`commit-rewriter\` (requires GTK 3). + --- **Full Changelog**: $CHANGELOG_URL @@ -245,6 +308,7 @@ jobs: VERSION="${{ steps.version.outputs.VERSION }}" DMG_FILE="${{ steps.prepare_files.outputs.DMG_FILE }}" ZIP_FILE="${{ steps.prepare_files.outputs.ZIP_FILE }}" + LINUX_FILES="${{ steps.prepare_files.outputs.LINUX_FILES }}" # Prepare files list for upload FILES_TO_UPLOAD=() @@ -254,6 +318,9 @@ jobs: if [ -n "$ZIP_FILE" ] && [ -f "$ZIP_FILE" ]; then FILES_TO_UPLOAD+=("$ZIP_FILE") fi + for FILE in $LINUX_FILES; do + FILES_TO_UPLOAD+=("$FILE") + done if [ ${#FILES_TO_UPLOAD[@]} -eq 0 ]; then echo "❌ Error: No files to upload" diff --git a/Makefile b/Makefile index 1614887..e776721 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # Git Commit Rewriter - Makefile # Use `make help` to list available commands -.PHONY: help build clean test install macos-app windows-portable +.PHONY: help build clean test install macos-app windows-portable linux # Variables PROJECT = commit-rewriter @@ -52,6 +52,9 @@ macos-app: ## Create .app and .dmg for macOS (auto-detect architecture) windows-portable: ## Create portable Windows .exe without console (cross-compilation) @./scripts/build-windows.sh +linux: ## Create .tar.gz and .AppImage for Linux (native build, host architecture) + @./scripts/build-linux.sh + # Dependency check check-deps: ## Check system dependencies @echo "$(GREEN)Checking dependencies...$(NC)" diff --git a/README.md b/README.md index 101623f..8527685 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Rust](https://img.shields.io/badge/rust-1.70%2B-orange.svg)](https://www.rust-lang.org/) -[![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Windows-lightgrey.svg)](https://github.com/atabits/commit-rewriter) +[![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-lightgrey.svg)](https://github.com/atabits/commit-rewriter) > **Edit Git commit messages the easy way** — A beautiful, fast GUI app built with Rust @@ -18,7 +18,7 @@ - **🔍 Smart Search** — Find commits instantly by message, hash, or author - **🛡️ Safe by Default** — Automatic backups before any changes - **🔄 Easy Rollback** — Undo changes with a single click -- **🌐 Cross-Platform** — Works on macOS and Windows +- **🌐 Cross-Platform** — Works on macOS, Linux, and Windows --- @@ -37,7 +37,7 @@ The app will be ready in `target/release/commit-rewriter` ✨ ### Install Globally ```bash -# macOS +# macOS / Linux sudo cp target/release/commit-rewriter /usr/local/bin/ # Now run from anywhere @@ -99,6 +99,19 @@ cargo build --release --target aarch64-apple-darwin # Windows cargo build --release --target x86_64-pc-windows-gnu + +# Linux (.tar.gz + .AppImage, run on Linux) +make linux +``` + +On Linux, building requires GTK 3 development headers (used for the folder picker): + +```bash +# Debian / Ubuntu +sudo apt install build-essential pkg-config libgtk-3-dev libssl-dev + +# Arch +sudo pacman -S base-devel pkgconf gtk3 openssl ``` --- diff --git a/assets/linux/commit-rewriter.desktop b/assets/linux/commit-rewriter.desktop new file mode 100644 index 0000000..fa2e953 --- /dev/null +++ b/assets/linux/commit-rewriter.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Type=Application +Name=Git Commit Rewriter +Comment=Edit Git commit messages with a GUI +Exec=commit-rewriter +Icon=commit-rewriter +Categories=Development;RevisionControl; +Terminal=false diff --git a/assets/linux/commit-rewriter.svg b/assets/linux/commit-rewriter.svg new file mode 100644 index 0000000..ec78f73 --- /dev/null +++ b/assets/linux/commit-rewriter.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/scripts/build-linux.sh b/scripts/build-linux.sh new file mode 100755 index 0000000..4e0d739 --- /dev/null +++ b/scripts/build-linux.sh @@ -0,0 +1,172 @@ +#!/bin/bash + +# Script to build Linux tarball and AppImage +# Usage: ./build-linux.sh +# +# Builds natively for the host architecture (x86_64 or arm64). +# Cross-compilation is not supported: run on a Linux machine or runner. + +set -e + +PROJECT_NAME="commit-rewriter" +APP_NAME="Git Commit Rewriter" + +# Determine project root +if [ -f "Cargo.toml" ]; then + PROJECT_ROOT="." +elif [ -f "../Cargo.toml" ]; then + PROJECT_ROOT=".." + cd "$PROJECT_ROOT" +else + echo "Error: Cannot find Cargo.toml" + exit 1 +fi + +# Get version from environment variable or Cargo.toml +if [ -z "$VERSION" ]; then + VERSION=$(grep -m 1 "^version" Cargo.toml | sed 's/version = "\(.*\)"/\1/' | tr -d ' ') +fi + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +info() { + echo -e "${GREEN}[INFO]${NC} $1" +} + +warn() { + echo -e "${YELLOW}[WARN]${NC} $1" +} + +error() { + echo -e "${RED}[ERROR]${NC} $1" +} + +if [ "$(uname -s)" != "Linux" ]; then + error "This script must be run on Linux (cross-compilation is not supported)" + exit 1 +fi + +# Detect architecture +case "$(uname -m)" in + x86_64) + ARCH_NAME="x86_64" + ;; + aarch64|arm64) + ARCH_NAME="arm64" + ;; + *) + error "Unsupported architecture: $(uname -m)" + exit 1 + ;; +esac + +# appimagetool uses its own architecture naming +if [ "$ARCH_NAME" = "arm64" ]; then + APPIMAGE_ARCH="aarch64" +else + APPIMAGE_ARCH="x86_64" +fi + +info "Building for Linux ($ARCH_NAME), version $VERSION..." + +# Check Rust +if ! command -v cargo &> /dev/null; then + error "Rust is not installed! Install via rustup: https://rustup.rs/" + exit 1 +fi + +info "Rust version: $(rustc --version)" + +# Build project +info "Compiling project..." +cargo build --release + +BINARY_PATH="target/release/${PROJECT_NAME}" +DIST_DIR="releases" +BASE_NAME="${PROJECT_NAME}-${VERSION}-linux-${ARCH_NAME}" +TARBALL_NAME="${BASE_NAME}.tar.gz" +APPIMAGE_NAME="${BASE_NAME}.AppImage" + +if [ ! -f "$BINARY_PATH" ]; then + error "Binary not found: $BINARY_PATH" + exit 1 +fi + +info "✅ Build completed: $BINARY_PATH" + +mkdir -p "$DIST_DIR" +WORK_DIR=$(mktemp -d) +trap 'rm -rf "$WORK_DIR"' EXIT + +# Create tarball +info "Creating tarball..." +TAR_ROOT="$WORK_DIR/$BASE_NAME" +mkdir -p "$TAR_ROOT" +cp "$BINARY_PATH" "$TAR_ROOT/" +cp assets/linux/${PROJECT_NAME}.desktop "$TAR_ROOT/" +cp assets/linux/${PROJECT_NAME}.svg "$TAR_ROOT/" +cp LICENSE README.md "$TAR_ROOT/" +tar -czf "$DIST_DIR/$TARBALL_NAME" -C "$WORK_DIR" "$BASE_NAME" + +info "✅ Tarball created: $DIST_DIR/$TARBALL_NAME" + +# Create AppDir structure +info "Creating AppImage structure..." +APPDIR="$WORK_DIR/AppDir" +mkdir -p "$APPDIR/usr/bin" +mkdir -p "$APPDIR/usr/share/applications" +mkdir -p "$APPDIR/usr/share/icons/hicolor/scalable/apps" + +cp "$BINARY_PATH" "$APPDIR/usr/bin/${PROJECT_NAME}" +chmod +x "$APPDIR/usr/bin/${PROJECT_NAME}" + +cat > "$APPDIR/AppRun" << 'EOF' +#!/bin/sh +HERE="$(dirname "$(readlink -f "${0}")")" +exec "${HERE}/usr/bin/commit-rewriter" "$@" +EOF +chmod +x "$APPDIR/AppRun" + +cp assets/linux/${PROJECT_NAME}.desktop "$APPDIR/" +cp assets/linux/${PROJECT_NAME}.desktop "$APPDIR/usr/share/applications/" +cp assets/linux/${PROJECT_NAME}.svg "$APPDIR/" +cp assets/linux/${PROJECT_NAME}.svg "$APPDIR/usr/share/icons/hicolor/scalable/apps/" + +# Find or download appimagetool +APPIMAGETOOL="appimagetool" +if ! command -v "$APPIMAGETOOL" &> /dev/null; then + info "Downloading appimagetool..." + APPIMAGETOOL_URL="https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${APPIMAGE_ARCH}.AppImage" + APPIMAGETOOL="$WORK_DIR/appimagetool.AppImage" + + if ! curl -fsSL "$APPIMAGETOOL_URL" -o "$APPIMAGETOOL"; then + error "Failed to download appimagetool from $APPIMAGETOOL_URL" + error "Install appimagetool manually and make sure it is in PATH" + exit 1 + fi + + chmod +x "$APPIMAGETOOL" +fi + +# Allow running without FUSE (e.g. in CI containers) +export APPIMAGE_EXTRACT_AND_RUN=1 + +info "Creating AppImage..." +ARCH="$APPIMAGE_ARCH" "$APPIMAGETOOL" --no-appstream "$APPDIR" "$DIST_DIR/$APPIMAGE_NAME" +chmod +x "$DIST_DIR/$APPIMAGE_NAME" + +info "✅ AppImage created: $DIST_DIR/$APPIMAGE_NAME" + +info "File sizes:" +ls -lh "$BINARY_PATH" | awk '{print $5, $9}' +ls -lh "$DIST_DIR/$TARBALL_NAME" | awk '{print $5, $9}' +ls -lh "$DIST_DIR/$APPIMAGE_NAME" | awk '{print $5, $9}' + +info "" +info "🎉 Done! Files created:" +info " - $DIST_DIR/$TARBALL_NAME" +info " - $DIST_DIR/$APPIMAGE_NAME" diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh index 2f721a8..881d35a 100755 --- a/scripts/build-windows.sh +++ b/scripts/build-windows.sh @@ -1,13 +1,26 @@ #!/bin/bash -# Script to create .exe and archive for Windows (cross-compilation from macOS) +# Script to create .exe and archive for Windows # Usage: ./build-windows.sh +# +# On Windows (Git Bash) builds natively with the MSVC toolchain. +# On macOS/Linux cross-compiles with MinGW (x86_64-pc-windows-gnu). set -e PROJECT_NAME="commit-rewriter" APP_NAME="Git Commit Rewriter" -TARGET="x86_64-pc-windows-gnu" + +case "$OSTYPE" in + msys*|cygwin*|win32*) + NATIVE_WINDOWS=1 + TARGET="x86_64-pc-windows-msvc" + ;; + *) + NATIVE_WINDOWS=0 + TARGET="x86_64-pc-windows-gnu" + ;; +esac # Determine project root if [ -f "Cargo.toml" ]; then @@ -49,7 +62,11 @@ error() { echo -e "${RED}[ERROR]${NC} $1" } -info "Building for Windows (cross-compilation)..." +if [ "$NATIVE_WINDOWS" = "1" ]; then + info "Building for Windows (native, $TARGET)..." +else + info "Building for Windows (cross-compilation, $TARGET)..." +fi # Check Rust if ! command -v rustc &> /dev/null; then @@ -124,7 +141,6 @@ Installation: Requirements: ------------- - Windows 10 or newer -- Visual C++ Redistributable (usually already installed) Usage: ------ @@ -142,7 +158,14 @@ info "Creating ZIP archive..." mkdir -p "$DIST_DIR" ORIGINAL_DIR=$(pwd) cd "$TEMP_DIR" -zip -r "$ORIGINAL_DIR/$DIST_DIR/$ZIP_NAME" . > /dev/null +if command -v zip &> /dev/null; then + zip -r "$ORIGINAL_DIR/$DIST_DIR/$ZIP_NAME" . > /dev/null +elif command -v 7z &> /dev/null; then + 7z a -tzip "$ORIGINAL_DIR/$DIST_DIR/$ZIP_NAME" . > /dev/null +else + error "Neither zip nor 7z found" + exit 1 +fi cd "$ORIGINAL_DIR" # Cleanup temporary directory From 0da94f3c54b3bfce50a82a326e5b7d40a8a8da82 Mon Sep 17 00:00:00 2001 From: Amin Atabiev Date: Sun, 11 Oct 2026 13:44:43 +0300 Subject: [PATCH 2/4] ci: retrigger checks From 2673a45c7e65f6f305b1dffecdd5b24071875e54 Mon Sep 17 00:00:00 2001 From: Amin Atabiev Date: Sun, 11 Oct 2026 13:46:38 +0300 Subject: [PATCH 3/4] ci: build macOS DMG on GitHub-hosted runner for arm64 and x86_64 --- .github/workflows/release.yml | 55 ++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6eb28ed..a85690d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,10 +10,18 @@ env: CARGO_TERM_COLOR: always jobs: - # Build macOS DMG + # Build macOS DMG (GitHub-hosted Apple Silicon runner, Intel cross-compiled) build-macos: - name: Build macOS DMG - runs-on: self-hosted + name: Build macOS DMG (${{ matrix.arch }}) + runs-on: macos-14 + strategy: + fail-fast: false + matrix: + include: + - arch: arm64 + target: aarch64-apple-darwin + - arch: x86_64 + target: x86_64-apple-darwin steps: - name: Checkout code uses: actions/checkout@v4 @@ -30,20 +38,24 @@ jobs: echo "Building version: $VERSION" - name: Setup Rust - run: rustc --version && cargo --version + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} - - name: Make scripts executable - run: chmod +x scripts/*.sh + - name: Cache Rust build + uses: Swatinem/rust-cache@v2 + with: + key: ${{ matrix.target }} - name: Build macOS DMG - run: ./scripts/build-macos-app.sh arm64 + run: ./scripts/build-macos-app.sh ${{ matrix.arch }} env: VERSION: ${{ steps.version.outputs.VERSION }} - name: Verify DMG file id: verify_dmg run: | - DMG_FILE=$(find releases -name "*.dmg" -type f | head -1) + DMG_FILE=$(find releases -name "*macos-${{ matrix.arch }}.dmg" -type f | head -1) if [ -z "$DMG_FILE" ]; then echo "❌ Error: DMG file not found" exit 1 @@ -60,7 +72,7 @@ jobs: - name: Upload DMG artifact uses: actions/upload-artifact@v4 with: - name: macos-dmg + name: macos-dmg-${{ matrix.arch }} path: ${{ steps.verify_dmg.outputs.DMG_FILE }} retention-days: 7 @@ -205,11 +217,12 @@ jobs: echo "VERSION=$VERSION" >> $GITHUB_OUTPUT echo "Creating release for version: $VERSION" - - name: Download macOS DMG artifact + - name: Download macOS DMG artifacts uses: actions/download-artifact@v4 with: - name: macos-dmg + pattern: macos-dmg-* path: artifacts/ + merge-multiple: true - name: Download Windows ZIP artifact uses: actions/download-artifact@v4 @@ -227,18 +240,17 @@ jobs: - name: Prepare release files id: prepare_files run: | - DMG_FILE=$(find artifacts -name "*.dmg" -type f | head -1) + DMG_FILES=$(find artifacts -name "*.dmg" -type f | sort | tr '\n' ' ') ZIP_FILE=$(find artifacts -name "*.zip" -type f | head -1) LINUX_FILES=$(find artifacts \( -name "*linux-*.tar.gz" -o -name "*linux-*.AppImage" \) -type f | sort | tr '\n' ' ') - if [ -z "$DMG_FILE" ]; then - echo "❌ Error: DMG file not found in artifacts" + if [ -z "$DMG_FILES" ]; then + echo "❌ Error: DMG files not found in artifacts" exit 1 fi - echo "DMG_FILE=$DMG_FILE" >> $GITHUB_OUTPUT - echo "✅ DMG: $DMG_FILE" - ls -lh "$DMG_FILE" + echo "DMG_FILES=$DMG_FILES" >> $GITHUB_OUTPUT + echo "✅ DMG: $DMG_FILES" if [ -n "$ZIP_FILE" ]; then echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_OUTPUT @@ -270,6 +282,7 @@ jobs: ## Downloads - **macOS (Apple Silicon)**: [commit-rewriter-$VERSION-macos-arm64.dmg](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-macos-arm64.dmg) + - **macOS (Intel)**: [commit-rewriter-$VERSION-macos-x86_64.dmg](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-macos-x86_64.dmg) $([ -n "${{ steps.prepare_files.outputs.ZIP_FILE }}" ] && echo "- **Windows**: [commit-rewriter-$VERSION-windows-portable.zip](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-windows-portable.zip)" || echo "- **Windows**: Not available") - **Linux (x86_64)**: [AppImage](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-x86_64.AppImage) · [tar.gz](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-x86_64.tar.gz) - **Linux (ARM64)**: [AppImage](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-arm64.AppImage) · [tar.gz](https://github.com/${{ github.repository }}/releases/download/v$VERSION/commit-rewriter-$VERSION-linux-arm64.tar.gz) @@ -306,15 +319,15 @@ jobs: - name: Create GitHub Release run: | VERSION="${{ steps.version.outputs.VERSION }}" - DMG_FILE="${{ steps.prepare_files.outputs.DMG_FILE }}" + DMG_FILES="${{ steps.prepare_files.outputs.DMG_FILES }}" ZIP_FILE="${{ steps.prepare_files.outputs.ZIP_FILE }}" LINUX_FILES="${{ steps.prepare_files.outputs.LINUX_FILES }}" # Prepare files list for upload FILES_TO_UPLOAD=() - if [ -n "$DMG_FILE" ] && [ -f "$DMG_FILE" ]; then - FILES_TO_UPLOAD+=("$DMG_FILE") - fi + for FILE in $DMG_FILES; do + FILES_TO_UPLOAD+=("$FILE") + done if [ -n "$ZIP_FILE" ] && [ -f "$ZIP_FILE" ]; then FILES_TO_UPLOAD+=("$ZIP_FILE") fi From a0892abcb265e0a1d6f8fe63f396d251dc877bb3 Mon Sep 17 00:00:00 2001 From: Amin Atabiev Date: Sun, 11 Oct 2026 13:50:54 +0300 Subject: [PATCH 4/4] build: drop OpenSSL by disabling unused git2 network features git2 only reads local repositories, so https/ssh support is not needed. This fixes macOS x86_64 cross-compilation and removes the libssl runtime dependency from Linux builds. --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 617b545..b8c4b15 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y build-essential pkg-config libgtk-3-dev libssl-dev + sudo apt-get install -y build-essential pkg-config libgtk-3-dev - name: Setup Rust uses: dtolnay/rust-toolchain@stable diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a85690d..ea43d76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -162,7 +162,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y build-essential pkg-config libgtk-3-dev libssl-dev + sudo apt-get install -y build-essential pkg-config libgtk-3-dev - name: Setup Rust uses: dtolnay/rust-toolchain@stable diff --git a/Cargo.toml b/Cargo.toml index f195cf5..4f08ec9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT" [dependencies] eframe = "0.28" egui = "0.28" -git2 = { version = "0.19", features = ["vendored-libgit2"] } +git2 = { version = "0.19", default-features = false, features = ["vendored-libgit2"] } chrono = "0.4" rfd = "0.14" anyhow = "1.0" diff --git a/README.md b/README.md index 8527685..cb98c67 100644 --- a/README.md +++ b/README.md @@ -108,10 +108,10 @@ On Linux, building requires GTK 3 development headers (used for the folder picke ```bash # Debian / Ubuntu -sudo apt install build-essential pkg-config libgtk-3-dev libssl-dev +sudo apt install build-essential pkg-config libgtk-3-dev # Arch -sudo pacman -S base-devel pkgconf gtk3 openssl +sudo pacman -S base-devel pkgconf gtk3 ``` ---