Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic release to Maven central #101

Merged
merged 1 commit into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release New Version
on:
workflow_dispatch:
inputs:
releaseVersion:
description: 'Release version'
required: false

env:
MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
JAVA_TOOL_OPTIONS: -Duser.name=io.github.java-native
GITHUB_BOT_NAME: github-actions
GITHUB_BOT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com

jobs:
maven-central-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git config --global user.email "${GITHUB_BOT_EMAIL}"
- run: git config --global user.name "${GITHUB_BOT_NAME}"
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: 11
distribution: temurin
server-id: ossrh
server-username: OSSRH_TOKEN_USERNAME
server-password: OSSRH_TOKEN_PASSWORD
gpg-private-key: ${{ secrets.JAVA_NATIVE_PGP_KEY }}
gpg-passphrase: PGP_KEY_PASSPHRASE
- name: Set release version if provided as input
if: github.event.inputs.releaseVersion != ''
run: echo "VERSIONS=-DreleaseVersion=${{ github.event.inputs.releaseVersion }}" >> $GITHUB_ENV
- name: Publish artifacts to Maven Central
run: mvn -B release:prepare release:perform -P package,maven-central-release ${VERSIONS}
env:
OSSRH_TOKEN_USERNAME: ${{ secrets.OSSRH_TOKEN_USERNAME }}
OSSRH_TOKEN_PASSWORD: ${{ secrets.OSSRH_TOKEN_PASSWORD }}
PGP_KEY_PASSPHRASE: ${{ secrets.JAVA_NATIVE_PGP_KEY_PASSPHRASE }}
- name: Push changes back to repo
run: git push && git push --tags --force
57 changes: 56 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<connection>scm:git:https://github.com/java-native/jssc.git</connection>
<developerConnection>scm:git:git@github.com:java-native/jssc.git</developerConnection>
<url>https://github.com/java-native/jssc</url>
<tag>HEAD</tag>
</scm>

<properties>
Expand Down Expand Up @@ -63,10 +64,13 @@
<plugin.build-helper-maven-version>3.2.0</plugin.build-helper-maven-version>
<plugin.compiler.version>3.8.0</plugin.compiler.version>
<plugin.enforcer.version>3.0.0-M3</plugin.enforcer.version>
<plugin.gpg.version>3.0.1</plugin.gpg.version>
<plugin.jar.version>3.1.1</plugin.jar.version>
<plugin.javadoc.version>3.1.1</plugin.javadoc.version>
<plugin.nar.version>3.6.0</plugin.nar.version>
<plugin.nexus-staging.version>1.6.7</plugin.nexus-staging.version>
<plugin.osmaven.version>1.7.0</plugin.osmaven.version>
<plugin.release.version>3.0.0-M4</plugin.release.version>
<plugin.signature.version>1.1</plugin.signature.version>
<plugin.source.version>3.0.1</plugin.source.version>
<plugin.surfire.version>3.0.0-M4</plugin.surfire.version>
Expand Down Expand Up @@ -447,7 +451,7 @@
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
Expand Down Expand Up @@ -574,5 +578,56 @@
</properties>
</profile>

<profile>
<id>maven-central-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${plugin.gpg.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<keyname>java-native</keyname>
<passphraseServerId>gpg.passphrase</passphraseServerId>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${plugin.release.version}</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<pushChanges>false</pushChanges>
<localCheckout>true</localCheckout>
<goals>deploy</goals>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>${plugin.nexus-staging.version}</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>
</project>