Publishing Package Version 0.2.0 #11
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
name: Release To Maven Central | |
run-name: Publishing Package Version ${{ github.event.inputs.Version }} | |
# Run workflow on commits to the `main` branch | |
on: | |
workflow_dispatch: | |
inputs: | |
Version: | |
description: "This input field requires version in format: x.y.z, where x => major version, y => minor version and z => patch version" | |
required: true | |
jobs: | |
publish: | |
name: Publish the Maven package | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- name: Check out git repository | |
uses: actions/checkout@v2 | |
- name: Install Java and Maven setup | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 8 | |
- name: Update version in POM | |
run: mvn -B versions:set -DnewVersion=${{ github.event.inputs.Version }} -DgenerateBackupPoms=false | |
- name: Release to Maven Central | |
id: release | |
uses: samuelmeuli/action-maven-publish@v1 | |
with: | |
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} | |
gpg_passphrase: ${{ secrets.OSSRH_GPG_PASSPHRASE }} | |
nexus_username: ${{ secrets.OSSRH_USERNAME }} | |
nexus_password: ${{ secrets.OSSRH_PASSWORD }} | |
- name: Commit the version change | |
if: steps.release.outputs.exit_code == 0 | |
uses: devops-infra/action-commit-push@master | |
with: | |
github_token: "${{ secrets.GITHUB_TOKEN }}" | |
commit_message: "ci(release-version) update pom.xml [ci skip]" | |
force: false | |
target_branch: project-version-update | |
- name: Push the version change | |
if: steps.release.outputs.exit_code == 0 | |
uses: CasperWA/push-protected@v2 | |
with: | |
token: ${{ secrets.PAT }} | |
branch: main | |
- name: Delete the intermediate branch | |
if: steps.release.outputs.exit_code == 0 | |
run: | | |
git branch -D project-version-update &>/dev/null || true | |
git push origin :project-version-update &>/dev/null || true | |
- name: Create tag | |
if: steps.release.outputs.exit_code == 0 | |
id: tag_version | |
uses: mathieudutour/github-tag-action@v6.0 | |
with: | |
github_token: ${{ secrets.PAT }} | |
custom_tag: ${{ github.event.inputs.Version }} | |
tag_prefix: "" | |
- name: Create changelog for the release | |
if: steps.release.outputs.exit_code == 0 | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ steps.tag_version.outputs.new_tag }} | |
name: Release Version ${{ github.event.inputs.Version }} | |
body: ${{ steps.tag_version.outputs.changelog }} |