image: eclipse-temurin:8

stages:
  - test
  - deploy

variables:
  GRADLE_OPTIONS: --no-daemon --info --stacktrace --warning-mode=all

cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches

before_script:
  - export GRADLE_USER_HOME=`pwd`/.gradle

tests:
  stage: test
  script:
    # We don't have proper tests for SableCC, so as a minimal test, run SableCC on itself twice.
    # If this succeeds, we at least know that it's not completely broken.
    - ./gradlew ${GRADLE_OPTIONS} regenerateParser
    - ./gradlew ${GRADLE_OPTIONS} regenerateParser

tests:jdk-11:
  extends: tests
  image: eclipse-temurin:11

tests:jdk-17:
  extends: tests
  image: eclipse-temurin:17

publish:
  stage: deploy
  script:
    - openssl aes-256-cbc -pass "env:ENCRYPTION_PASSWORD" -d -a -md md5 -in secring.gpg.enc -out secring.gpg
    - openssl aes-256-cbc -pass "env:ENCRYPTION_PASSWORD" -d -a -md md5 -in pubring.gpg.enc -out pubring.gpg
    - openssl aes-256-cbc -pass "env:ENCRYPTION_PASSWORD" -d -a -md md5 -in gradle.properties.enc -out gradle.properties
    - ./gradlew ${GRADLE_OPTIONS} publish
  only:
    - master@general/stups/sablecc-stups
    - develop@general/stups/sablecc-stups
