name: Build Companion WiFi Firmwares

permissions:
  contents: write

on:
  workflow_dispatch:
  push:
    tags:
      - 'companion-wifi-v*'

jobs:

  build:
    runs-on: ubuntu-latest
    env:
      OFFICIAL_MESHCORE_VERSION: ${{ vars.OFFICIAL_MESHCORE_VERSION }}
    steps:

      - name: Clone Repo
        uses: actions/checkout@v6

      - name: Setup Build Environment
        uses: ./.github/actions/setup-build-environment

      - name: Build Firmwares
        run: /usr/bin/env bash build.sh build-companion-wifi-firmwares

      - name: Upload Workflow Artifacts
        uses: actions/upload-artifact@v7
        with:
          name: companion-wifi-firmwares
          path: out

      - name: Create Release
        uses: softprops/action-gh-release@v2
        if: startsWith(github.ref, 'refs/tags/')
        with:
          name: Companion WiFi Firmware ${{ env.RELEASE_VERSION }}
          body: ""
          draft: true
          files: out/*
