rbxcloud 0.17.0

CLI and SDK for the Roblox Open Cloud APIs
Documentation
name: Release

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

jobs:
  check-release-version:
    name: Check Release Version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.x"

      - name: Check tag version against cargo version
        run: python -u scripts/check_version.py ${{ github.ref_name }}

  build:
    needs: ["check-release-version"]
    strategy:
      fail-fast: false
      matrix:
        include:
          - host: linux
            os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            label: linux

          - host: windows
            os: windows-latest
            target: x86_64-pc-windows-msvc
            label: win64

          - host: macos
            os: macos-13
            target: x86_64-apple-darwin
            label: macos

          - host: macos
            os: macos-latest
            target: aarch64-apple-darwin
            label: macos-aarch64

    name: Build (${{ matrix.label }})
    runs-on: ${{ matrix.os }}
    env:
      BIN: rbxcloud
    steps:
      - uses: actions/checkout@v4

      - name: Get version from tag
        shell: bash
        run: |
          echo "PROJECT_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV

      - name: Rust
        run: rustup toolchain install stable-${{ matrix.target }} --profile minimal --no-self-update

      - name: Rust Cache
        uses: Swatinem/rust-cache@v2

      - name: Build Release
        run: cargo build --release --locked --verbose
        env:
          CARGO_TARGET_DIR: output
          OPENSSL_STATIC: 1

      - name: Create Release Archive
        shell: bash
        run: |
          mkdir staging

          if [ "${{ matrix.host }}" = "windows" ]; then
            cp "output/release/$BIN.exe" staging/
            cd staging
            7z a ../release.zip *
          else
            cp "output/release/$BIN" staging/
            cd staging
            zip ../release.zip *
          fi

      - name: Upload Archive to Artifacts
        uses: actions/upload-artifact@v4
        with:
          name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}
          path: release.zip

  create-release:
    needs: ["build"]
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.x"

      - name: Create artifact directory
        shell: bash
        run: mkdir gh_artifacts

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

      - name: Move releases
        run: python -u scripts/move_releases.py gh_artifacts

      - name: Create release
        id: create_release
        uses: softprops/action-gh-release@v2
        with:
          draft: true
          generate_release_notes: true
          fail_on_unmatched_files: true
          files: gh_artifacts/*.zip

  publish:
    needs: ["create-release"]
    name: Publish
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Rust
        run: rustup toolchain install stable --profile minimal --no-self-update

      - name: Publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        shell: bash
        run: cargo publish