rsb 0.3.5

a http server benchmark tool, written in rust.
Documentation
name: Release

permissions:
  contents: write
  packages: write

on:
  push:
    tags:
      - 'v*'

env:
  CARGO_REGISTRY_TOKEN: ${{ secrets.CRATESIO_TOKEN }}
  DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
  DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
  # Publish to crates.io - independent job
  publish-crates:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Publish to crates.io
        run: cargo publish

  # Create GitHub Release - independent job
  create-release:
    name: Create GitHub Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Create Release
        uses: taiki-e/create-gh-release-action@v1
        with:
          changelog: CHANGELOG.md
          ref: ${{ github.ref }}
          token: ${{ env.GITHUB_TOKEN }}

  # Linux x86_64 - static linking with musl
  upload-linux-x86_64:
    name: Upload Binaries (Linux x86_64)
    runs-on: ubuntu-latest
    needs: create-release
    steps:
      - uses: actions/checkout@v4
      
      - name: Build and upload
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: rsb
          target: x86_64-unknown-linux-musl
          archive: rsb-x86_64-unknown-linux-musl
          token: ${{ env.GITHUB_TOKEN }}

  # Linux ARM64 - using cross
  upload-linux-arm64:
    name: Upload Binaries (Linux ARM64)
    runs-on: ubuntu-latest
    needs: create-release
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-unknown-linux-gnu
      
      - name: Install cross
        uses: taiki-e/install-action@v2
        with:
          tool: cross
      
      - name: Build
        run: cross build --release --target aarch64-unknown-linux-gnu
      
      - name: Upload
        uses: svenstaro/upload-release-action@v2
        with:
          repo_token: ${{ env.GITHUB_TOKEN }}
          file: target/aarch64-unknown-linux-gnu/release/rsb
          asset_name: rsb-aarch64-unknown-linux-gnu.tar.gz
          tag: ${{ github.ref }}
          overwrite: true

  # macOS x86_64 - native
  upload-macos-x86_64:
    name: Upload Binaries (macOS x86_64)
    runs-on: macos-latest
    needs: create-release
    steps:
      - uses: actions/checkout@v4
      
      - name: Build and upload
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: rsb
          target: x86_64-apple-darwin
          archive: rsb-x86_64-apple-darwin
          token: ${{ env.GITHUB_TOKEN }}

  # macOS ARM64 - native
  upload-macos-arm64:
    name: Upload Binaries (macOS ARM64)
    runs-on: macos-latest
    needs: create-release
    steps:
      - uses: actions/checkout@v4
      
      - name: Build and upload
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: rsb
          target: aarch64-apple-darwin
          archive: rsb-aarch64-apple-darwin
          token: ${{ env.GITHUB_TOKEN }}

  # Windows x86_64 - native
  upload-windows-x86_64:
    name: Upload Binaries (Windows x86_64)
    runs-on: windows-latest
    needs: create-release
    steps:
      - uses: actions/checkout@v4
      
      - name: Build and upload
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: rsb
          target: x86_64-pc-windows-msvc
          archive: rsb-x86_64-pc-windows-msvc
          token: ${{ env.GITHUB_TOKEN }}

  # Build and push Docker images
  push-docker:
    name: Push Docker Images
    runs-on: ubuntu-latest
    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 Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ env.DOCKERHUB_USERNAME }}
          password: ${{ env.DOCKERHUB_TOKEN }}
      
      - name: Login to GHCR
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ env.GITHUB_TOKEN }}
      
      - name: Get version from tag
        id: version
        run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
      
      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          context: .
          file: docker/Dockerfile
          platforms: linux/amd64,linux/arm64
          push: true
          tags: |
            gamelife1314/rsb:latest
            gamelife1314/rsb:${{ steps.version.outputs.VERSION }}
            ghcr.io/gamelife1314/rsb:latest
            ghcr.io/gamelife1314/rsb:${{ steps.version.outputs.VERSION }}