name: Release
on:
  push:
    tags: ["v*"]
jobs:
  test:
    runs-on: ubuntu-latest
    if: github.repository == 'lightbend/config'
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Setup JDK
        uses: actions/setup-java@v2
        with:
          distribution: temurin
          java-version: 11
      - name: Setup SBT
        run: |
          # Make sure ca-certificates and gnupg are installed (often required for adding new repos)
          sudo apt-get update
          sudo apt-get install -y ca-certificates gnupg
          
          # Add the sbt repositories to apt sources
          echo "deb https://repo.scala-sbt.org/scalasbt/debian all main" | sudo tee /etc/apt/sources.list.d/sbt.list
          echo "deb https://repo.scala-sbt.org/scalasbt/debian /" | sudo tee /etc/apt/sources.list.d/sbt_old.list
      
          # Import the Scala SBT public key
          curl -sL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x2EE0EA64E40A89B84B2DF73499E82A75642AC823" \
            | sudo apt-key add -
      
          # Now update and install
          sudo apt-get update
          sudo apt-get install -y sbt
      - env:
          PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
          PGP_SECRET: ${{ secrets.PGP_SECRET }}
          SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
          SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
        run: sbt ci-release
