-
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.
Automatically build and publish the Java package.
- Loading branch information
Showing
1 changed file
with
45 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,45 @@ | ||
name: GitHub Packages Maven Publish | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
release: | ||
types: | ||
- created | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
|
||
- name: Update the current version. | ||
working-directory: ./java | ||
run: | | ||
# Extract the tag or commit hash from GITHUB_REF | ||
if [[ "$GITHUB_REF" =~ refs/tags/.* ]]; then | ||
# Extract the tag from GITHUB_REF | ||
VERSION=$(echo "${GITHUB_REF}" | sed -n 's|refs/tags/\(.*\)|\1|p') | ||
else | ||
# Use the short commit hash as the version | ||
VERSION=$(git rev-parse --short HEAD) | ||
fi | ||
mvn versions:set -DnewVersion="$VERSION" | ||
echo "" | ||
echo "Version has been updated to $VERSION." | ||
- name: Build and deploy to GitHub Packages | ||
working-directory: ./java | ||
run: mvn --batch-mode deploy -DaltDeploymentRepository="github::default::https://maven.pkg.github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |