seedgen 0.3.0

Zero-config database seed data generator with deterministic, constraint-safe fake data
Documentation
name: Release

# Maintainer triggers a release by tagging a commit: `git tag v0.1.0 && git push --tags`.
# Main is branch-protected; the tag's commit was already reviewed via PR.
on:
  push:
    tags: ['v*']

permissions:
  contents: write

jobs:
  build:
    name: Build ${{ matrix.artifact }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            artifact: seedgen-linux-amd64
            ext: ""
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            artifact: seedgen-linux-arm64
            ext: ""
          - target: x86_64-apple-darwin
            os: macos-latest
            artifact: seedgen-darwin-amd64
            ext: ""
          - target: aarch64-apple-darwin
            os: macos-latest
            artifact: seedgen-darwin-arm64
            ext: ""
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            artifact: seedgen-windows-amd64.exe
            ext: ".exe"
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

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

      - name: Install cross-compilation tools
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu
          echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV

      - name: Build
        run: cargo build --release --target ${{ matrix.target }}

      - name: Package (Unix)
        if: matrix.os != 'windows-latest'
        run: cp target/${{ matrix.target }}/release/seedgen${{ matrix.ext }} ${{ matrix.artifact }}

      - name: Package (Windows)
        if: matrix.os == 'windows-latest'
        shell: bash
        run: cp target/${{ matrix.target }}/release/seedgen${{ matrix.ext }} ${{ matrix.artifact }}

      - uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.artifact }}
          path: ${{ matrix.artifact }}

  release:
    name: Create GitHub Release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: |
            seedgen-linux-amd64/seedgen-linux-amd64
            seedgen-linux-arm64/seedgen-linux-arm64
            seedgen-darwin-amd64/seedgen-darwin-amd64
            seedgen-darwin-arm64/seedgen-darwin-arm64
            seedgen-windows-amd64.exe/seedgen-windows-amd64.exe
          generate_release_notes: true

  publish-crate:
    name: Publish to crates.io
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_TOKEN }}

  publish-docker:
    name: Publish Docker image
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: docker/setup-qemu-action@v3

      - uses: docker/setup-buildx-action@v3

      - uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKER_USER }}
          password: ${{ secrets.DOCKER_TOKEN }}

      - uses: docker/build-push-action@v5
        with:
          context: .
          push: true
          platforms: linux/amd64,linux/arm64
          tags: |
            fikridev/seedgen:latest
            fikridev/seedgen:${{ github.ref_name }}