name: Build mips-unknown-linux-gnu Releases
on:
  workflow_dispatch:
  push:
    tags:
      - "v*.*.*"
env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        target:
          - mips-unknown-linux-gnu

        include:
          - target: mips-unknown-linux-gnu
            host_os: ubuntu-latest

    runs-on: ${{ matrix.host_os }}
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable

      - name: Prepare
        shell: bash
        run: |
          cargo install cbindgen
          mkdir release

      - name: Build
        shell: bash
        run: |
          ./.github/workflows/mips-unknown-linux-gnu.sh
          cbindgen -c cbindgen.toml -o ./overtls.h
          zip -j release/overtls-${{ matrix.target }}.zip target/${{ matrix.target }}/release/overtls-bin ./config.json ./overtls.h target/${{ matrix.target }}/release/libovertls.so

      - name: Upload
        uses: softprops/action-gh-release@v3
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          files: release/*
