Skip to content

Commit

Permalink
chore: Update repository URLs in pom.xml and refactor GitHub Actions …
Browse files Browse the repository at this point in the history
…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
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 57 deletions.
85 changes: 30 additions & 55 deletions .github/workflows/publish.yml
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 }}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

<name>Crawlab SDK</name>
<description>Crawlab SDK for Java</description>
<url>https://github.com/crawlab-team/crawlab-sdk-java</url>
<url>https://github.com/crawlab-team/crawlab-java-sdk</url>
<licenses>
<license>
<name>BSD 3-Clause License</name>
<url>https://github.com/crawlab-team/crawlab-sdk-java/blob/main/LICENSE</url>
<url>https://github.com/crawlab-team/crawlab-java-sdk/blob/main/LICENSE</url>
</license>
</licenses>
<developers>
Expand Down

0 comments on commit e3942b1

Please sign in to comment.