name: OpenWrt Build

on:
  push:
    branches:
      - main
      - tmp
  pull_request:
    branches:
      - main
    types: [opened, synchronize, reopened]
  release:
    types: [created]

jobs:
  build:
    name: ${{ matrix.arch }} ${{ matrix.target }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - arch: arm_cortex-a9_vfpv3-d16
            target: mvebu-cortexa9

          - arch: mips_24kc
            target: ath79-generic

          - arch: mipsel_24kc
            target: mt7621

          - arch: powerpc_464fp
            target: apm821xx-nand

          - arch: aarch64_cortex-a53
            target: mvebu-cortexa53

          - arch: arm_cortex-a15_neon-vfpv4
            target: armvirt-32

          - arch: i386_pentium-mmx
            target: x86-geode

          - arch: x86_64
            target: x86-64

    steps:
      - uses: actions/checkout@v3
        with:
          submodules: false
          fetch-depth: 1

      - name: Build
        uses: openwrt/gh-action-sdk@main
        env:
          ARCH: ${{ matrix.arch }}-snapshot
          FEED_DIR: ${{ github.workspace }}/packages/openwrt
          FEEDNAME: ndpid_openwrt_packages_ci
          PACKAGES: nDPId-testing
          V: s

      - name: Store packages
        uses: actions/upload-artifact@v3
        with:
          name: nDPId-${{ matrix.arch}}-${{ matrix.target }}
          path: bin/packages/${{ matrix.arch }}/ndpid_openwrt_packages_ci/*.ipk
