name: Build Native

on: workflow_call

permissions:
  contents: write
  packages: write

jobs:
  build-native:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          submodules: recursive
          ref: ${{github.event.pull_request.head.ref}}
          repository: ${{github.event.pull_request.head.repo.full_name}}

      - name: Setup native build
        id: base
        uses: ./.github/actions/setup-native

      - name: Build Native
        run: bin/build-native.sh

      - name: Get release version string
        run: echo "long=$(./bin/buildinfo.py long)" >> $GITHUB_OUTPUT
        id: version

      - name: Store binaries as an artifact
        uses: actions/upload-artifact@v4
        with:
          name: firmware-native-${{ steps.version.outputs.long }}.zip
          overwrite: true
          path: |
            release/meshtasticd_linux_x86_64
            bin/config-dist.yaml
