oxidelta 0.1.4

VCDIFF (RFC 3284) delta encoder/decoder — Rust reimplementation of xdelta3
Documentation
name: release

on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    name: build-${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            exe_suffix: ""
          - os: ubuntu-latest
            target: aarch64-unknown-linux-gnu
            exe_suffix: ""
          - os: macos-latest
            target: x86_64-apple-darwin
            exe_suffix: ""
          - os: macos-latest
            target: aarch64-apple-darwin
            exe_suffix: ""
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            exe_suffix: ".exe"
          - os: windows-latest
            target: aarch64-pc-windows-msvc
            exe_suffix: ".exe"

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Build release binary
        shell: bash
        run: |
          set -euo pipefail
          if [ "${{ matrix.target }}" = "aarch64-unknown-linux-gnu" ]; then
            cargo install cross --locked
            cross build --release --bin oxidelta --target "${{ matrix.target }}"
          else
            cargo build --release --bin oxidelta --target "${{ matrix.target }}"
          fi

      - name: Package (Unix)
        if: runner.os != 'Windows'
        shell: bash
        run: |
          set -euo pipefail
          mkdir -p dist
          cp "target/${{ matrix.target }}/release/oxidelta" "dist/oxidelta-${{ matrix.target }}"

      - name: Package (Windows)
        if: runner.os == 'Windows'
        shell: pwsh
        run: |
          New-Item -ItemType Directory -Path dist -Force | Out-Null
          Copy-Item "target/${{ matrix.target }}/release/oxidelta${{ matrix.exe_suffix }}" "dist/oxidelta-${{ matrix.target }}${{ matrix.exe_suffix }}"

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: oxidelta-${{ matrix.target }}
          path: dist/*

  cargo-publish:
    if: startsWith(github.ref, 'refs/tags/v')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Validate tag matches Cargo.toml version
        shell: bash
        run: |
          set -euo pipefail
          tag_version="${GITHUB_REF_NAME#v}"
          cargo_version="$(sed -n 's/^version = "\(.*\)"$/\1/p' Cargo.toml | head -n 1)"
          if [ -z "$cargo_version" ]; then
            echo "Could not read package version from Cargo.toml"
            exit 1
          fi
          if [ "$tag_version" != "$cargo_version" ]; then
            echo "Tag version ($tag_version) does not match Cargo.toml version ($cargo_version)"
            exit 1
          fi

      - name: Publish crate to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --allow-dirty

  publish:
    if: startsWith(github.ref, 'refs/tags/v')
    needs: [build, cargo-publish]
    runs-on: ubuntu-latest
    steps:
      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: dist

      - name: Generate checksums
        shell: bash
        run: |
          set -euo pipefail
          find dist -type f -exec sha256sum {} \; > dist/SHA256SUMS

      - name: Publish GitHub release assets
        uses: softprops/action-gh-release@v2
        with:
          files: dist/**/*
          generate_release_notes: true