Release #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| checks: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tag: ${{ steps.get_tag.outputs.tag }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check HEAD has a tag | |
| id: get_tag | |
| run: | | |
| TAG=$(git tag --points-at HEAD | head -n1) | |
| if [ -z "$TAG" ]; then | |
| echo "Error: HEAD commit has no tag. Please tag this commit before publishing." | |
| exit 1 | |
| fi | |
| echo "Found tag: $TAG" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| - name: Check tag matches Cargo.toml version | |
| run: | | |
| TAG="${{ steps.get_tag.outputs.tag }}" | |
| # Strip leading 'v' if present (v0.4.1 -> 0.4.1) | |
| VERSION="${TAG#v}" | |
| CARGO_VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/.*"\(.*\)".*/\1/') | |
| if [ "$VERSION" != "$CARGO_VERSION" ]; then | |
| echo "Error: Tag version ($VERSION) does not match Cargo.toml version ($CARGO_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Tag matches Cargo.toml version: $VERSION" | |
| - name: Check version not already on crates.io | |
| run: | | |
| TAG="${{ steps.get_tag.outputs.tag }}" | |
| # Strip leading 'v' if present (v0.4.1 -> 0.4.1) | |
| VERSION="${TAG#v}" | |
| echo "Checking if $VERSION exists on crates.io..." | |
| CRATE_NAME=$(grep -m1 '^name' Cargo.toml | sed 's/.*"\(.*\)".*/\1/') | |
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://crates.io/api/v1/crates/$CRATE_NAME/$VERSION") | |
| if [ "$HTTP_STATUS" = "200" ]; then | |
| echo "Error: Version $VERSION already exists on crates.io" | |
| exit 1 | |
| fi | |
| echo "Version $VERSION not yet published, proceeding." | |
| ci: | |
| needs: checks | |
| uses: ./.github/workflows/ci.yml | |
| ui-tests: | |
| needs: ci | |
| uses: ./.github/workflows/ui-tests.yml | |
| publish: | |
| needs: ui-tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install packages needed for build | |
| run: sudo apt-get update && sudo apt-get install -y build-essential libgtksourceview-5-dev | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Publish to crates.io | |
| run: cargo publish | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| create-release: | |
| needs: [checks, publish] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Create GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="${{ needs.checks.outputs.tag }}" | |
| gh release create "$TAG" --title "$TAG" --generate-notes | |
| appimage: | |
| needs: [checks, create-release] | |
| strategy: | |
| matrix: | |
| include: | |
| - runner: ubuntu-24.04 | |
| arch: x86_64 | |
| - runner: ubuntu-24.04-arm | |
| arch: aarch64 | |
| runs-on: ${{ matrix.runner }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install packages needed for build | |
| run: sudo apt-get update && sudo apt-get install -y build-essential libgtksourceview-5-dev librsvg2-bin libfuse2 | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Build release binary | |
| run: cargo build --release | |
| - name: Convert SVG icon to PNG | |
| run: rsvg-convert -w 256 -h 256 assets/mergers.svg -o mergers.png | |
| - name: Download appimagetool | |
| run: | | |
| curl -fsSL -o appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${{ matrix.arch }}.AppImage | |
| chmod +x appimagetool | |
| - name: Build AppImage | |
| run: | | |
| mkdir -p AppDir/usr/bin | |
| cp target/release/mergers AppDir/usr/bin/mergers | |
| cp assets/mergers.desktop AppDir/mergers.desktop | |
| cp mergers.png AppDir/mergers.png | |
| ln -s usr/bin/mergers AppDir/AppRun | |
| ./appimagetool --appimage-extract-and-run AppDir mergers-${{ matrix.arch }}.AppImage | |
| - name: Upload AppImage to GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="${{ needs.checks.outputs.tag }}" | |
| gh release upload "$TAG" mergers-${{ matrix.arch }}.AppImage --clobber | |
| macos: | |
| needs: [checks, create-release] | |
| strategy: | |
| matrix: | |
| include: | |
| - runner: macos-latest | |
| arch: aarch64 | |
| - runner: macos-15-intel | |
| arch: x86_64 | |
| runs-on: ${{ matrix.runner }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install dependencies | |
| run: brew install gtk4 gtksourceview5 | |
| - name: Install Rust | |
| uses: actions-rust-lang/setup-rust-toolchain@v1 | |
| - name: Build release binary | |
| run: cargo build --release | |
| - name: Create tarball | |
| run: tar -czf mergers-darwin-${{ matrix.arch }}.tar.gz -C target/release mergers | |
| - name: Upload to GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="${{ needs.checks.outputs.tag }}" | |
| gh release upload "$TAG" mergers-darwin-${{ matrix.arch }}.tar.gz --clobber | |
| windows: | |
| needs: [checks, create-release] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - runner: windows-latest | |
| msystem: UCRT64 | |
| package_prefix: mingw-w64-ucrt-x86_64 | |
| rust_target: x86_64-pc-windows-gnu | |
| cargo_target_flag: "--target x86_64-pc-windows-gnu" | |
| binary_path: target/x86_64-pc-windows-gnu/release/mergers.exe | |
| arch: x86_64 | |
| - runner: windows-11-arm | |
| msystem: CLANGARM64 | |
| package_prefix: mingw-w64-clang-aarch64 | |
| rust_target: aarch64-pc-windows-gnullvm | |
| cargo_target_flag: "--target aarch64-pc-windows-gnullvm" | |
| binary_path: target/aarch64-pc-windows-gnullvm/release/mergers.exe | |
| arch: aarch64 | |
| runs-on: ${{ matrix.runner }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Setup MSYS2 | |
| uses: msys2/setup-msys2@v2 | |
| with: | |
| msystem: ${{ matrix.msystem }} | |
| update: true | |
| - name: Set MSYS2 mirror for ARM64 | |
| if: matrix.msystem == 'CLANGARM64' | |
| shell: msys2 {0} | |
| run: | | |
| echo 'Server = https://repo.msys2.org/mingw/$repo/' > /etc/pacman.d/mirrorlist.mingw | |
| - name: Install MSYS2 packages (UCRT64) | |
| if: matrix.msystem == 'UCRT64' | |
| shell: msys2 {0} | |
| run: | | |
| pacman -S --noconfirm ${{ matrix.package_prefix }}-gtk4 ${{ matrix.package_prefix }}-gtksourceview5 ${{ matrix.package_prefix }}-pkgconf ${{ matrix.package_prefix }}-gcc | |
| - name: Install MSYS2 packages (CLANGARM64) | |
| if: matrix.msystem == 'CLANGARM64' | |
| shell: msys2 {0} | |
| run: | | |
| pacman -S --noconfirm ${{ matrix.package_prefix }}-gtk4 ${{ matrix.package_prefix }}-gtksourceview5 ${{ matrix.package_prefix }}-pkgconf ${{ matrix.package_prefix }}-clang | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust | |
| shell: msys2 {0} | |
| run: | | |
| export CARGO_HOME="$(pwd)/.cargo" | |
| export RUSTUP_HOME="$(pwd)/.rustup" | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable | |
| export PATH="$(pwd)/.cargo/bin:$PATH" | |
| rustup target add ${{ matrix.rust_target }} | |
| - name: Configure cargo linker | |
| shell: msys2 {0} | |
| run: | | |
| mkdir -p .cargo | |
| printf '[target.x86_64-pc-windows-gnu]\nlinker = "gcc"\n[target.aarch64-pc-windows-gnullvm]\nlinker = "clang"\n' > .cargo/config.toml | |
| - name: Build release binary | |
| shell: msys2 {0} | |
| run: | | |
| export CARGO_HOME="$(pwd)/.cargo" | |
| export RUSTUP_HOME="$(pwd)/.rustup" | |
| # Use only MSYS2 paths to avoid picking up link.exe from Visual Studio | |
| export PATH="$(pwd)/.cargo/bin:/$MSYSTEM/bin:/usr/bin" | |
| export PKG_CONFIG_ALLOW_CROSS=1 | |
| cargo build --release ${{ matrix.cargo_target_flag }} | |
| - name: Bundle binary with DLLs | |
| shell: msys2 {0} | |
| run: | | |
| mkdir -p dist | |
| cp ${{ matrix.binary_path }} dist/ | |
| # Copy all required DLLs from MSYS2 | |
| ldd ${{ matrix.binary_path }} | grep -i "$MSYSTEM" | awk '{print $3}' | xargs -I{} cp {} dist/ | |
| # Copy GtkSourceView language specs and styles | |
| mkdir -p dist/share | |
| cp -r /$MSYSTEM/share/gtksourceview-5 dist/share/gtksourceview-5 | |
| # Copy GTK schema files | |
| mkdir -p dist/share/glib-2.0/schemas | |
| cp /$MSYSTEM/share/glib-2.0/schemas/gschemas.compiled dist/share/glib-2.0/schemas/ | |
| # Copy icon theme | |
| mkdir -p dist/share/icons | |
| cp -r /$MSYSTEM/share/icons/hicolor dist/share/icons/ | |
| cp -r /$MSYSTEM/share/icons/Adwaita dist/share/icons/ 2>/dev/null || true | |
| - name: Create zip | |
| shell: pwsh | |
| run: Compress-Archive -Path dist\* -DestinationPath mergers-windows-${{ matrix.arch }}.zip | |
| - name: Upload to GitHub release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| TAG="${{ needs.checks.outputs.tag }}" | |
| gh release upload "$TAG" mergers-windows-${{ matrix.arch }}.zip --clobber | |
| aur: | |
| needs: [checks, appimage] | |
| runs-on: ubuntu-latest | |
| container: archlinux:base-devel | |
| steps: | |
| - name: Install dependencies | |
| run: pacman -Sy --noconfirm git openssh | |
| - name: Setup SSH | |
| env: | |
| AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }} | |
| run: | | |
| mkdir -p -m 700 /root/.ssh | |
| echo "$AUR_SSH_KEY" > /root/.ssh/aur | |
| chmod 600 /root/.ssh/aur | |
| ssh-keyscan aur.archlinux.org >> /root/.ssh/known_hosts | |
| - name: Clone AUR repo | |
| run: GIT_SSH_COMMAND="ssh -i /root/.ssh/aur" git clone ssh://aur@aur.archlinux.org/mergers.git aur-repo | |
| - name: Update PKGBUILD | |
| run: | | |
| TAG="${{ needs.checks.outputs.tag }}" | |
| VERSION="${TAG#v}" | |
| SHA=$(curl -sL "https://github.com/joske/mergers/archive/refs/tags/${TAG}.tar.gz" | sha256sum | cut -d' ' -f1) | |
| cd aur-repo | |
| sed -i "s/^pkgver=.*/pkgver=${VERSION}/" PKGBUILD | |
| sed -i "s/^pkgrel=.*/pkgrel=1/" PKGBUILD | |
| sed -i "s/^sha256sums=.*/sha256sums=('${SHA}')/" PKGBUILD | |
| - name: Generate .SRCINFO | |
| run: | | |
| cd aur-repo | |
| useradd -m builder | |
| chown -R builder:builder . | |
| su builder -c "makepkg --printsrcinfo > .SRCINFO" | |
| - name: Commit and push | |
| run: | | |
| cd aur-repo | |
| chown -R root:root . | |
| git config user.name "Jos Dehaes" | |
| git config user.email "jos.dehaes@gmail.com" | |
| git add PKGBUILD .SRCINFO | |
| git diff-index --quiet HEAD || { git commit -m "Update to ${{ needs.checks.outputs.tag }}" && GIT_SSH_COMMAND="ssh -i /root/.ssh/aur" git push; } | |
| - name: Cleanup SSH key | |
| if: always() | |
| run: rm -f /root/.ssh/aur | |
| homebrew: | |
| needs: [checks, macos] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Determine version | |
| id: version | |
| run: | | |
| TAG="${{ needs.checks.outputs.tag }}" | |
| VERSION="${TAG#v}" | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Compute SHA256 checksum | |
| id: sha | |
| run: | | |
| TAG="${{ steps.version.outputs.tag }}" | |
| URL="https://github.com/joske/mergers/releases/download/${TAG}/mergers-darwin-aarch64.tar.gz" | |
| SHA=$(curl -sL "$URL" | shasum -a 256 | cut -d' ' -f1) | |
| echo "sha=$SHA" >> "$GITHUB_OUTPUT" | |
| - name: Checkout tap repository | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: joske/homebrew-mergers | |
| token: ${{ secrets.HOMEBREW_TAP_TOKEN }} | |
| - name: Update formula | |
| env: | |
| VERSION: ${{ steps.version.outputs.version }} | |
| TAG: ${{ steps.version.outputs.tag }} | |
| SHA: ${{ steps.sha.outputs.sha }} | |
| run: | | |
| cat > Formula/mergers.rb << EOF | |
| class Mergers < Formula | |
| desc "Visual diff and merge tool written in Rust with GTK4" | |
| homepage "https://github.com/joske/mergers" | |
| version "${VERSION}" | |
| license "GPL-2.0-only" | |
| url "https://github.com/joske/mergers/releases/download/${TAG}/mergers-darwin-aarch64.tar.gz" | |
| sha256 "${SHA}" | |
| depends_on :macos | |
| depends_on "adwaita-icon-theme" | |
| depends_on "gtk4" | |
| depends_on "gtksourceview5" | |
| def install | |
| bin.install "mergers" | |
| end | |
| test do | |
| assert_match version.to_s, shell_output("\#{bin}/mergers --version") | |
| end | |
| end | |
| EOF | |
| - name: Commit and push | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add Formula/mergers.rb | |
| git commit -m "Update mergers to ${{ steps.version.outputs.tag }}" | |
| git push |