Skip to content

Commit

Permalink
Configure JReleaser for releases
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Feb 7, 2024
1 parent 210121e commit ec2366e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 98 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: 11
Expand Down
30 changes: 13 additions & 17 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
PLAIN_VERSION: ${{ steps.version.outputs.PLAIN_VERSION }}
NEXT_VERSION: ${{ steps.version.outputs.NEXT_VERSION }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
Expand Down Expand Up @@ -59,43 +59,39 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ needs.version.outputs.HEAD }}
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: ${{ env.JAVA_DISTRO }}
cache: maven
server-id: central
server-username: MAVEN_USERNAME
server-password: MAVEN_CENTRAL_TOKEN
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Release to Maven Central
env:
MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
MAVEN_CENTRAL_TOKEN: ${{ secrets.SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Stage
run: |
export GPG_TTY=$(tty)
./mvnw -ntp -B --file pom.xml \
-Drepository.url=https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git \
-Dmaven.site.skip=true -Drelease=true deploy
-Dmaven.site.skip=true -Drelease=true -Pstage
- name: Release to GitHub
- name: Release
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
JRELEASER_NEXUS2_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: |
./mvnw -B --file pom.xml -Pjreleaser jreleaser:release
- name: JReleaser output
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jreleaser-release
path: |
Expand Down
1 change: 0 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Given a project named `foo` located at `moditect/foo`:
<properties>
<project.identifier>foo</project.identifier>
<project.github.repository>moditect/foo</project.github.repository>
<local.repository.path>/tmp/repository</local.repository.path>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down
110 changes: 32 additions & 78 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
<project.identifier>moditect</project.identifier>
<project.github.repository>moditect/moditect-org-parent</project.github.repository>
<java.version>1.8</java.version>
<!-- override if multi-project -->
<local.repository.path>${project.build.directory}/repository</local.repository.path>
<!-- override when needed -->
<enforcer.skip>false</enforcer.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -52,7 +50,7 @@
<nexus.url>https://oss.sonatype.org</nexus.url>
<repository.url>git@github.com:${project.github.repository}.git</repository.url>
<!-- value comes from property git.commit.author.time -->
<project.build.outputTimestamp>2024-02-07T20:00:03Z</project.build.outputTimestamp>
<project.build.outputTimestamp>${git.commit.author.time}</project.build.outputTimestamp>
<version.antrun.plugin>3.1.0</version.antrun.plugin>
<version.clean.plugin>3.3.2</version.clean.plugin>
<version.compiler.plugin>3.12.1</version.compiler.plugin>
Expand All @@ -68,6 +66,7 @@
<version.install.plugin>3.1.1</version.install.plugin>
<version.javadoc.plugin>3.6.3</version.javadoc.plugin>
<version.jar.plugin>3.3.0</version.jar.plugin>
<version.jreleaser.plugin>1.10.0</version.jreleaser.plugin>
<version.license.plugin>4.3</version.license.plugin>
<version.nexus.plugin>1.6.13</version.nexus.plugin>
<version.resources.plugin>3.3.1</version.resources.plugin>
Expand Down Expand Up @@ -397,84 +396,12 @@
</profile>

<profile>
<id>gpg</id>
<activation>
<property>
<name>release</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>remote-deploy</id>
<activation>
<property>
<name>release</name>
</property>
</activation>
<build>
<defaultGoal>deploy</defaultGoal>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<serverId>central</serverId>
<nexusUrl>${nexus.url}</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>local-deploy</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<id>stage</id>
<properties>
<altDeploymentRepository>local::file:${local.repository.path}</altDeploymentRepository>
<altDeploymentRepository>local::file:${maven.multiModuleProjectDirectory}/target/staging-deploy</altDeploymentRepository>
</properties>
<build>
<defaultGoal>deploy</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<filesets>
<fileset>
<directory>${local.repository.path}</directory>
</fileset>
</filesets>
</configuration>
</plugin>
</plugins>
</build>
</profile>

Expand All @@ -485,19 +412,46 @@
<plugin>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>1.5.1</version>
<version>${version.jreleaser.plugin}</version>
<inherited>false</inherited>
<configuration>
<jreleaser>
<project>
<name>ModiTect Parent</name>
<!--links>
<homepage>https://github.com/moditect/moditect-org-parent</homepage>
<documentation>https://github.com/moditect/moditect-org-parent</documentation>
</links-->
<java>
<version>8</version>
</java>
</project>
<signing>
<active>ALWAYS</active>
<armored>true</armored>
</signing>
<deploy>
<maven>
<nexus2>
<maven-central>
<active>ALWAYS</active>
<url>https://oss.sonatype.org/service/local</url>
<snapshotUrl>https://oss.sonatype.org/content/repositories/snapshots/</snapshotUrl>
<closeRepository>true</closeRepository>
<releaseRepository>true</releaseRepository>
<stagingRepositories>target/staging-deploy</stagingRepositories>
</maven-central>
</nexus2>
</maven>
</deploy>
<release>
<github>
<changelog>
<formatted>ALWAYS</formatted>
<preset>conventional-commits</preset>
<contributors>
<format>- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}</format>
</contributors>
</changelog>
</github>
</release>
Expand Down

0 comments on commit ec2366e

Please sign in to comment.