Releasing GitHub_Actions_POC #22 #22
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 Pipeline | |
run-name: "Releasing ${{ github.event.repository.name }} #${{github.run_number}}" | |
on: | |
workflow_dispatch | |
jobs: | |
initialization: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' || github.ref_name == 'refs/heads/master' | |
outputs: | |
RELEASE_VERSION: ${{steps.splitVersion.outputs._0}} | |
env: | |
SNAPSHOTVERSION: "" | |
steps: | |
- name: Checkout Code Repository | |
uses: actions/checkout@v4 | |
- name: Downloading Java | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
- name: Get Current Version | |
run: | | |
echo "POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
- name: Print Version | |
run: echo ${{env.POM_VERSION}} | |
- name: Verify Is SNAPSHOT Version | |
if: ${{ !contains(env.POM_VERSION, '-SNAPSHOT')}} | |
run: | | |
echo "ERROR: Version is set to incompatible version ${{env.POM_VERSION}}. Only SNAPSHOT development versions can be converted to a release version." | |
exit 1 | |
- name: Split version code | |
uses: xom9ikk/split@v1 | |
id: splitVersion | |
with: | |
string: ${{env.POM_VERSION}} | |
separator: -SNAPSHOT | |
limit: -1 | |
- name: Split version code - Minor | |
uses: xom9ikk/split@v1 | |
id: splitVersionMinor | |
with: | |
string: ${{env.POM_VERSION}} | |
separator: . | |
limit: -1 | |
- name: Increment Snapshot Version | |
id: newSnapshotVersion | |
run: | | |
echo "SnapShotVersion=$((${{steps.splitVersionMinor.outputs._1}}++))" | |
- name: Print Versions | |
run: | | |
echo " Snapshot Version -- ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}" | |
echo " Release Version -- ${{steps.splitVersion.outputs._0}}" | |