-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
115 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,70 @@ | ||
name: Java (Release) | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
releaseType: | ||
description: 'Release type - major, minor or patch' | ||
required: true | ||
default: 'minor' | ||
options: | ||
- 'major' | ||
- 'minor' | ||
- 'patch' | ||
|
||
defaults: | ||
run: | ||
working-directory: visual-java | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Maven Central Repository | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
server-id: ossrh | ||
server-username: MVN_CENTRAL_USERNAME | ||
server-password: MVN_CENTRAL_PASSWORD | ||
|
||
- name: upgrade & push version | ||
id: upgrade | ||
run: | | ||
current_version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) | ||
new_version=$(./scripts/bump_version.sh -c $current_version -r ${{ github.event.inputs.releaseType }}) | ||
mvn versions:set -DgenerateBackupPoms=false -DnewVersion=$new_version | ||
tag_name="java-$new_version" | ||
git add ./pom.xml | ||
git commit -m "[release] $tag_name" | ||
git tag $tag_name | ||
git push | ||
git push origin $tag_name | ||
echo "version=$new_version" >> "$GITHUB_OUTPUT" | ||
echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT" | ||
- name: Import GPG signing key | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.MVN_CENTRAL_GPG_PRIVATE_KEY }} | ||
passphrase: ${{ secrets.MVN_CENTRAL_GPG_PASSPHRASE }} | ||
|
||
- name: Release to Maven repo | ||
run: | | ||
mvn -P release -Dgpg.passphrase=${{ secrets.MVN_CENTRAL_GPG_PASSPHRASE }} \ | ||
-Drevision=${{ steps.upgrade.outputs.version }} deploy | ||
env: | ||
MVN_CENTRAL_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }} | ||
MVN_CENTRAL_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }} | ||
|
||
- name: Github Release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
fail_on_unmatched_files: true | ||
tag_name: ${{ steps.upgrade.outputs.tag_name }} | ||
files: visual-java/target/java-client-${{ steps.upgrade.outputs.version }}.jar | ||
generate_release_notes: true |
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,45 @@ | ||
#!/bin/bash | ||
|
||
# Function to bump version based on release type | ||
bump_version() { | ||
local version=$1 | ||
local release_type=$2 | ||
|
||
# Split the version into parts | ||
IFS='.' read -r -a version_parts <<< "$version" | ||
|
||
# Increment the appropriate part based on release type | ||
case "$release_type" in | ||
"major") ((version_parts[0]++)); version_parts[1]=0; version_parts[2]=0;; | ||
"minor") ((version_parts[1]++)); version_parts[2]=0;; | ||
"patch") ((version_parts[2]++));; | ||
*) echo "Invalid release type"; exit 1;; | ||
esac | ||
|
||
# Join the parts back into a single version string | ||
new_version="${version_parts[0]}.${version_parts[1]}.${version_parts[2]}" | ||
echo "$new_version" | ||
} | ||
|
||
# Main script starts here | ||
|
||
# Parse command line options | ||
while getopts ":c:r:" opt; do | ||
case $opt in | ||
c) current_version="$OPTARG";; | ||
r) release_type="$OPTARG";; | ||
\?) echo "Invalid option: -$OPTARG" >&2; exit 1;; | ||
:) echo "Option -$OPTARG requires an argument." >&2; exit 1;; | ||
esac | ||
done | ||
|
||
# Check if current_version and release_type are provided | ||
if [ -z "$current_version" ] || [ -z "$release_type" ]; then | ||
echo "Usage: $0 -c <currentVersion> -r <releaseType>" | ||
exit 1 | ||
fi | ||
|
||
# Bump the version | ||
new_version=$(bump_version "$current_version" "$release_type") | ||
|
||
echo "$new_version" |