Skip to content

Commit cd1452a

Browse files
committed
Deploy to maven central
1 parent 6bd02fa commit cd1452a

File tree

3 files changed

+108
-16
lines changed

3 files changed

+108
-16
lines changed

.github/workflows/pre-release-ci.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,42 @@ jobs:
1616
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
1717
restore-keys: |
1818
${{ runner.os }}-maven-
19-
- name: Set up JDK 1.8
19+
- name: Set up Java for publishing to GitHub Packages
2020
uses: actions/setup-java@v1
2121
with:
2222
java-version: 1.8
2323
server-id: github
2424
server-username: GITHUB_ACTOR
2525
server-password: GITHUB_TOKEN
26-
- name: Deploy pre-release version
26+
- name: Deploy pre-release version to GitHub Packages
2727
run: |
2828
pre_release_version=${{ github.event.release.tag_name }}
2929
echo Pre-release version $pre_release_version
3030
mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false
3131
mvn versions:commit
32-
mvn clean deploy -B -V
32+
mvn clean deploy -Pdeploy2Github -B -V
3333
env:
3434
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }}
35+
- name: Set up Java for publishing to Maven Central Repository
36+
uses: actions/setup-java@v1
37+
with:
38+
java-version: 1.8
39+
server-id: ossrh
40+
server-username: MAVEN_USERNAME
41+
server-password: MAVEN_PASSWORD
42+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
43+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
44+
- name: Deploy pre-release version to the Maven Central Repository
45+
run: |
46+
pre_release_version=${{ github.event.release.tag_name }}
47+
echo Pre-release version $pre_release_version
48+
mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false
49+
mvn versions:commit
50+
mvn deploy -Pdeploy2Maven -DskipTests -B -V
51+
env:
52+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
53+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
54+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
3555
- name: Rollback pre-release (remove tag)
3656
if: failure()
3757
run: git push origin :refs/tags/${{ github.event.release.tag_name }}

.github/workflows/release-ci.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2020
restore-keys: |
2121
${{ runner.os }}-maven-
22-
- name: Set up JDK 1.8
22+
- name: Set up Java for publishing to GitHub Packages
2323
uses: actions/setup-java@v1
2424
with:
2525
java-version: 1.8
@@ -44,10 +44,30 @@ jobs:
4444
-Darguments="-DskipTests=true -Ddockerfile.skip=true"
4545
echo ::set-output name=release_tag::$(git describe --tags --abbrev=0)
4646
- name: Perform release
47-
run: mvn -B release:perform -Darguments="-DskipTests=true -Ddockerfile.skip=true"
47+
run: mvn -B release:perform -Pdeploy2Github -Darguments="-DskipTests=true -Ddockerfile.skip=true -Pdeploy2Github"
4848
env:
4949
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5050
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
51+
- name: Set up Java for publishing to Maven Central Repository
52+
uses: actions/setup-java@v1
53+
with:
54+
java-version: 1.8
55+
server-id: ossrh
56+
server-username: MAVEN_USERNAME
57+
server-password: MAVEN_PASSWORD
58+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
59+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
60+
- name: Deploy release version to the Maven Central Repository
61+
run: |
62+
release_version=$(echo ${{ steps.prepare_release.outputs.release_tag }} | sed "s/release-//")
63+
echo release version $release_version
64+
mvn versions:set -DnewVersion=$release_version -DgenerateBackupPoms=false
65+
mvn versions:commit
66+
mvn deploy -Pdeploy2Maven -DskipTests -B -V
67+
env:
68+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
69+
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
70+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
5171
- name: Rollback release
5272
if: failure()
5373
run: |

pom.xml

Lines changed: 63 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,6 @@
2020
</license>
2121
</licenses>
2222

23-
<distributionManagement>
24-
<repository>
25-
<id>github</id>
26-
<name>GitHub Packages</name>
27-
<url>https://maven.pkg.github.com/scalecube/scalecube-parent</url>
28-
</repository>
29-
</distributionManagement>
30-
3123
<scm>
3224
<url>https://scalecube.io</url>
3325
<connection>scm:git:https://github.com/scalecube/scalecube-parent.git</connection>
@@ -63,6 +55,8 @@
6355
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
6456
<maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
6557
<versions-maven-plugin.version>2.7</versions-maven-plugin.version>
58+
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
59+
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
6660

6761
<!-- check style configuration -->
6862
<checkstyle.config.location>google_checks.xml</checkstyle.config.location>
@@ -200,8 +194,17 @@
200194
<releaseProfiles>release</releaseProfiles>
201195
<tagNameFormat>release-@{project.version}</tagNameFormat>
202196
<goals>deploy</goals>
203-
<username>${env.GITHUB_ACTOR}</username>
204-
<password>${env.GITHUB_TOKEN}</password>
197+
</configuration>
198+
</plugin>
199+
<plugin>
200+
<groupId>org.sonatype.plugins</groupId>
201+
<artifactId>nexus-staging-maven-plugin</artifactId>
202+
<version>${nexus-staging-maven-plugin.version}</version>
203+
<extensions>true</extensions>
204+
<configuration>
205+
<serverId>ossrh</serverId>
206+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
207+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
205208
</configuration>
206209
</plugin>
207210
<plugin>
@@ -219,7 +222,7 @@
219222
<message>The reactor is not valid</message>
220223
<ignoreModuleDependencies>true</ignoreModuleDependencies>
221224
</reactorModuleConvergence>
222-
<dependencyConvergence />
225+
<dependencyConvergence/>
223226
</rules>
224227
</configuration>
225228
</execution>
@@ -268,6 +271,24 @@
268271
</execution>
269272
</executions>
270273
</plugin>
274+
<plugin>
275+
<artifactId>maven-gpg-plugin</artifactId>
276+
<version>${maven-gpg-plugin.version}</version>
277+
<configuration>
278+
<gpgArguments>
279+
<arg>--pinentry-mode</arg>
280+
<arg>loopback</arg>
281+
</gpgArguments>
282+
</configuration>
283+
<executions>
284+
<execution>
285+
<id>sign-artifacts</id>
286+
<goals>
287+
<goal>sign</goal>
288+
</goals>
289+
</execution>
290+
</executions>
291+
</plugin>
271292
<!-- Docker -->
272293
<plugin>
273294
<groupId>com.spotify</groupId>
@@ -396,6 +417,37 @@
396417
<dockerfile.skip>false</dockerfile.skip>
397418
</properties>
398419
</profile>
420+
<profile>
421+
<id>deploy2Github</id>
422+
<distributionManagement>
423+
<repository>
424+
<id>github</id>
425+
<name>GitHub Packages</name>
426+
<url>https://maven.pkg.github.com/scalecube/scalecube-parent</url>
427+
</repository>
428+
</distributionManagement>
429+
</profile>
430+
<profile>
431+
<id>deploy2Maven</id>
432+
<distributionManagement>
433+
<repository>
434+
<id>ossrh</id>
435+
<name>Central Repository OSSRH</name>
436+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
437+
</repository>
438+
</distributionManagement>
439+
<build>
440+
<plugins>
441+
<plugin>
442+
<groupId>org.sonatype.plugins</groupId>
443+
<artifactId>nexus-staging-maven-plugin</artifactId>
444+
</plugin>
445+
<plugin>
446+
<artifactId>maven-gpg-plugin</artifactId>
447+
</plugin>
448+
</plugins>
449+
</build>
450+
</profile>
399451
</profiles>
400452

401453
</project>

0 commit comments

Comments
 (0)