From ac95d7c985b74af6b13d04b3c2cafc4bd301077e Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 24 Jul 2024 19:49:43 +0200 Subject: [PATCH] Add inputs --- .github/workflows/release.yml | 43 ++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8fc8a392..959d23f1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,20 +1,41 @@ -name: Manual Run automatic Maven Release +name: Manual Maven Release -on: workflow_dispatch +on: + workflow_dispatch: + inputs: + version: + description: The version to release (will be inferred from the pom version by default). + required: false + next-version: + description: The next developement version (will be inferred from the pom version by default). + required: false + java-version: + description: The java version to use + required: false + default: 22 + distribution: + description: The java distribution to use. + required: false + default: temurin + maven-version: + description: The Maven version to use + required: false + default: 3.9.8 jobs: release: name: Release to Maven Central runs-on: ubuntu-latest steps: + - name: Checkout ${{ github.ref_name }} uses: actions/checkout@v4 - name: Setup Java uses: actions/setup-java@v4 with: - distribution: 'temurin' - java-version: '22' + distribution: ${{ github.event.inputs.distribution }} + java-version: ${{ github.event.inputs.java-version }} cache: maven server-id: central server-username: MAVEN_USER @@ -25,7 +46,7 @@ jobs: - name: Setup Maven uses: stCarolas/setup-maven@v5 with: - maven-version: '3.9.8' + maven-version: ${{ github.event.inputs.maven-version }} - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v6 @@ -35,7 +56,7 @@ jobs: git_config_global: true git_user_signingkey: true git_commit_gpgsign: true - fingerprint: '0181A4828FA27B6BE6F1F5A68611CD28F472E006' + fingerprint: ${{ secrets.MAVEN_GPG_KEY_FINGERPRINT }} - name: Diag run: | @@ -61,23 +82,23 @@ jobs: run: | gh extension install valeriobelli/gh-milestone version=$(mvn -q -DforceStdout help:evaluate -N -Dexpression=project.version | sed -rn 's/([^-]+)(-SNAPSHOT|)$/\1/p') - echo "VERSION=$version" >> "$GITHUB_OUTPUT" + echo "version=$version" >> "$GITHUB_OUTPUT" - name: Release env: MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - MAVEN_GPG_KEY_FINGERPRINT: '0x0181A4828FA27B6BE6F1F5A68611CD28F472E006!' + MAVEN_GPG_KEY_FINGERPRINT: ${{ secrets.MAVEN_GPG_KEY_FINGERPRINT }} MAVEN_USER: ${{ secrets.NEXUS_USER }} MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} run: | - mvn -B release:prepare release:perform -Darguments="-DskipTests" + mvn -B release:prepare release:perform -Darguments="-DskipTests" -DreleaseVersion=${{ github.event.inputs.version }} -DdevelopmentVersion=${{ github.event.inputs.next-version }} - name: Post release env: GH_TOKEN: ${{ github.token }} shell: bash run: | - version=${{ steps.pre-release.outputs.VERSION }} + version=${{ steps.pre-release.outputs.version }} echo "Trying to find milestone $version" milestone=$(gh milestone list --json id,title,state --jq "map_values(select(.title == \"${version}\" and .state == \"OPEN\")).[].number") if [ ! -z "$milestone" ]; then @@ -89,7 +110,7 @@ jobs: echo "Preparing development $version" echo "Trying to find milestone $version" milestone=$(gh milestone list --json id,title,state --jq "map_values(select(.title == \"${version}\" and .state == \"OPEN\")).[].number") - if [ ! -z "$milestone" ]; then + if [ -z "$milestone" ]; then echo "Creating milestone $version" gh milestone create --title $milestone fi