# Releases a new minor / major version from the HEAD of the main branch
name: Release Build
on:
  workflow_dispatch:
    inputs:
      version:
        description: The version to tag the release with, e.g., 1.2.0, 1.2.1-alpha.1
        required: true

jobs:
  build:
    name: Build and release
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2.3.4
      - uses: actions/setup-java@v2
        with:
          distribution: adopt
          java-version: 11
      - uses: burrunan/gradle-cache-action@v1.10
        with:
          job-id: jdk11
          remote-build-cache-proxy-enabled: false
          arguments: build --stacktrace -Prelease.version=${{ github.event.inputs.version }}
      - name: Publish artifacts
        run: ./gradlew final closeAndReleaseSonatypeStagingRepository --stacktrace -Prelease.version=${{ github.event.inputs.version }}
        env:
          GRGIT_USER: ${{ github.actor }}
          GRGIT_PASS: ${{ secrets.GITHUB_TOKEN }}
          SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
          SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
          GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
          GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
