kind: pipeline
type: docker
name: default

steps:
  - name: test
    image: maven:3-openjdk-17
    commands:
    - mvn -B -DskipTests clean package
    - mvn test -B
    volumes:
    - name: m2
      path: /root/.m2

  - name: archive-standard-artifact
    image: alpine:latest
    commands:
    - mkdir -p /builds/ns-usbloader
    - echo target/ns-usbloader-*jar
    - cp target/ns-usbloader-*jar /builds/ns-usbloader/
    volumes:
    - name: builds
      path: /builds

  - name: make-win-installer
    image: wheatstalk/makensis:3
    commands:
    - cp target/NS-USBloader.exe misc/windows/NSIS/
    - misc/windows/update_version.sh
    - cd misc/windows/NSIS
    - makensis -V4 ./installer.nsi
    - echo Installer-*.exe
    - cp Installer-*.exe /builds/ns-usbloader/
    - rm ./NS-USBloader.exe
    - rm ./Installer-*.exe
    - cd ../../../
    volumes:
    - name: builds
      path: /builds
    - name: jdk
      path: /drone/src/misc/windows/NSIS/jdk
    - name: drivers
      path: /drone/src/misc/windows/NSIS/Drivers_set.exe

  - name: emerge-legacy-artifact
    image: maven:3-openjdk-17
    commands:
    - . ./.make_legacy
    - mvn -B -DskipTests clean package
    - echo target/ns-usbloader-*jar
    - cp target/ns-usbloader-*jar /builds/ns-usbloader/
    volumes:
    - name: m2
      path: /root/.m2
    - name: builds
      path: /builds

  - name: make-legacy-win-installer
    image: wheatstalk/makensis:3
    commands:
    - cp target/NS-USBloader.exe misc/windows/NSIS/
    - misc/windows/update_version.sh legacy
    - cd misc/windows/NSIS
    - makensis -V4 ./installer.nsi
    - echo Installer-*.exe
    - cp Installer-*.exe /builds/ns-usbloader/
    - cd ../../../
    volumes:
    - name: builds
      path: /builds
    - name: jdk
      path: /drone/src/misc/windows/NSIS/jdk
    - name: drivers
      path: /drone/src/misc/windows/NSIS/Drivers_set.exe

  - name: emerge-mac-m1-artifact
    image: maven:3-openjdk-17
    commands:
      - . ./.make_m1
      - mvn -B -DskipTests clean package
      - echo target/ns-usbloader-*jar
      - cp target/ns-usbloader-*jar /builds/ns-usbloader/
    volumes:
      - name: m2
        path: /root/.m2
      - name: builds
        path: /builds

volumes:
  - name: m2
    host:
      path: /home/docker/drone/files/m2
  - name: builds
    host:
      path: /home/www/builds
  - name: jdk
    host:
      path: /home/docker/drone/files/assembly/openjdk-19.0.2
  - name: drivers
    host:
      path: /home/docker/drone/files/assembly/Drivers_set.exe