name: CD # Continuous Deployment

on:
  release:
    types: [published]

jobs:

  upload-assets:
    name: ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    if: github.repository_owner == 'mcarvin8'
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
          - target: i686-unknown-linux-gnu
            os: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6
        with:
          ref: refs/tags/${{ github.event.release.tag_name }}
      - name: Upload Rust binary
        uses: taiki-e/upload-rust-binary-action@v1
        with:
          bin: config-disassembler
          target: ${{ matrix.target }}
          archive: config-disassembler-$tag-$target
          tar: all
          zip: windows
          checksum: sha256
          locked: true
          ref: refs/tags/${{ github.event.release.tag_name }}
        env:
          GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
