Skip to content

Commit 19c352a

Browse files
committed
trying to automate releases.
1 parent 31b6b5b commit 19c352a

File tree

3 files changed

+128
-9
lines changed

3 files changed

+128
-9
lines changed

.github/release-settings.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
4+
<pluginGroups>
5+
<pluginGroup>eu.maveniverse.maven.plugins</pluginGroup>
6+
</pluginGroups>
7+
8+
<servers>
9+
<server>
10+
<id>sonatype-central-portal</id>
11+
<username>${env.MAVEN_USER}</username>
12+
<password>${env.MAVEN_PASSWORD}</password>
13+
<configuration>
14+
<njord.publisher>sonatype-cp</njord.publisher>
15+
<njord.releaseUrl>njord:template:release-sca</njord.releaseUrl>
16+
</configuration>
17+
</server>
18+
</servers>
19+
20+
</settings>

.github/workflows/release.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
releaseVersion:
7+
description: "Release version, e.g. 0.3.6 (optional — auto-detected from the current POM)"
8+
required: false
9+
10+
jobs:
11+
release:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write # to automatically create tags
15+
16+
steps:
17+
- name: Validate release version
18+
if: ${{ github.event.inputs.releaseVersion != '' }}
19+
run: |
20+
RELEASE=${{ github.event.inputs.releaseVersion }}
21+
if [[ ! $RELEASE =~ ^[0-9]+\.[0-9]+\.[0-9]+(-SNAPSHOT)?$ ]]; then
22+
echo "Error: releaseVersion '$RELEASE' is not in the correct format x.y.z or x.y.z-SNAPSHOT"
23+
exit 1
24+
fi
25+
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
ref: master
31+
32+
- name: Set up Java
33+
uses: actions/setup-java@v4
34+
with:
35+
java-version: '21'
36+
distribution: 'adopt'
37+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
38+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
39+
40+
- name: Configure git
41+
run: |
42+
git config user.email "[email protected]"
43+
git config user.name "GitHub Actions"
44+
45+
- name: Prepare Release
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
49+
run: |
50+
MVN_ARGS=""
51+
if [ -n "${{ github.event.inputs.releaseVersion }}" ]; then
52+
MVN_ARGS="$MVN_ARGS -DreleaseVersion=${{ github.event.inputs.releaseVersion }}"
53+
fi
54+
mvn -B release:prepare $MVN_ARGS
55+
56+
- name: Determine release version
57+
id: version
58+
run: |
59+
export TAG=$(grep 'scm.tag=' release.properties | cut -d'=' -f2)
60+
export VERSION=${TAG#JavaFastPFOR-}
61+
62+
echo "released_tag=${TAG}" >> $GITHUB_OUTPUT
63+
echo "released_version=${VERSION}" >> $GITHUB_OUTPUT
64+
65+
echo "Releasing tag: ${TAG}"
66+
echo "Releasing version: ${VERSION}"
67+
68+
- name: Release
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
72+
MAVEN_GPG_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
73+
MAVEN_USER: ${{ secrets.MAVEN_USER }}
74+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
75+
run: |
76+
mvn -B release:perform -Darguments="-DskipTests -DaltDeploymentRepository=id::default::njord: -Dnjord.autoPublish=true -Dnjord.publishingType=automatic" -s .github/release-settings.xml
77+
78+
- name: Create GitHub Release
79+
run: gh release create "${{ steps.version.outputs.released_tag }}" --generate-notes --title "Version ${{ steps.version.outputs.released_version }}"
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

pom.xml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,12 @@
1616
<java.target.version>1.8</java.target.version>
1717
<maven.compiler.source>1.8</maven.compiler.source>
1818
<maven.compiler.target>1.8</maven.compiler.target>
19+
<njord.version>0.8.5</njord.version>
1920
</properties>
2021
<issueManagement>
2122
<system>GitHub Issue Tracking</system>
2223
<url>https://github.com/lemire/externalsortinginjava/issues</url>
2324
</issueManagement>
24-
<parent>
25-
<groupId>org.sonatype.oss</groupId>
26-
<artifactId>oss-parent</artifactId>
27-
<version>5</version>
28-
</parent>
2925
<licenses>
3026
<license>
3127
<name>Public Domain</name>
@@ -41,19 +37,16 @@
4137
<artifactId>junit</artifactId>
4238
<version>4.13.1</version>
4339
</dependency>
44-
4540
<dependency>
4641
<groupId>com.github.jbellis</groupId>
4742
<artifactId>jamm</artifactId>
4843
<version>0.3.1</version>
4944
</dependency>
50-
5145
<dependency>
5246
<groupId>org.apache.commons</groupId>
5347
<artifactId>commons-csv</artifactId>
5448
<version>1.9.0</version>
5549
</dependency>
56-
5750
</dependencies>
5851
</dependencyManagement>
5952
<dependencies>
@@ -74,7 +67,14 @@
7467
</dependency>
7568
</dependencies>
7669
<build>
77-
<plugins>
70+
<extensions>
71+
<extension>
72+
<groupId>eu.maveniverse.maven.njord</groupId>
73+
<artifactId>extension3</artifactId>
74+
<version>${njord.version}</version>
75+
</extension>
76+
</extensions>
77+
<plugins>
7878

7979
<plugin>
8080
<artifactId>maven-dependency-plugin</artifactId>
@@ -205,6 +205,11 @@
205205
</execution>
206206
</executions>
207207
</plugin>
208+
<plugin>
209+
<groupId>eu.maveniverse.maven.plugins</groupId>
210+
<artifactId>njord</artifactId>
211+
<version>${njord.version}</version>
212+
</plugin>
208213
</plugins>
209214
</build>
210215
<scm>
@@ -213,4 +218,17 @@
213218
<developerConnection>scm:git:[email protected]:lemire/externalsortinginjava.git</developerConnection>
214219
<tag>HEAD</tag>
215220
</scm>
221+
222+
<distributionManagement>
223+
<snapshotRepository>
224+
<id>sonatype-central-portal</id>
225+
<name>Sonatype Central Portal</name>
226+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
227+
</snapshotRepository>
228+
<repository>
229+
<id>sonatype-central-portal</id>
230+
<name>Sonatype Central Portal</name>
231+
<url>https://repo.maven.apache.org/maven2/</url>
232+
</repository>
233+
</distributionManagement>
216234
</project>

0 commit comments

Comments
 (0)