Skip to content

Commit 1ba643a

Browse files
committed
add workflow
1 parent ca6de27 commit 1ba643a

3 files changed

Lines changed: 76 additions & 2 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Publish to Maven Central
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Extract version from tag
17+
id: version
18+
run: |
19+
TAG="${GITHUB_REF_NAME}"
20+
VERSION="${TAG#v}"
21+
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
22+
echo "Tag '$TAG' does not look like a semver release (expected vX.Y.Z)" >&2
23+
exit 1
24+
fi
25+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
26+
echo "Publishing version: $VERSION"
27+
28+
- name: Set up JDK 25
29+
uses: actions/setup-java@v4
30+
with:
31+
java-version: '25'
32+
distribution: 'temurin'
33+
server-id: central
34+
server-username: MAVEN_CENTRAL_USERNAME
35+
server-password: MAVEN_CENTRAL_PASSWORD
36+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
37+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
38+
39+
- name: Configure GPG for non-interactive signing
40+
run: |
41+
mkdir -p ~/.gnupg
42+
chmod 700 ~/.gnupg
43+
echo "pinentry-mode loopback" >> ~/.gnupg/gpg.conf
44+
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
45+
echo "use-agent" >> ~/.gnupg/gpg.conf
46+
gpgconf --reload gpg-agent || true
47+
48+
- name: Cache Maven packages
49+
uses: actions/cache@v4
50+
with:
51+
path: ~/.m2/repository
52+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
53+
restore-keys: ${{ runner.os }}-m2
54+
55+
- name: Verify pom.xml version matches tag
56+
run: |
57+
POM_VERSION=$(mvn -B -q -DforceStdout help:evaluate -Dexpression=project.version)
58+
TAG_VERSION="${{ steps.version.outputs.version }}"
59+
if [ "$POM_VERSION" != "$TAG_VERSION" ]; then
60+
echo "::error::Version mismatch — tag is '$TAG_VERSION' but pom.xml has '$POM_VERSION'."
61+
echo "::error::Bump pom.xml first: mvn versions:set -DnewVersion=$TAG_VERSION -DgenerateBackupPoms=false"
62+
echo "::error::Then commit, tag, and push again."
63+
exit 1
64+
fi
65+
echo "pom.xml version matches tag: $POM_VERSION"
66+
67+
- name: Publish to Maven Central
68+
env:
69+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
70+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
71+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
72+
run: mvn -B -P sign-artifacts -DskipTests clean deploy

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ hs_err_pid*
1919
target
2020
.gradle
2121
build
22+
.idea/*

‎pom.xml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<artifactId>dataforseo-client</artifactId>
66
<packaging>jar</packaging>
77
<name>dataforseo-client</name>
8-
<version>2.0.20</version>
8+
<version>2.0.21</version>
99
<url>https://github.com/dataforseo/JavaClient</url>
1010
<description>API client that provide services of DataForSeo API. For more information about client code generation, please follow to github </description>
1111
<scm>
@@ -37,11 +37,12 @@
3737
<plugin>
3838
<groupId>org.sonatype.central</groupId>
3939
<artifactId>central-publishing-maven-plugin</artifactId>
40-
<version>0.3.0</version>
40+
<version>0.10.0</version>
4141
<extensions>true</extensions>
4242
<configuration>
4343
<publishingServerId>central</publishingServerId>
4444
<tokenAuth>true</tokenAuth>
45+
<autoPublish>true</autoPublish>
4546
</configuration>
4647
</plugin>
4748

0 commit comments

Comments
 (0)