Skip to content

Commit fb90ca6

Browse files
committed
build: set up release workflow
1 parent 58fafb0 commit fb90ca6

7 files changed

Lines changed: 361 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Java CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "main" ]
7+
pull_request:
8+
branches: [ "main" ]
9+
10+
jobs:
11+
build:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest, macos-latest]
16+
17+
steps:
18+
- uses: actions/checkout@v6
19+
20+
- name: Set up JDK 22
21+
uses: actions/setup-java@v5
22+
with:
23+
java-version: '22'
24+
distribution: 'temurin'
25+
cache: maven
26+
27+
- name: Build and verify
28+
run: ./mvnw --no-transfer-progress --batch-mode verify

.github/workflows/release.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Release version (e.g., 1.0.0)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: write # Required to create releases and push commits
17+
18+
# Uncomment to add an approval gate before releasing:
19+
# environment: jreleaser
20+
21+
env:
22+
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }}
24+
JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }}
25+
JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
26+
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
27+
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
28+
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 0 # Full history for changelog generation
34+
35+
- name: Set up JDK 22
36+
uses: actions/setup-java@v4
37+
with:
38+
java-version: '22'
39+
distribution: 'temurin'
40+
cache: maven
41+
42+
- name: Set release version
43+
run: ./mvnw --no-transfer-progress --batch-mode versions:set -DnewVersion=${{ inputs.version }} -DprocessAllModules=true versions:commit
44+
45+
- name: Build and deploy to staging
46+
run: ./mvnw --no-transfer-progress --batch-mode clean deploy -Prelease
47+
48+
- name: Commit release version
49+
run: |
50+
git config user.email "github-actions[bot]@users.noreply.github.com"
51+
git config user.name "github-actions[bot]"
52+
git add -A
53+
git commit -m "ci: Releasing version ${{ inputs.version }}"
54+
git push
55+
56+
- name: Run JReleaser
57+
run: ./mvnw --no-transfer-progress --batch-mode jreleaser:full-release
58+
59+
- name: Set next development version
60+
run: ./mvnw --no-transfer-progress --batch-mode build-helper:parse-version versions:set "-DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT" -DprocessAllModules=true versions:commit
61+
62+
- name: Commit next development version
63+
run: |
64+
git add -A
65+
git commit -m "ci: Prepare for next development iteration"
66+
git push
67+
68+
- name: Upload JReleaser output
69+
if: always()
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: jreleaser-output
73+
path: |
74+
target/jreleaser/trace.log
75+
target/jreleaser/output.properties
76+
retention-days: 7

