caxton 0.1.4

A secure WebAssembly runtime for multi-agent systems
Documentation
name: Build Artifacts

on:
  release:
    types: [published]

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build-release-artifacts:
    name: Build Release Artifacts
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            artifact: caxton-linux-x86_64
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
            artifact: caxton-linux-x86_64-musl
          - os: macos-latest
            target: x86_64-apple-darwin
            artifact: caxton-macos-x86_64
          - os: macos-latest
            target: aarch64-apple-darwin
            artifact: caxton-macos-aarch64
          - os: windows-latest
            target: x86_64-pc-windows-msvc
            artifact: caxton-windows-x86_64.exe

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable
          target: ${{ matrix.target }}

      - name: Install musl tools (Linux musl only)
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: sudo apt-get update && sudo apt-get install -y musl-tools

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

      - name: Prepare artifact (Unix)
        if: runner.os != 'Windows'
        run: |
          cp target/${{ matrix.target }}/release/caxton ${{ matrix.artifact }}
          chmod +x ${{ matrix.artifact }}

      - name: Prepare artifact (Windows)
        if: runner.os == 'Windows'
        run: |
          copy target\${{ matrix.target }}\release\caxton.exe ${{ matrix.artifact }}

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

  upload-release-artifacts:
    name: Upload Release Artifacts
    runs-on: ubuntu-latest
    needs: build-release-artifacts
    permissions:
      contents: write
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      - name: Create release archive (Unix)
        run: |
          cd artifacts
          for dir in */; do
            cd "$dir"
            tar -czf "../${dir%/}.tar.gz" *
            cd ..
          done

      - name: Upload artifacts to existing release
        uses: softprops/action-gh-release@v1
        with:
          # Don't create a new release, just upload files to the existing one
          tag_name: ${{ github.event.release.tag_name }}
          files: |
            artifacts/*.tar.gz
            artifacts/caxton-windows-x86_64.exe/caxton-windows-x86_64.exe
          # Don't update the release body or other properties
          body: ""
          draft: false
          prerelease: false
          fail_on_unmatched_files: true
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}