---
kind: pipeline
name: default
type: docker

steps:
  - name: test
    image: eclipse-temurin:8-jdk
    commands:
      - ./gradlew test
  - name: build
    image: eclipse-temurin:8-jdk
    environment:
      AUTH_TOKEN:           # Gitea access token ENV variable
        from_secret: auth   # Name of DroneCI secret exposed above
    commands:
      - ./gradlew build packages
      - for file in build/libs/*-all.jar ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done
      - for file in build/distributions/*.deb ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done
      - for file in build/distributions/*.rpm ; do curl --user "${DRONE_REPO_OWNER}:$${AUTH_TOKEN}" --upload-file "$${file}" "https://git.data.coop/api/packages/${DRONE_REPO_OWNER}/generic/${DRONE_REPO_NAME}/${DRONE_TAG}/$(basename $file)" ; done
    when:
      event:
        - tag
