Skip to content
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
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: Release version without the leading v
required: true
type: string
push:
tags:
- 'v*'

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
environment: jreleaser
steps:
- name: Check out source
uses: actions/checkout@v7
with:
fetch-depth: 0

- name: Set up JDK 21
uses: actions/setup-java@v6
with:
java-version: '21'
distribution: temurin
cache: maven

- name: Set release version
env:
TAG_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
INPUT_VERSION: ${{ inputs.version }}
run: |
VERSION="${INPUT_VERSION:-${TAG_VERSION#v}}"
if [[ -z "$VERSION" || "$VERSION" == "$TAG_VERSION" && "$TAG_VERSION" != v* ]]; then
echo "A release tag or workflow version is required"
exit 1
fi
./mvnw -B versions:set -DnewVersion="$VERSION" -DgenerateBackupPoms=false

- name: Stage Maven Central artifacts
run: >-
./mvnw -B -Prelease deploy
-DaltDeploymentRepository=staging::default::file:${{ github.workspace }}/target/staging-deploy

- name: Release with JReleaser
uses: jreleaser/release-action@v2
env:
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}

- name: JReleaser release output
if: always()
uses: actions/upload-artifact@v7
with:
name: jreleaser-release-output
path: |
target/surefire-reports
target/jreleaser/trace.log
target/jreleaser/output.properties
52 changes: 44 additions & 8 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@

Use the following to test an incremental release + deploy:
# Release Process

Releases are published to GitHub and Maven Central by JReleaser from a version tag.

## Prerequisites

- Push access to the `codejive/java-properties` repository.
- A Maven Central publisher account and namespace for `org.codejive`.
- An armored GPG key configured in the repository's `jreleaser` environment:
`JRELEASER_GPG_PUBLIC_KEY`, `JRELEASER_GPG_SECRET_KEY`, and
`JRELEASER_GPG_PASSPHRASE`.
- The `MAVENCENTRAL_USERNAME` and `MAVENCENTRAL_PASSWORD` secrets.
- The workflow-provided `GITHUB_TOKEN` permission to create releases.

## Creating a Release

1. Ensure the changes are committed and the CI workflow is green.
2. Create and push an annotated tag whose name is the release version, for example:

```shell
git tag -a v0.0.8 -m "Release v0.0.8"
git push origin v0.0.8
```

3. The `Release` workflow sets the Maven version from the tag, builds the sources and
Javadoc artifacts, and runs JReleaser.
4. Verify the GitHub release and the published component on Maven Central.

The workflow can also be started manually from GitHub Actions. In that case, provide
the version without the leading `v`.

## Local Configuration Check

This validates the JReleaser configuration without publishing anything:

```
mvn -B release:clean release:prepare -DdryRun=true
./mvnw jreleaser:config
```

If everything seems successful the following will actual perform a deploy:
To build the artifacts that a release would stage locally:

```
mvn -B release:clean release:prepare release:perform
./mvnw -B -Prelease clean package
```

_WARNING: Make sure **JAVA_HOME** is set or the release will fail!_
Publishing should be performed by the GitHub Actions workflow so that credentials and
signing keys remain outside the local environment.

If something went wrong you can roll back the release using:
## Recovery

```
mvn release:rollback
./mvnw jreleaser:full-release
```

Use this command to set a specific version:
Re-running the workflow for the same tag is safe because the JReleaser GitHub release
configuration allows overwriting an existing release. If a release must be corrected,
fix the source, create a new patch version, and push a new tag.

```
mvn -B release:update-versions -DdevelopmentVersion=1.2.3-SNAPSHOT
Expand Down
40 changes: 40 additions & 0 deletions jreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
project:
name: java-properties
description: A Java Properties parser that preserves comments and formatting
longDescription: |
A drop-in replacement for java.util.Properties that preserves comments and
formatting when properties files are read, changed, and written.
authors:
- Tako Schotanus
license: Apache-2.0
links:
homepage: https://github.com/codejive/java-properties
stereotype: NONE

release:
github:
owner: codejive
name: java-properties
overwrite: true
draft: false
changelog:
formatted: ALWAYS
preset: conventional-commits
contributors:
format: '- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}'

signing:
active: ALWAYS
armored: true

checksum:
individual: true

deploy:
maven:
mavenCentral:
java-properties:
active: RELEASE
url: https://central.sonatype.com/api/v1/publisher
stagingRepositories:
- target/staging-deploy
45 changes: 4 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,11 @@
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.7.0</version>
<extensions>true</extensions>
<groupId>org.jreleaser</groupId>
<artifactId>jreleaser-maven-plugin</artifactId>
<version>1.14.0</version>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<releaseProfiles>release</releaseProfiles>
<tagNameFormat>v@{project.version}</tagNameFormat>
<goals>deploy</goals>
<configFile>${project.basedir}/jreleaser.yml</configFile>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -158,20 +145,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.2.8</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand All @@ -184,14 +157,4 @@
<tag>HEAD</tag>
</scm>

<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</project>
Loading