-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(workflow): 🚀 added publish workflow to deploy to Maven central
Closes #14
- Loading branch information
Showing
1 changed file
with
286 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,286 @@ | ||
name: Deploy Release to GitHub and Maven Central | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release_type: | ||
type: choice | ||
description: "Release Type" | ||
required: true | ||
options: | ||
- major | ||
- minor | ||
- patch | ||
default: "minor" | ||
|
||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} | ||
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} | ||
|
||
jobs: | ||
prepare-release-snapshot: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: "11" | ||
distribution: "adopt" | ||
|
||
- name: Restore local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ github.sha }} | ||
|
||
- name: Maven command to update Major snapshot version | ||
if: ${{ github.event.inputs.release_type == 'major' }} | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=\${parsedVersion.nextMajorVersion}.0.0-SNAPSHOT versions:commit | ||
|
||
- name: Maven command to update Minor snapshot version | ||
if: ${{ github.event.inputs.release_type == 'minor' }} | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.nextMinorVersion}.0-SNAPSHOT versions:commit | ||
|
||
- name: Maven command to update Patch snapshot version | ||
if: ${{ github.event.inputs.release_type == 'patch' }} | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit | ||
|
||
- name: Build the artifacts | ||
run: mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip | ||
|
||
- name: Upload target folder | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: target | ||
path: | | ||
${{ github.workspace }}/core-java/target | ||
${{ github.workspace }}/core-java/pom.xml | ||
release-snapshot: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare-release-snapshot | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: "11" | ||
distribution: "adopt" | ||
|
||
- name: Restore local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ github.sha }} | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: target | ||
|
||
- name: Release snapshot to Maven central | ||
uses: samuelmeuli/action-maven-publish@v1 | ||
with: | ||
gpg_private_key: ${{ env.GPG_PRIVATE_KEY }} | ||
gpg_passphrase: ${{ env.GPG_PASSPHRASE }} | ||
nexus_username: ${{ env.NEXUS_USERNAME }} | ||
nexus_password: ${{ env.NEXUS_PASSWORD }} | ||
maven_profiles: release | ||
server_id: ossrh | ||
maven_args: --settings ${{ github.workspace }}/core-java/setting/settings.xml -f core-java/pom.xml -DskipTests -Dcheckstyle.skip -B | ||
|
||
prepare-release: | ||
needs: | ||
- release-snapshot | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: "11" | ||
distribution: "adopt" | ||
|
||
- name: Restore local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ github.sha }} | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: target | ||
|
||
- name: Maven command to update Major version | ||
if: ${{ github.event.inputs.release_type == 'major' }} | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=\${parsedVersion.majorVersion}.0.0 versions:commit | ||
|
||
- name: Maven command to update Minor version | ||
if: ${{ github.event.inputs.release_type == 'minor' }} | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.0 versions:commit | ||
|
||
- name: Maven command to update Patch version | ||
if: ${{ github.event.inputs.release_type == 'patch' }} | ||
run: mvn build-helper:parse-version versions:set -f core-java/pom.xml -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.incrementalVersion} versions:commit | ||
|
||
- name: Build the project | ||
run: mvn clean install -f core-java/pom.xml -DskipTests -Dcheckstyle.skip | ||
|
||
- name: Upload target folder | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: target | ||
path: | | ||
${{ github.workspace }}/core-java/target | ||
${{ github.workspace }}/core-java/pom.xml | ||
maven-release: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- prepare-release | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: "11" | ||
distribution: "adopt" | ||
|
||
- name: Restore local Maven repository | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ github.sha }} | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: target | ||
|
||
- name: Release to Maven central | ||
uses: samuelmeuli/action-maven-publish@v1 | ||
with: | ||
gpg_private_key: ${{ env.GPG_PRIVATE_KEY }} | ||
gpg_passphrase: ${{ env.GPG_PASSPHRASE }} | ||
nexus_username: ${{ env.NEXUS_USERNAME }} | ||
nexus_password: ${{ env.NEXUS_PASSWORD }} | ||
maven_profiles: release | ||
server_id: ossrh | ||
maven_args: --settings ${{ github.workspace }}/core-java/setting/settings.xml -f core-java/pom.xml -DskipTests -Dcheckstyle.skip -B | ||
|
||
push-pom: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- maven-release | ||
outputs: | ||
release-version: ${{ steps.artifacts.outputs.version }} | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Java and Maven | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: "11" | ||
distribution: "adopt" | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: target | ||
|
||
- name: Get the release version | ||
id: artifacts | ||
run: | | ||
export MVN_VERSION=$(mvn -f core-java/pom.xml -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) | ||
echo "::set-output name=version::$MVN_VERSION" | ||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v3 | ||
with: | ||
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ env.GPG_PASSPHRASE }} | ||
git-user-signingkey: true | ||
git-commit-gpgsign: true | ||
|
||
- name: Push updated pom.xml | ||
uses: EndBug/add-and-commit@v7 | ||
with: | ||
add: core-java/pom.xml | ||
message: Released latest version to Maven central | ||
push: true | ||
default_author: user_info | ||
signoff: true | ||
|
||
push-tag: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- push-pom | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: target | ||
|
||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v3 | ||
with: | ||
gpg-private-key: ${{ env.GPG_PRIVATE_KEY }} | ||
passphrase: ${{ env.GPG_PASSPHRASE }} | ||
git-user-signingkey: true | ||
git-commit-gpgsign: true | ||
|
||
- name: Create and Push Tag | ||
uses: EndBug/add-and-commit@v7 | ||
with: | ||
tag: v${{ needs.push-pom.outputs.release-version }} | ||
message: Released to Maven central | ||
signoff: true | ||
default_author: user_info | ||
push: true | ||
|
||
github-release: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- push-pom | ||
- push-tag | ||
steps: | ||
- name: Check out Git repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Download target folder | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: target | ||
|
||
- name: Create GitHub Release | ||
uses: softprops/action-gh-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
GITHUB_REPOSITORY: ${{ github.repository }} | ||
with: | ||
tag_name: v${{ needs.push-pom.outputs.release-version }} | ||
name: Version ${{ needs.push-pom.outputs.release-version }} | ||
prerelease: false | ||
draft: false | ||
discussion_category_name: Announcements | ||
generate_release_notes: true | ||
files: | | ||
core-java/target/*.jar | ||
core-java/target/*.pom |