rustberg 0.0.5

A production-grade, cross-platform, single-binary Apache Iceberg REST Catalog
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_TERM_COLOR: always

jobs:
  # ===========================================================================
  # Build Release Binaries
  # ===========================================================================
  build:
    name: Build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          # Linux x86_64 (musl - static binary)
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            artifact: rustberg-linux-x86_64
            ext: ""
            musl: true
          # Linux ARM64 (musl - static binary)
          - os: ubuntu-latest
            target: aarch64-unknown-linux-musl
            artifact: rustberg-linux-aarch64
            ext: ""
            zigbuild: true
          # macOS ARM64 (Apple Silicon)
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: rustberg-darwin-aarch64
            ext: ""
          # Windows x86_64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: rustberg-windows-x86_64
            ext: ".exe"
    steps:
      - uses: actions/checkout@v4

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

      - uses: Swatinem/rust-cache@v2

      - name: Install musl-tools
        if: matrix.musl
        run: sudo apt-get update && sudo apt-get install -y musl-tools

      - name: Install Zig
        if: matrix.zigbuild
        uses: mlugg/setup-zig@v1
        with:
          version: 0.13.0

      - name: Install cargo-zigbuild
        if: matrix.zigbuild
        uses: taiki-e/install-action@v2
        with:
          tool: cargo-zigbuild

      - name: Build release (native)
        if: "!matrix.zigbuild"
        run: cargo build --release --all-features --target ${{ matrix.target }}

      - name: Build release (zigbuild)
        if: matrix.zigbuild
        run: cargo zigbuild --release --all-features --target ${{ matrix.target }}

      - name: Package binary
        shell: bash
        run: |
          mkdir -p dist
          cp target/${{ matrix.target }}/release/rustberg${{ matrix.ext }} dist/${{ matrix.artifact }}${{ matrix.ext }}
          cd dist
          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            7z a ${{ matrix.artifact }}.zip ${{ matrix.artifact }}${{ matrix.ext }}
          else
            tar -czvf ${{ matrix.artifact }}.tar.gz ${{ matrix.artifact }}${{ matrix.ext }}
          fi

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

  # ===========================================================================
  # Build Docker Image
  # ===========================================================================
  docker:
    name: Docker
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4

      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Extract metadata
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: ghcr.io/${{ github.repository }}
          tags: |
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}
            type=sha

      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: .
          platforms: linux/amd64,linux/arm64
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
          cache-from: type=gha
          cache-to: type=gha,mode=max

  # ===========================================================================
  # Create GitHub Release
  # ===========================================================================
  release:
    name: Release
    needs: [build, docker]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts

      - name: Generate checksums
        run: |
          cd artifacts
          find . -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec sha256sum {} \; > ../checksums.txt
          cat ../checksums.txt

      - name: Create release
        uses: softprops/action-gh-release@v1
        with:
          generate_release_notes: true
          files: |
            artifacts/**/*.tar.gz
            artifacts/**/*.zip
            checksums.txt

  # ===========================================================================
  # Publish to crates.io
  # ===========================================================================
  publish:
    name: Publish to crates.io
    needs: [release]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --all-features