Skip to content

Commit 7f34177

Browse files
author
Marvin Zhang
committed
chore: Update pom.xml versioning and refine GitHub Actions workflow for publishing
- Changed versioning in pom.xml to use a property for better maintainability. - Removed the distribution management section from pom.xml to simplify configuration. - Enhanced GitHub Actions workflow by renaming jobs for clarity and separating snapshot and release publishing processes. - Updated Java setup steps in the workflow to ensure compatibility with the current project requirements.
1 parent 0f3178d commit 7f34177

File tree

2 files changed

+24
-31
lines changed

2 files changed

+24
-31
lines changed

.github/workflows/publish.yml

+20-15
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,30 @@ on:
1111
types: [published]
1212

1313
jobs:
14-
publish:
14+
publish-snapshot:
15+
name: Publish Snapshot
16+
if: github.event_name == 'push' || github.event_name == 'pull_request'
1517
runs-on: ubuntu-latest
1618
steps:
1719
- uses: actions/checkout@v3
18-
19-
- name: Setup
20-
id: setup
20+
- name: Set up Java for publishing to GitHub Packages
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
- name: Publish package
2126
run: |
22-
# set PROFILE according to the event
23-
if [ -n "${{ github.event.release }}" ]; then
24-
echo "PROFILE=release" >> $GITHUB_ENV
25-
else
26-
echo "PROFILE=snapshot" >> $GITHUB_ENV
27-
fi
28-
echo "PROFILE: ${PROFILE}"
27+
mvn -P snapshot --batch-mode deploy
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2930

30-
- name: Set up Maven Central Repository
31-
id: setup-maven
31+
publish-release:
32+
name: Publish Release
33+
if: github.event_name == 'release'
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v3
37+
- name: Set up Java for publishing to Maven Central
3238
uses: actions/setup-java@v4
3339
with:
3440
java-version: '17'
@@ -38,10 +44,9 @@ jobs:
3844
server-password: MAVEN_PASSWORD
3945
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
4046
gpg-passphrase: MAVEN_GPG_PASSPHRASE
41-
4247
- name: Publish package
4348
run: |
44-
mvn -P ${{ env.PROFILE }} --batch-mode deploy
49+
mvn -P release --batch-mode deploy
4550
env:
4651
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
4752
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}

pom.xml

+4-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>io.crawlab</groupId>
77
<artifactId>crawlab-sdk</artifactId>
8-
<version>0.7.0-SNAPSHOT</version>
8+
<version>${project.version}</version>
99
<packaging>jar</packaging>
1010

1111
<name>Crawlab SDK</name>
@@ -30,22 +30,10 @@
3030
<url>https://github.com/crawlab-team/crawlab-java-sdk</url>
3131
</scm>
3232

33-
<distributionManagement>
34-
<repository>
35-
<id>central</id>
36-
<name>Central Repository</name>
37-
<url>https://central.sonatype.com/content/repositories/releases</url>
38-
</repository>
39-
<snapshotRepository>
40-
<id>central</id>
41-
<name>Central Snapshots</name>
42-
<url>https://central.sonatype.com/content/repositories/snapshots</url>
43-
</snapshotRepository>
44-
</distributionManagement>
45-
4633
<properties>
4734
<maven.compiler.source>17</maven.compiler.source>
4835
<maven.compiler.target>17</maven.compiler.target>
36+
<project.version>0.7.0</project.version>
4937
</properties>
5038

5139
<dependencies>
@@ -133,7 +121,7 @@
133121
</plugins>
134122
</build>
135123
<properties>
136-
<version>0.7.0</version>
124+
<version>${project.version}</version>
137125
</properties>
138126
</profile>
139127

@@ -187,7 +175,7 @@
187175
</plugins>
188176
</build>
189177
<properties>
190-
<version>0.7.0-SNAPSHOT</version>
178+
<version>${project.version}-SNAPSHOT</version>
191179
</properties>
192180
</profile>
193181
</profiles>

0 commit comments

Comments
 (0)