Merge pull request #75 from OsgiliathEnterprise/embeddedid #25
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven | |
name: Maven compile and release | |
on: | |
push: | |
branches: [ main ] | |
workflow_dispatch: | |
inputs: | |
releaseVersion: | |
description: "Define the release version" | |
required: true | |
default: "" | |
developmentVersion: | |
description: "Define the snapshot version" | |
required: true | |
default: "" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 21.0.1 | |
distribution: 'temurin' | |
java-package: 'jdk' | |
cache: 'maven' | |
server-id: ossrh | |
- name: Configure Git User | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "GitHub Actions" | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Import GPG Key | |
uses: crazy-max/[email protected] | |
with: | |
gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
- name: Build, test and report | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
./mvnw -DskipTests install | |
cd sample-mono | |
./mvnw generate-sources -Pentities-from-changelog | |
cd .. | |
./mvnw -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Pentities-from-changelog,coverage -Dsonar.projectKey=OsgiliathEnterprise_data-migrator | |
rm -rf src/main/java | |
- name: Verify Whether a Release is Ready | |
id: release | |
shell: bash | |
run: | | |
if [ "${{ github.event.inputs.releaseVersion }}" != "" ] && [ "${{ github.event.inputs.developmentVersion }}" != "" ]; then | |
echo "auto_release=true" >> $GITHUB_ENV | |
else | |
echo "auto_release=false" >> $GITHUB_ENV | |
fi | |
- name: Release With Maven | |
run: | | |
./mvnw -B -U \ | |
-P 'release' \ | |
release:prepare \ | |
release:perform \ | |
javadoc:jar \ | |
source:jar \ | |
-s ./.mvn/settings.xml \ | |
-Dgpg.passphrase=${{ secrets.MAVEN_GPG_PASSPHRASE }} \ | |
-DreleaseVersion=${{ github.event.inputs.releaseVersion }} \ | |
-DdevelopmentVersion=${{ github.event.inputs.developmentVersion }} \ | |
deploy | |
env: | |
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} | |
AUTO_RELEASE_AFTER_CLOSE: ${{ env.auto_release }} | |
- name: Artifact Name | |
shell: bash | |
run: | | |
echo "artifact_name=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)" >> "$GITHUB_ENV" | |
- name: Workflow Release Notes | |
uses: peter-evans/repository-dispatch@v2 | |
if: ${{ github.event.inputs.releaseVersion }} != "" && ${{ github.event.inputs.developmentVersion }} != "" | |
with: | |
event-type: release-notes | |
client-payload: '{"auto_release": "${{ env.auto_release }}", "artifact": "${{ env.artifact_name }}-${{ env.sha_short }}"}' |