Skip to content

Commit

Permalink
Deploy to maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
segabriel committed Jan 12, 2021
1 parent 6bd02fa commit cd1452a
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 16 deletions.
26 changes: 23 additions & 3 deletions .github/workflows/pre-release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,42 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 1.8
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: github
server-username: GITHUB_ACTOR
server-password: GITHUB_TOKEN
- name: Deploy pre-release version
- name: Deploy pre-release version to GitHub Packages
run: |
pre_release_version=${{ github.event.release.tag_name }}
echo Pre-release version $pre_release_version
mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false
mvn versions:commit
mvn clean deploy -B -V
mvn clean deploy -Pdeploy2Github -B -V
env:
GITHUB_TOKEN: ${{ secrets.ORGANIZATION_TOKEN }}
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Deploy pre-release version to the Maven Central Repository
run: |
pre_release_version=${{ github.event.release.tag_name }}
echo Pre-release version $pre_release_version
mvn versions:set -DnewVersion=$pre_release_version -DgenerateBackupPoms=false
mvn versions:commit
mvn deploy -Pdeploy2Maven -DskipTests -B -V
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Rollback pre-release (remove tag)
if: failure()
run: git push origin :refs/tags/${{ github.event.release.tag_name }}
24 changes: 22 additions & 2 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 1.8
- name: Set up Java for publishing to GitHub Packages
uses: actions/setup-java@v1
with:
java-version: 1.8
Expand All @@ -44,10 +44,30 @@ jobs:
-Darguments="-DskipTests=true -Ddockerfile.skip=true"
echo ::set-output name=release_tag::$(git describe --tags --abbrev=0)
- name: Perform release
run: mvn -B release:perform -Darguments="-DskipTests=true -Ddockerfile.skip=true"
run: mvn -B release:perform -Pdeploy2Github -Darguments="-DskipTests=true -Ddockerfile.skip=true -Pdeploy2Github"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ secrets.GITHUB_REPOSITORY }}
- name: Set up Java for publishing to Maven Central Repository
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE
- name: Deploy release version to the Maven Central Repository
run: |
release_version=$(echo ${{ steps.prepare_release.outputs.release_tag }} | sed "s/release-//")
echo release version $release_version
mvn versions:set -DnewVersion=$release_version -DgenerateBackupPoms=false
mvn versions:commit
mvn deploy -Pdeploy2Maven -DskipTests -B -V
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
- name: Rollback release
if: failure()
run: |
Expand Down
74 changes: 63 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
</license>
</licenses>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/scalecube/scalecube-parent</url>
</repository>
</distributionManagement>

<scm>
<url>https://scalecube.io</url>
<connection>scm:git:https://github.com/scalecube/scalecube-parent.git</connection>
Expand Down Expand Up @@ -63,6 +55,8 @@
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<maven-dependency-plugin.version>3.1.2</maven-dependency-plugin.version>
<versions-maven-plugin.version>2.7</versions-maven-plugin.version>
<maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>

<!-- check style configuration -->
<checkstyle.config.location>google_checks.xml</checkstyle.config.location>
Expand Down Expand Up @@ -200,8 +194,17 @@
<releaseProfiles>release</releaseProfiles>
<tagNameFormat>release-@{project.version}</tagNameFormat>
<goals>deploy</goals>
<username>${env.GITHUB_ACTOR}</username>
<password>${env.GITHUB_TOKEN}</password>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${nexus-staging-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
Expand All @@ -219,7 +222,7 @@
<message>The reactor is not valid</message>
<ignoreModuleDependencies>true</ignoreModuleDependencies>
</reactorModuleConvergence>
<dependencyConvergence />
<dependencyConvergence/>
</rules>
</configuration>
</execution>
Expand Down Expand Up @@ -268,6 +271,24 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
<executions>
<execution>
<id>sign-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Docker -->
<plugin>
<groupId>com.spotify</groupId>
Expand Down Expand Up @@ -396,6 +417,37 @@
<dockerfile.skip>false</dockerfile.skip>
</properties>
</profile>
<profile>
<id>deploy2Github</id>
<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/scalecube/scalecube-parent</url>
</repository>
</distributionManagement>
</profile>
<profile>
<id>deploy2Maven</id>
<distributionManagement>
<repository>
<id>ossrh</id>
<name>Central Repository OSSRH</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

0 comments on commit cd1452a

Please sign in to comment.