-
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.
fix: publish to maven central, workflow permission cleanup (#90)
- Loading branch information
Showing
6 changed files
with
177 additions
and
23 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Build | ||
name: Build & Release | ||
on: | ||
workflow_dispatch: | ||
push: | ||
|
@@ -9,25 +9,31 @@ on: | |
- '**/pom.xml' | ||
- 'pom.xml' | ||
|
||
concurrency: | ||
group: ci-main | ||
|
||
permissions: | ||
# used by semantic release | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
# used to publish the jar to github packages | ||
packages: write | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
# used by semantic release | ||
contents: write | ||
# used to publish the jar to github packages | ||
packages: write | ||
outputs: | ||
new-release-published: ${{ steps.semantic-release.outputs.new_release_published }} | ||
new-release-version: ${{ steps.semantic-release.outputs.new_release_version }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@v4.1.7 | ||
with: | ||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
uses: actions/setup-java@v4.2.2 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
@@ -36,11 +42,51 @@ jobs: | |
- name: Run Tests | ||
run: mvn -B -ntp clean install | ||
|
||
- name: Create new release | ||
uses: cycjimmy/semantic-release-action@v3 | ||
- name: Import GPG key | ||
uses: crazy-max/[email protected] | ||
with: | ||
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} | ||
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | ||
|
||
- id: semantic-release | ||
name: Create new Release | ||
uses: cycjimmy/[email protected] | ||
with: | ||
extra_plugins: | | ||
@semantic-release/git | ||
@semantic-release/exec | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | ||
|
||
publish-maven-central: | ||
name: Publish to Maven Central | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: needs.build.outputs.new-release-published == 'true' | ||
steps: | ||
- uses: actions/[email protected] | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/[email protected] | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
server-id: ossrh | ||
server-username: MAVEN_USERNAME | ||
server-password: MAVEN_PASSWORD | ||
|
||
- name: Import GPG Key | ||
uses: crazy-max/[email protected] | ||
with: | ||
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} | ||
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | ||
|
||
- name: Publish Package | ||
run: | | ||
mvn -B -ntp versions:set -DgenerateBackupPoms=false -DnewVersion=${{ needs.build.outputs.new-release-version }} | ||
mvn -B -ntp -Psign-with-gpg -Ppublish-ossrh clean deploy -DskipTests -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} | ||
env: | ||
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} |
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
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