Skip to content

On workflow dispatch start maven release #8

On workflow dispatch start maven release

On workflow dispatch start maven release #8

# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: On workflow dispatch start maven release
on:
workflow_dispatch:
inputs:
releaseversion:
description: 'Release version'
required: true
default: "0.1.14"
jobs:
build:
runs-on: ubuntu-latest
# See https://stackoverflow.com/a/61421306/15619
env:
RELEASE_VERSION: ${{github.event.inputs.releaseversion}}
steps:
- run: echo "Will perform a maven release with public version ${{ github.event.inputs.releaseversion }}"
- uses: actions/checkout@v3
with:
ref: main
fetch-depth: '0'
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6.1.0
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: List gpg keys (there should be only one)
run: gpg -K
- name: Setup git configuration
run: |
git config --global user.email "aadarchi-releaser-bot@users.noreply.github.com"
git config --global user.name "🤖 Aadarchi releaser bot"
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: maven
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: ${{ secrets.OSS_SONATYPE_USERNAME }}
server-password: ${{ secrets.OSS_SONATYPE_PASSWORD }}
- name: Do not forget to configure Maven Settings!
uses: s4u/maven-settings-action@v3.0.0
with:
override: true
githubServer: true
servers: |
[{
"id": "ossrh",
"username": "${{ secrets.OSS_SONATYPE_USERNAME }}",
"password": "${{ secrets.OSS_SONATYPE_PASSWORD }}"
}]
properties: |
[
{"aadarchi.github.token": "${{ secrets.TOKEN_FOR_GITHUB }}" },
{"aadarchi.gitlab.token": "${{ secrets.TOKEN_FOR_GITLAB }}" },
{"releaseVersion": "${{env.RELEASE_VERSION}}" },
{"gpg.passphrase": "${{secrets.MAVEN_GPG_PASSPHRASE}}" },
{"username": "git"},
{"password": "${{ secrets.GITHUB_TOKEN }}"}
]
- name: Build with Maven
run: mvn --no-transfer-progress -B release:prepare release:perform -Prelease --file pom.xml
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Get created tag name (for GitHuub release creation)
id: tag
run: echo "CREATED_GIT_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT
- name: Create associated GitHub release
uses: lakto/gren-action@v2.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
options: "--override --data-source=issues --prerelease --tags=${{ steps.tag.outputs.CREATED_GIT_TAG }}"