Skip to content

Commit e3942b1

Browse files
author
Marvin Zhang
committed
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.
1 parent 14bc4a5 commit e3942b1

File tree

2 files changed

+32
-57
lines changed

2 files changed

+32
-57
lines changed

.github/workflows/publish.yml

+30-55
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,37 @@
1-
name: Publish to Maven Central
1+
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
2+
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
3+
4+
name: Maven Package
25

36
on:
47
push:
5-
branches:
6-
- main
8+
branches: [main]
79

810
jobs:
9-
publish:
11+
build:
12+
1013
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
1118
steps:
12-
- uses: actions/checkout@v3
13-
14-
- name: Set up JDK 17
15-
uses: actions/setup-java@v3
16-
with:
17-
java-version: '17'
18-
distribution: 'temurin'
19-
server-id: central # Maven settings server id
20-
server-username: ${{ secrets.OSSRH_USERNAME }}
21-
server-password: ${{ secrets.OSSRH_PASSWORD }}
22-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
23-
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
24-
25-
- name: Cache Maven dependencies
26-
uses: actions/cache@v3
27-
with:
28-
path: ~/.m2/repository
29-
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
30-
restore-keys: |
31-
${{ runner.os }}-m2-
32-
33-
- name: Setup Maven settings
34-
run: |
35-
mkdir -p ~/.m2
36-
echo "<settings>
37-
<servers>
38-
<server>
39-
<id>central</id>
40-
<username>${{ secrets.OSSRH_USERNAME }}</username>
41-
<password>${{ secrets.OSSRH_PASSWORD }}</password>
42-
</server>
43-
</servers>
44-
</settings>" > ~/.m2/settings.xml
45-
46-
- name: Import GPG key
47-
run: |
48-
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
49-
env:
50-
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
51-
52-
- name: Set GPG_TTY
53-
run: echo "export GPG_TTY=$(tty)" >> $GITHUB_ENV
54-
55-
- name: Reload gpg-agent
56-
run: gpg-connect-agent reloadagent /bye
57-
58-
- name: Build and Test
59-
run: mvn clean test
60-
61-
- name: Build and Publish
62-
run: mvn clean deploy -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }}
19+
- uses: actions/checkout@v4
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
26+
settings-path: ${{ github.workspace }} # location for the settings.xml file
27+
28+
- name: Build and Test
29+
run: mvn clean test
30+
31+
- name: Build with Maven
32+
run: mvn -B package --file pom.xml
33+
34+
- name: Publish to GitHub Packages Apache Maven
35+
run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml
36+
env:
37+
GITHUB_TOKEN: ${{ github.token }}

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010

1111
<name>Crawlab SDK</name>
1212
<description>Crawlab SDK for Java</description>
13-
<url>https://github.com/crawlab-team/crawlab-sdk-java</url>
13+
<url>https://github.com/crawlab-team/crawlab-java-sdk</url>
1414
<licenses>
1515
<license>
1616
<name>BSD 3-Clause License</name>
17-
<url>https://github.com/crawlab-team/crawlab-sdk-java/blob/main/LICENSE</url>
17+
<url>https://github.com/crawlab-team/crawlab-java-sdk/blob/main/LICENSE</url>
1818
</license>
1919
</licenses>
2020
<developers>

0 commit comments

Comments
 (0)