RELEASE.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Release Process
2+
3+
This project uses [JReleaser](https://jreleaser.org/) for automated releases to GitHub Releases and Maven Central.
4+
5+
## Creating a Release
6+
7+
1. **Ensure all changes are committed and pushed**
8+
9+
```bash
10+
git status # Should be clean
11+
```
12+
13+
2. **Trigger the release workflow**
14+
- Go to [Actions → Release](../../actions/workflows/release.yml)
15+
- Click **Run workflow**
16+
- Enter the release version (e.g., `1.0.0`)
17+
- Click **Run workflow**
18+
19+
3. **What the workflow does**
20+
- Updates all `pom.xml` versions to the release version
21+
- Builds and signs artifacts (JARs, sources, javadoc) for both modules
22+
- Deploys staging artifacts to local directories
23+
- Commits and pushes the version change
24+
- Creates a GitHub Release with auto-generated changelog
25+
- Publishes both `miniterm` and `miniterm-ffm` to Maven Central
26+
- Bumps versions to the next `-SNAPSHOT` and pushes
27+
28+
4. **Verify the release**
29+
- Check [GitHub Releases](../../releases)
30+
- Check [Maven Central](https://central.sonatype.com/search?q=g:org.codejive.miniterm) (may take ~30 minutes)
31+
32+
## Local Testing (Optional)
33+
34+
```bash
35+
# Validate JReleaser configuration
36+
./mvnw jreleaser:config
37+
38+
# Test build with release profile (produces staged artifacts)
39+
./mvnw clean deploy -Prelease
40+
41+
# Inspect staged artifacts (all modules land here)
42+
ls target/staging-deploy/
43+
```
44+
45+
## First-Time Setup
46+
47+
### 1. Generate GPG Keys
48+
49+
```bash
50+
gpg --gen-key
51+
gpg --list-secret-keys --keyid-format=long
52+
53+
# Export keys (replace KEY_ID with your key ID)
54+
gpg --armor --export KEY_ID > public.key
55+
gpg --armor --export-secret-keys KEY_ID > private.key
56+
57+
# Publish to key server
58+
gpg --keyserver keyserver.ubuntu.com --send-keys KEY_ID
59+
```
60+
61+
### 2. Register at Maven Central
62+
63+
1. Sign up at https://central.sonatype.com/
64+
2. Verify namespace ownership for `org.codejive`
65+
3. Generate a user token (username + password)
66+
67+
### 3. Configure GitHub Secrets
68+
69+
Add at [Settings → Secrets → Actions](../../settings/secrets/actions):
70+
71+
| Secret | Description |
72+
|--------|-------------|
73+
| `GPG_PUBLIC_KEY` | Contents of `public.key` |
74+
| `GPG_SECRET_KEY` | Contents of `private.key` |
75+
| `GPG_PASSPHRASE` | Passphrase used when generating the GPG key |
76+
| `MAVENCENTRAL_USERNAME` | Maven Central token username |
77+
| `MAVENCENTRAL_PASSWORD` | Maven Central token password |
78+
79+
`GITHUB_TOKEN` is provided automatically by GitHub Actions.
80+
81+
### 4. Optional: Protected Environment
82+
83+
For an extra approval gate, create a `jreleaser` environment under Settings → Environments, add the same secrets there, and uncomment the `environment: jreleaser` line in `.github/workflows/release.yml`.
84+
85+
## Version Management
86+
87+
- Development versions use `-SNAPSHOT` suffix (e.g., `1.0.0-SNAPSHOT`)
88+
- The workflow automatically bumps to the next patch SNAPSHOT after each release
89+
- Use [semantic versioning](https://semver.org/): `MAJOR.MINOR.PATCH`
90+
- Use [conventional commits](https://www.conventionalcommits.org/) for automatic changelog entries (`feat:`, `fix:`, `docs:`, etc.)

jreleaser.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
project:
2+
name: miniterm
3+
description: A minimal terminal library
4+
longDescription: |
5+
miniterm is a minimal terminal library for Java providing platform-specific
6+
implementations for terminal manipulation. It includes a legacy Java 8+
7+
implementation (miniterm) and a modern Java 22+ FFM-based implementation
8+
(miniterm-ffm).
9+
authors:
10+
- Tako Schotanus
11+
tags:
12+
- java
13+
- terminal
14+
- library
15+
license: Apache-2.0
16+
links:
17+
homepage: https://github.com/codejive/miniterm
18+
languages:
19+
java:
20+
groupId: org.codejive.miniterm
21+
version: '8'
22+
inceptionYear: '2024'
23+
stereotype: NONE
24+
25+
# No assembly needed - Maven handles JARs
26+
assemble:
27+
enabled: false
28+
29+
# Maven Central deployment - all three staging repos (parent + two modules)
30+
deploy:
31+
maven:
32+
mavenCentral:
33+
miniterm:
34+
active: RELEASE
35+
url: https://central.sonatype.com/api/v1/publisher
36+
stagingRepositories:
37+
- target/staging-deploy
38+
39+
# GitHub release configuration
40+
release:
41+
github:
42+
owner: codejive
43+
name: miniterm
44+
overwrite: true
45+
changelog:
46+
formatted: ALWAYS
47+
preset: conventional-commits
48+
contributors:
49+
format: '- {{contributorName}}{{#contributorUsernameAsLink}} ({{.}}){{/contributorUsernameAsLink}}'
50+
51+
# Checksum generation
52+
checksum:
53+
individual: true
54+
55+
# GPG signing - required for Maven Central
56+
signing:
57+
active: ALWAYS
58+
armored: true

miniterm-ffm/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.codejive.miniterm</groupId>
99
<artifactId>miniterm-parent</artifactId>
10-
<version>0.0.1-SNAPSHOT</version>
10+
<version>0.1.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>miniterm-ffm</artifactId>

miniterm/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.codejive.miniterm</groupId>
99
<artifactId>miniterm-parent</artifactId>
10-
<version>0.0.1-SNAPSHOT</version>
10+
<version>0.1.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>miniterm</artifactId>

0 commit comments

Comments
 (0)