---
variables:
  - &default
    image: "git.freifunk-rhein-sieg.net/freifunk-troisdorf/docker-gluon-build:latest"
    pull: true
    environment:
      - input_version=${CI_COMMIT_TAG}
      - GLUON_SITEDIR=..
      - FORCE_UNSAFE_CONFIGURE=1
      - GLUON_TARGET=${TARGET}
      - GLUON_DEPRECATED=1

workspace:
  base: /build

clone:
  git:
    image: woodpeckerci/plugin-git
    settings:
      recursive: true

pipeline:
  make_update:
    <<: *default
    commands:
      - cd gluon
      - make update

  patch-iw-to-iw-full:
    <<: *default
    commands:
      - sed -i 's/+iw /+iw-full /g' gluon/openwrt/package/kernel/mac80211/Makefile

  build:
    <<: *default
    commands:
      - cd gluon
      - make -j$(nproc) GLUON_AUTOUPDATER_BRANCH=${BRANCH} GLUON_AUTOUPDATER_ENABLED=1 GLUON_RELEASE=$input_version-${BRANCH} GLUON_OUTPUTDIR=output/${BRANCH}

matrix:
  TARGET:
    - ath79-generic
    - ath79-mikrotik
    - ath79-nand
    - bcm27xx-bcm2708
    - bcm27xx-bcm2709
    - ipq40xx-generic
    - ipq40xx-mikrotik
    - ipq806x-generic
    - lantiq-xrx200
    - lantiq-xway
    - mediatek-mt7622
    - mpc85xx-p1010
    - mpc85xx-p1020
    - ramips-mt7620
    - ramips-mt7621
    - ramips-mt76x8
    - realtek-rtl838x
    - rockchip-armv8
    - sunxi-cortexa7
    - x86-64
    - x86-generic
    - x86-geode
    - x86-legacy
  BRANCH:
    - stable
    - beta
    - experimental

depends_on:
  - prepare