zesty-backup 1.0.2

A flexible, multi-provider backup utility for cloud storage
name: Release

on:
  release:
    types: [created]

env:
  CARGO_TERM_COLOR: always

jobs:
  build-release:
    name: Build Release Binaries
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            bin_name: zesty-backup
            archive_format: tar.gz
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            bin_name: zesty-backup.exe
            archive_format: zip
          - os: macos-latest
            target: x86_64-apple-darwin
            bin_name: zesty-backup
            archive_format: tar.gz
          - os: macos-latest
            target: aarch64-apple-darwin
            bin_name: zesty-backup
            archive_format: tar.gz
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
      
      - name: Cache cargo registry
        uses: actions/cache@v3
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
      
      - name: Build release
        run: |
          rustup target add ${{ matrix.target }}
          cargo build --release --target ${{ matrix.target }} --verbose
      
      - name: Create archive (Linux/macOS)
        if: matrix.os != 'windows-latest'
        run: |
          mkdir -p release
          cp target/${{ matrix.target }}/release/${{ matrix.bin_name }} release/
          tar czf zesty-backup-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive_format }} -C release ${{ matrix.bin_name }}
      
      - name: Create archive (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          mkdir release
          copy target\${{ matrix.target }}\release\${{ matrix.bin_name }} release\
          powershell Compress-Archive -Path release\${{ matrix.bin_name }} -DestinationPath zesty-backup-${{ github.ref_name }}-${{ matrix.target }}.zip -Force
      
      - name: Upload release asset
        uses: actions/upload-artifact@v4
        with:
          name: zesty-backup-${{ matrix.target }}
          path: zesty-backup-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive_format }}
      
      - name: Upload to release
        uses: softprops/action-gh-release@v1
        with:
          files: zesty-backup-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive_format }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}