Skip to content

Commit

Permalink
Automatically build and publish the Java package.
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed May 2, 2024
1 parent 91802d8 commit 3faa15c
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/java-package.yml
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 }}

0 comments on commit 3faa15c

Please sign in to comment.