-
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.
chore: Update repository URLs in pom.xml and refactor GitHub Actions …
…workflow - Changed the repository URL in pom.xml to reflect the new GitHub repository name. - Streamlined the GitHub Actions workflow by updating the JDK setup and removing unnecessary steps. - Enhanced the build process by ensuring compatibility with the latest GitHub Actions versions and simplifying the deployment commands.
- Loading branch information
Marvin Zhang
committed
Jan 3, 2025
1 parent
14bc4a5
commit e3942b1
Showing
2 changed files
with
32 additions
and
57 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 |
---|---|---|
@@ -1,62 +1,37 @@ | ||
name: Publish to Maven Central | ||
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created | ||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path | ||
|
||
name: Maven Package | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
branches: [main] | ||
|
||
jobs: | ||
publish: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: central # Maven settings server id | ||
server-username: ${{ secrets.OSSRH_USERNAME }} | ||
server-password: ${{ secrets.OSSRH_PASSWORD }} | ||
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} | ||
|
||
- name: Cache Maven dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-m2- | ||
- name: Setup Maven settings | ||
run: | | ||
mkdir -p ~/.m2 | ||
echo "<settings> | ||
<servers> | ||
<server> | ||
<id>central</id> | ||
<username>${{ secrets.OSSRH_USERNAME }}</username> | ||
<password>${{ secrets.OSSRH_PASSWORD }}</password> | ||
</server> | ||
</servers> | ||
</settings>" > ~/.m2/settings.xml | ||
- name: Import GPG key | ||
run: | | ||
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import | ||
env: | ||
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
|
||
- name: Set GPG_TTY | ||
run: echo "export GPG_TTY=$(tty)" >> $GITHUB_ENV | ||
|
||
- name: Reload gpg-agent | ||
run: gpg-connect-agent reloadagent /bye | ||
|
||
- name: Build and Test | ||
run: mvn clean test | ||
|
||
- name: Build and Publish | ||
run: mvn clean deploy -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | ||
settings-path: ${{ github.workspace }} # location for the settings.xml file | ||
|
||
- name: Build and Test | ||
run: mvn clean test | ||
|
||
- name: Build with Maven | ||
run: mvn -B package --file pom.xml | ||
|
||
- name: Publish to GitHub Packages Apache Maven | ||
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml | ||
env: | ||
GITHUB_TOKEN: ${{ github.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