Skip to content

Commit d4d9b2b

Browse files
committed
Deploy to maven central
1 parent 342c1e0 commit d4d9b2b

File tree

3 files changed

+89
-15
lines changed

3 files changed

+89
-15
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: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46

57
<parent>
68
<groupId>io.scalecube</groupId>
79
<artifactId>scalecube-parent-pom</artifactId>
8-
<version>0.2.17</version>
10+
<version>0.2.19</version>
911
</parent>
1012

1113
<artifactId>scalecube-security-parent</artifactId>
@@ -24,14 +26,6 @@
2426
</repository>
2527
</repositories>
2628

27-
<distributionManagement>
28-
<repository>
29-
<id>github</id>
30-
<name>GitHub Packages</name>
31-
<url>https://maven.pkg.github.com/scalecube/scalecube-security</url>
32-
</repository>
33-
</distributionManagement>
34-
3529
<scm>
3630
<url>https://github.com/scalecube/scalecube</url>
3731
<connection>scm:git:https://github.com/scalecube/scalecube-security.git</connection>
@@ -140,4 +134,44 @@
140134
</dependency>
141135
</dependencies>
142136

137+
<profiles>
138+
<profile>
139+
<id>deploy2Github</id>
140+
<distributionManagement>
141+
<repository>
142+
<id>github</id>
143+
<name>GitHub Packages</name>
144+
<url>https://maven.pkg.github.com/scalecube/scalecube-security</url>
145+
</repository>
146+
</distributionManagement>
147+
</profile>
148+
<profile>
149+
<id>deploy2Maven</id>
150+
<distributionManagement>
151+
<repository>
152+
<id>ossrh</id>
153+
<name>Central Repository OSSRH</name>
154+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
155+
</repository>
156+
</distributionManagement>
157+
<build>
158+
<plugins>
159+
<plugin>
160+
<groupId>org.sonatype.plugins</groupId>
161+
<artifactId>nexus-staging-maven-plugin</artifactId>
162+
</plugin>
163+
<plugin>
164+
<artifactId>maven-source-plugin</artifactId>
165+
</plugin>
166+
<plugin>
167+
<artifactId>maven-javadoc-plugin</artifactId>
168+
</plugin>
169+
<plugin>
170+
<artifactId>maven-gpg-plugin</artifactId>
171+
</plugin>
172+
</plugins>
173+
</build>
174+
</profile>
175+
</profiles>
176+
143177
</project>

0 commit comments

Comments
 (0)