Skip to content

Commit 5a3910b

Browse files
committed
Update version to 0.1.12 in pom.xml and modify GitHub Actions workflows to use JDK 17. Refactor build steps to include testing, code style checks, and Javadoc generation, enhancing the CI process.
1 parent bd0ff09 commit 5a3910b

File tree

3 files changed

+108
-167
lines changed

3 files changed

+108
-167
lines changed

.github/workflows/publish.yml

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -7,96 +7,97 @@ on:
77
types: [created]
88

99
jobs:
10-
publish:
10+
build:
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- uses: actions/checkout@v3
15-
16-
- name: Set up JDK 11
15+
16+
- name: Set up JDK 17
1717
uses: actions/setup-java@v3
1818
with:
19-
java-version: '11'
19+
java-version: '17'
2020
distribution: 'temurin'
21-
cache: 'maven'
22-
server-id: ossrh
23-
server-username: ${{ secrets.OSSRH_USERNAME }}
24-
server-password: ${{ secrets.OSSRH_TOKEN }}
25-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
26-
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
27-
settings-path: ${{ github.workspace }}
28-
29-
- name: Set Version
30-
id: set_version
31-
uses: actions/github-script@v4
32-
if: github.event_name == 'release'
33-
with:
34-
script: |
35-
const noRef = context.ref.replace('refs/tags/', '')
36-
const noPrefix = noRef.replace('v', '')
37-
core.setOutput('version', noPrefix)
38-
39-
- name: Build with Maven
40-
run: mvn -B package --file pom.xml
41-
42-
- name: Run tests
43-
run: mvn -B test --file pom.xml
44-
45-
- name: Check code style
46-
run: mvn -B checkstyle:check --file pom.xml
47-
48-
- name: Generate Javadoc
49-
run: mvn -B javadoc:javadoc --file pom.xml
50-
51-
- name: Publish to Maven Central
52-
run: |
53-
if [ "${{ github.event_name }}" == "release" ]; then
54-
mvn --batch-mode versions:set -DnewVersion=${{ steps.set_version.outputs.version }}
55-
fi
56-
mvn --batch-mode deploy -P release
57-
env:
58-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
59-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
60-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
21+
cache: maven
6122

62-
- name: Wait for Maven Central Sync
63-
if: github.event_name == 'release'
23+
- name: Import GPG key
6424
run: |
65-
echo "Waiting for artifacts to sync to Maven Central..."
66-
# Wait for up to 30 minutes (180 * 10 seconds)
67-
for i in {1..180}; do
68-
STATUS=$(curl -s -o /dev/null -w "%{http_code}" https://repo1.maven.org/maven2/com/notificationapi/notificationapi-java-server-sdk/${{ steps.set_version.outputs.version }}/)
69-
if [ $STATUS -eq 200 ]; then
70-
echo "✅ Artifacts found in Maven Central!"
71-
break
72-
fi
73-
echo "Attempt $i: Artifacts not yet available (status: $STATUS). Waiting 10 seconds..."
74-
sleep 10
75-
done
76-
if [ $STATUS -ne 200 ]; then
77-
echo "❌ Timeout waiting for artifacts to appear in Maven Central"
78-
exit 1
79-
fi
25+
# Setup GPG directory
26+
mkdir -p ~/.gnupg
27+
chmod 700 ~/.gnupg
28+
29+
# Write key to file
30+
echo "${{ secrets.GPG_PRIVATE_KEY }}" > ~/private.key
31+
32+
# Import the key
33+
gpg --batch --import ~/private.key
34+
35+
# Clean up
36+
rm ~/private.key
37+
38+
# Extract key ID from the imported key
39+
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)
40+
echo "Imported GPG key ID: $GPG_KEY_ID"
41+
echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV
8042
81-
- name: Verify Maven Central Artifacts
82-
if: github.event_name == 'release'
43+
- name: Build and Publish with Maven
44+
env:
45+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
46+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
47+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
8348
run: |
84-
VERSION=${{ steps.set_version.outputs.version }}
85-
BASE_URL="https://repo1.maven.org/maven2/com/notificationapi/notificationapi-java-server-sdk/$VERSION/notificationapi-java-server-sdk-$VERSION"
49+
# Create settings.xml file
50+
mkdir -p ~/.m2
51+
cat > ~/.m2/settings.xml << EOF
52+
<?xml version="1.0" encoding="UTF-8"?>
53+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
54+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
56+
<servers>
57+
<server>
58+
<id>central</id>
59+
<username>\${env.OSSRH_USERNAME}</username>
60+
<password>\${env.OSSRH_TOKEN}</password>
61+
</server>
62+
<server>
63+
<id>gpg.passphrase</id>
64+
<passphrase>\${env.GPG_PASSPHRASE}</passphrase>
65+
</server>
66+
</servers>
67+
<profiles>
68+
<profile>
69+
<id>gpg</id>
70+
<properties>
71+
<gpg.keyname>\${env.GPG_KEY_ID}</gpg.keyname>
72+
<gpg.passphrase>\${env.GPG_PASSPHRASE}</gpg.passphrase>
73+
<gpg.executable>gpg</gpg.executable>
74+
</properties>
75+
</profile>
76+
<profile>
77+
<id>central</id>
78+
<activation>
79+
<activeByDefault>true</activeByDefault>
80+
</activation>
81+
<properties>
82+
<central.username>\${env.OSSRH_USERNAME}</central.username>
83+
<central.password>\${env.OSSRH_TOKEN}</central.password>
84+
</properties>
85+
</profile>
86+
</profiles>
87+
<activeProfiles>
88+
<activeProfile>gpg</activeProfile>
89+
<activeProfile>central</activeProfile>
90+
</activeProfiles>
91+
</settings>
92+
EOF
8693
87-
# List of expected files
88-
FILES=(".jar" ".jar.asc" ".pom" ".pom.asc" "-javadoc.jar" "-javadoc.jar.asc" "-sources.jar" "-sources.jar.asc")
94+
# Debug GPG configuration
95+
echo "Using GPG key ID: $GPG_KEY_ID"
96+
gpg --list-keys $GPG_KEY_ID
8997
90-
echo "Verifying all artifacts for version $VERSION..."
91-
for FILE in "${FILES[@]}"; do
92-
URL="$BASE_URL$FILE"
93-
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" $URL)
94-
if [ $HTTP_CODE -eq 200 ]; then
95-
echo "✅ Found $FILE"
96-
else
97-
echo "❌ Missing $FILE (HTTP $HTTP_CODE)"
98-
exit 1
99-
fi
100-
done
101-
echo "✅ All required artifacts verified in Maven Central!"
102-
98+
# Set environment variables and run Maven with debug for GPG
99+
export OSSRH_USERNAME=${{ secrets.OSSRH_USERNAME }}
100+
export OSSRH_TOKEN="${{ secrets.OSSRH_TOKEN }}"
101+
export GPG_PASSPHRASE=${{ secrets.GPG_PASSPHRASE }}
102+
103+
mvn clean deploy -Dgpg.keyname=$GPG_KEY_ID -Dgpg.passphrase=$GPG_PASSPHRASE -Dcentral.username=$OSSRH_USERNAME -Dcentral.password=$OSSRH_TOKEN --settings ~/.m2/settings.xml

.github/workflows/pull-request.yml

Lines changed: 26 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Pull Request CI
1+
name: Pull Request Pipeline
22

33
on:
44
pull_request:
@@ -7,95 +7,35 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
java: [ '11', '17' ]
1013

