image: "openjdk:latest"

cache:
  key: "$CI_PROJECT_NAME"
  paths:
    - ".gradle/caches"

before_script:
  - "export GRADLE_USER_HOME=$(pwd)/.gradle"
  - "echo $SIGNING_properties | base64 -d > .gradle/gradle.properties"
  - "echo $SIGNING_secretKey | base64 -d > .gradle/sonatype_upload.gpg"
  - "chmod +x ./gradlew"

stages:
  - "build"
  - "test"
  - "release"

build:
  stage: "build"
  script:
    - "./gradlew build"
  except:
    - "tags"

test:
  stage: "test"
  script:
    - "./gradlew check --stacktrace"
  artifacts:
    paths:
      - "build/test-results/**/TEST-*.xml"
    reports:
      junit:
        - "build/test-results/**/TEST-*.xml"
  except:
    - "tags"

release:
  stage: "release"
  script:
    - "./gradlew publish"
  artifacts:
    paths:
      - "build/libs/*"
  rules:
    - if: "$CI_COMMIT_TAG != ''"
      when: always
