Skip to content

Commit 7905469

Browse files
author
Christine Zhou
committed
Updating PEx github action
1 parent 5367942 commit 7905469

File tree

3 files changed

+114
-45
lines changed

3 files changed

+114
-45
lines changed

.github/workflows/maven-publish.yml

Lines changed: 102 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,109 @@
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 Publish
1+
name: Publish to Maven Central
52

63
on:
7-
push:
8-
branches: [ "maven-publish-**" ]
4+
release:
5+
types: [published]
96
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to publish (e.g., 0.4.1)'
10+
required: true
11+
type: string
1012

1113
jobs:
12-
Maven-Publish-Ubuntu:
14+
publish:
1315
runs-on: ubuntu-latest
16+
1417
steps:
15-
- uses: actions/checkout@v3
16-
- name: Set up Java for publishing to Maven Central Repository
17-
uses: actions/setup-java@v3
18-
with:
19-
distribution: 'temurin'
20-
java-version: '11'
21-
server-id: ossrh
22-
server-username: MAVEN_USERNAME
23-
server-password: MAVEN_PASSWORD
24-
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} # Value of the GPG private key to import
25-
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
26-
- name: Publish to the Maven Central Repository
27-
working-directory: Src/PRuntimes/PSymRuntime
28-
run: mvn --batch-mode deploy -P release -Dmaven.test.skip
29-
env:
30-
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
31-
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
32-
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
33-
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 17
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '17'
25+
distribution: 'temurin'
26+
27+
- name: Cache Maven dependencies
28+
uses: actions/cache@v3
29+
with:
30+
path: ~/.m2
31+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
32+
restore-keys: ${{ runner.os }}-m2
33+
34+
- name: Import GPG key
35+
uses: crazy-max/ghaction-import-gpg@v6
36+
with:
37+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
38+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
39+
40+
- name: Extract version from release
41+
id: get_version
42+
run: |
43+
if [ "${{ github.event_name }}" = "release" ]; then
44+
VERSION=${{ github.event.release.tag_name }}
45+
# Remove 'v' prefix if present
46+
VERSION=${VERSION#v}
47+
else
48+
VERSION=${{ github.event.inputs.version }}
49+
fi
50+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
51+
echo "Publishing version: $VERSION"
52+
53+
- name: Update PEx version
54+
run: |
55+
cd Src/PEx
56+
# Update the revision property in pom.xml
57+
sed -i "s/<revision>.*<\/revision>/<revision>${{ steps.get_version.outputs.VERSION }}<\/revision>/" pom.xml
58+
echo "Updated PEx version to ${{ steps.get_version.outputs.VERSION }}"
59+
60+
- name: Create Maven settings.xml
61+
run: |
62+
mkdir -p ~/.m2
63+
cat > ~/.m2/settings.xml << 'EOF'
64+
<?xml version="1.0" encoding="UTF-8"?>
65+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
66+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
67+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
68+
http://maven.apache.org/xsd/settings-1.0.0.xsd">
69+
<servers>
70+
<server>
71+
<id>central</id>
72+
<username>${{ secrets.MAVEN_USERNAME }}</username>
73+
<password>${{ secrets.MAVEN_PASSWORD }}</password>
74+
</server>
75+
<server>
76+
<id>gpg.passphrase</id>
77+
<passphrase>${{ secrets.GPG_PASSPHRASE }}</passphrase>
78+
</server>
79+
</servers>
80+
</settings>
81+
EOF
82+
83+
- name: Publish to Maven Central
84+
run: |
85+
cd Src/PEx
86+
mvn clean deploy -P release -DskipTests
87+
env:
88+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
89+
90+
- name: Create deployment summary
91+
run: |
92+
echo "## 🚀 Maven Central Deployment" >> $GITHUB_STEP_SUMMARY
93+
echo "Successfully published **PEx ${{ steps.get_version.outputs.VERSION }}** to Maven Central!" >> $GITHUB_STEP_SUMMARY
94+
echo "" >> $GITHUB_STEP_SUMMARY
95+
echo "### 📦 Artifact Details" >> $GITHUB_STEP_SUMMARY
96+
echo "- **Group ID:** io.github.p-org" >> $GITHUB_STEP_SUMMARY
97+
echo "- **Artifact ID:** pex" >> $GITHUB_STEP_SUMMARY
98+
echo "- **Version:** ${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
99+
echo "" >> $GITHUB_STEP_SUMMARY
100+
echo "### 📋 Maven Dependency" >> $GITHUB_STEP_SUMMARY
101+
echo '```xml' >> $GITHUB_STEP_SUMMARY
102+
echo '<dependency>' >> $GITHUB_STEP_SUMMARY
103+
echo ' <groupId>io.github.p-org</groupId>' >> $GITHUB_STEP_SUMMARY
104+
echo ' <artifactId>pex</artifactId>' >> $GITHUB_STEP_SUMMARY
105+
echo " <version>${{ steps.get_version.outputs.VERSION }}</version>" >> $GITHUB_STEP_SUMMARY
106+
echo '</dependency>' >> $GITHUB_STEP_SUMMARY
107+
echo '```' >> $GITHUB_STEP_SUMMARY
108+
echo "" >> $GITHUB_STEP_SUMMARY
109+
echo "🔗 [View on Maven Central](https://central.sonatype.com/artifact/io.github.p-org/pex/${{ steps.get_version.outputs.VERSION }})" >> $GITHUB_STEP_SUMMARY

Src/PCompiler/CompilerCore/Backend/PEx/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal class Constants
6363
<dependency>
6464
<groupId>io.github.p-org</groupId>
6565
<artifactId>pex</artifactId>
66-
<version>[0.3.0,)</version>
66+
<version>[0.4.0,)</version>
6767
</dependency>
6868
6969
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->

Src/PEx/pom.xml

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,15 @@
119119
<build>
120120
<plugins>
121121
<plugin>
122-
<groupId>org.sonatype.plugins</groupId>
123-
<artifactId>nexus-staging-maven-plugin</artifactId>
124-
<version>1.6.13</version>
122+
<groupId>org.sonatype.central</groupId>
123+
<artifactId>central-publishing-maven-plugin</artifactId>
124+
<version>0.4.0</version>
125125
<extensions>true</extensions>
126126
<configuration>
127-
<serverId>ossrh</serverId>
128-
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
129-
<autoReleaseAfterClose>true</autoReleaseAfterClose>
127+
<publishingServerId>central</publishingServerId>
128+
<tokenAuth>true</tokenAuth>
129+
<autoPublish>true</autoPublish>
130+
<waitUntil>published</waitUntil>
130131
</configuration>
131132
</plugin>
132133
<plugin>
@@ -246,7 +247,7 @@
246247
<plugin>
247248
<groupId>org.apache.maven.plugins</groupId>
248249
<artifactId>maven-gpg-plugin</artifactId>
249-
<version>1.5</version>
250+
<version>3.0.1</version>
250251
<executions>
251252
<execution>
252253
<id>sign-artifacts</id>
@@ -263,17 +264,9 @@
263264
</profiles>
264265

265266
<distributionManagement>
266-
<snapshotRepository>
267-
<id>ossrh</id>
268-
<url>
269-
https://s01.oss.sonatype.org/content/repositories/snapshots
270-
</url>
271-
</snapshotRepository>
272267
<repository>
273-
<id>ossrh</id>
274-
<url>
275-
https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
276-
</url>
268+
<id>central</id>
269+
<url>https://central.sonatype.com/api/v1/publisher/deployments/upload/</url>
277270
</repository>
278271
</distributionManagement>
279272

@@ -283,7 +276,7 @@
283276
<maven.compiler.target>${java.version}</maven.compiler.target>
284277
<log4j2.configurationFile>${project.basedir}/src/main/resources/log4j2.xml</log4j2.configurationFile>
285278
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
286-
<revision>0.3.0</revision>
279+
<revision>0.4.0</revision>
287280
</properties>
288281

289282
</project>

0 commit comments

Comments
 (0)