1114
steps:
1215
- uses: actions/checkout@v3
13-
14-
- name: Set up JDK 17
16+
17+
- name: Set up JDK ${{ matrix.java }}
1518
uses: actions/setup-java@v3
1619
with:
17-
java-version: '17'
20+
java-version: ${{ matrix.java }}
1821
distribution: 'temurin'
19-
cache: maven
20-
21-
- name: Import GPG key
22-
run: |
23-
# Setup GPG directory
24-
mkdir -p ~/.gnupg
25-
chmod 700 ~/.gnupg
26-
27-
# Write key to file
28-
echo "${{ secrets.GPG_PRIVATE_KEY }}" > ~/private.key
29-
30-
# Import the key
31-
gpg --batch --import ~/private.key
32-
33-
# Clean up
34-
rm ~/private.key
35-
36-
# Extract key ID from the imported key
37-
GPG_KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | cut -d'/' -f2)
38-
echo "Imported GPG key ID: $GPG_KEY_ID"
39-
echo "GPG_KEY_ID=$GPG_KEY_ID" >> $GITHUB_ENV
40-
41-
- name: Build and Publish with Maven
42-
env:
43-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
44-
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
45-
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
46-
run: |
47-
# Create settings.xml file
48-
mkdir -p ~/.m2
49-
cat > ~/.m2/settings.xml << EOF
50-
<?xml version="1.0" encoding="UTF-8"?>
51-
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
52-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53-
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
54-
<servers>
55-
<server>
56-
<id>central</id>
57-
<username>\${env.OSSRH_USERNAME}</username>
58-
<password>\${env.OSSRH_TOKEN}</password>
59-
</server>
60-
<server>
61-
<id>gpg.passphrase</id>
62-
<passphrase>\${env.GPG_PASSPHRASE}</passphrase>
63-
</server>
64-
</servers>
65-
<profiles>
66-
<profile>
67-
<id>gpg</id>
68-
<properties>
69-
<gpg.keyname>\${env.GPG_KEY_ID}</gpg.keyname>
70-
<gpg.passphrase>\${env.GPG_PASSPHRASE}</gpg.passphrase>
71-
<gpg.executable>gpg</gpg.executable>
72-
</properties>
73-
</profile>
74-
<profile>
75-
<id>central</id>
76-
<activation>
77-
<activeByDefault>true</activeByDefault>
78-
</activation>
79-
<properties>
80-
<central.username>\${env.OSSRH_USERNAME}</central.username>
81-
<central.password>\${env.OSSRH_TOKEN}</central.password>
82-
</properties>
83-
</profile>
84-
</profiles>
85-
<activeProfiles>
86-
<activeProfile>gpg</activeProfile>
87-
<activeProfile>central</activeProfile>
88-
</activeProfiles>
89-
</settings>
90-
EOF
91-
92-
# Debug GPG configuration
93-
echo "Using GPG key ID: $GPG_KEY_ID"
94-
gpg --list-keys $GPG_KEY_ID
95-
96-
# Set environment variables and run Maven with debug for GPG
97-
export OSSRH_USERNAME=${{ secrets.OSSRH_USERNAME }}
98-
export OSSRH_TOKEN="${{ secrets.OSSRH_TOKEN }}"
99-
export GPG_PASSPHRASE=${{ secrets.GPG_PASSPHRASE }}
22+
cache: 'maven'
23+
server-id: central
24+
server-username: ${{ secrets.OSSRH_USERNAME }}
25+
server-password: ${{ secrets.OSSRH_TOKEN }}
26+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
27+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
28+
settings-path: ${{ github.workspace }}
10029

101-
mvn clean deploy -Dgpg.keyname=$GPG_KEY_ID -Dgpg.passphrase=$GPG_PASSPHRASE -Dcentral.username=$OSSRH_USERNAME -Dcentral.password=$OSSRH_TOKEN --settings ~/.m2/settings.xml
30+
- name: Build with Maven
31+
run: mvn -B package --file pom.xml
32+
33+
- name: Run tests
34+
run: mvn -B test --file pom.xml
35+
36+
- name: Check code style
37+
run: mvn -B checkstyle:check --file pom.xml
38+
39+
- name: Generate Javadoc
40+
run: mvn -B javadoc:javadoc --file pom.xml
41+

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.notificationapi</groupId>
88
<artifactId>notificationapi-java-server-sdk</artifactId>
9-
<version>0.1.11</version>
9+
<version>0.1.12</version>
1010
<packaging>jar</packaging>
1111

1212
<!-- Project metadata -->

0 commit comments

Comments
 (0)