-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out snapshot workflow from release workflow and make them reusable
- Loading branch information
1 parent
1d10f29
commit 5fb9e8f
Showing
2 changed files
with
122 additions
and
61 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
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,46 @@ | ||
name: "Publish: manual OR automatic snapshot" | ||
|
||
on: | ||
workflow_call: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
# Output project version from the POM to conditionally run dependent steps | ||
project-version: ${{ steps.project_version.outputs.version }} | ||
steps: | ||
- name: Checkout latest code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Java & Maven | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: 'maven' | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
gpg-private-key: ${{ secrets.MAVEN_GPG_KEY }} | ||
gpg-passphrase: MAVEN_GPG_PASSPHRASE | ||
|
||
- name: Get project version from POM | ||
id: project_version | ||
run: echo "VERSION=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout`" >> $GITHUB_OUTPUT | ||
|
||
# Run only if project POM has version ending in "-SNAPSHOT" | ||
snapshot: | ||
needs: setup | ||
if: endsWith(needs.setup.outputs.project-version, '-SNAPSHOT') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Publish SNAPSHOT | ||
run: mvn -B -ntp clean deploy | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |