Skip to content

Commit c563830

Browse files
authored
Add release workflow (#168)
* begin release workflow * add release workflow file * sequence * debug output * prettier, enable * change per review * changelog * revert mac changes * change per review * changelog * update per isaacbrodsky/h3-java * update * typo * remove top line from CHANGELOG * update per isaacbrodsky repo * fix changelog * adjust release instructions * update changelog date for release
1 parent 5590ed2 commit c563830

File tree

5 files changed

+252
-9
lines changed

5 files changed

+252
-9
lines changed

.github/workflows/release.yml

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
name: Release to Maven Central
2+
3+
on:
4+
# Manual trigger
5+
workflow_dispatch:
6+
inputs:
7+
release_version:
8+
description: "Version to release (if empty, derive from project version)"
9+
required: false
10+
# Automatic trigger on pushing a version tag (e.g., "v1.2.3")
11+
push:
12+
tags:
13+
- "v*"
14+
15+
jobs:
16+
# Corresponds to tests in tests.yml
17+
build-with-docker:
18+
name: Build ${{ matrix.dockcross-only }} (Dockcross)
19+
runs-on: ${{ matrix.os }}
20+
21+
strategy:
22+
matrix:
23+
os: [ubuntu-latest]
24+
java-distribution: [adopt]
25+
java-version: [8]
26+
dockcross-only:
27+
[
28+
"android-arm",
29+
"android-arm64",
30+
"linux-arm64",
31+
"linux-armv5",
32+
"linux-armv7",
33+
"linux-s390x",
34+
"linux-ppc64le",
35+
"linux-x64",
36+
"linux-x86",
37+
"windows-static-x64",
38+
"windows-static-x86",
39+
]
40+
41+
steps:
42+
- uses: actions/checkout@v4
43+
with:
44+
submodules: recursive
45+
46+
- uses: actions/setup-java@v2
47+
with:
48+
distribution: "${{ matrix.java-distribution }}"
49+
java-version: "${{ matrix.java-version }}"
50+
51+
- uses: gradle/actions/setup-gradle@v3
52+
with:
53+
gradle-version: wrapper
54+
55+
- uses: actions/cache@v4
56+
id: gradle-cache
57+
with:
58+
path: |
59+
~/.gradle/caches
60+
~/.gradle/wrapper
61+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
62+
restore-keys: |
63+
${{ runner.os }}-gradle-
64+
65+
- name: Tests
66+
run: ./gradlew clean test -Ph3SystemPrune=true "-Ph3DockcrossOnly=${{ matrix.dockcross-only }}"
67+
env:
68+
OCI_EXE: docker
69+
70+
- uses: actions/upload-artifact@v4
71+
name: Upload artifacts
72+
with:
73+
name: docker-built-shared-objects-${{ matrix.dockcross-only }}
74+
path: |
75+
src/main/resources/*/*.so
76+
src/main/resources/*/*.dll
77+
if-no-files-found: error
78+
79+
# Corresponsd to tests-no-docker in tests.yml
80+
build:
81+
name: Build ${{ matrix.os }}
82+
runs-on: ${{ matrix.os }}
83+
84+
strategy:
85+
matrix:
86+
os: [macos-latest]
87+
java-distribution: [adopt]
88+
java-version: [8]
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
with:
93+
submodules: recursive
94+
95+
- uses: actions/setup-java@v2
96+
with:
97+
distribution: "${{ matrix.java-distribution }}"
98+
java-version: "${{ matrix.java-version }}"
99+
100+
- uses: gradle/actions/setup-gradle@v3
101+
with:
102+
gradle-version: wrapper
103+
104+
- uses: actions/cache@v4
105+
id: gradle-cache
106+
with:
107+
path: |
108+
~/.gradle/caches
109+
~/.gradle/wrapper
110+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
111+
restore-keys: |
112+
${{ runner.os }}-gradle-
113+
114+
- name: Tests
115+
run: ./gradlew clean test
116+
117+
- uses: actions/upload-artifact@v4
118+
name: Upload Mac OS Artifacts
119+
with:
120+
name: macos-built-shared-objects
121+
path: src/main/resources/*/*.dylib
122+
if-no-files-found: error
123+
124+
release:
125+
runs-on: ubuntu-latest
126+
permissions:
127+
contents: write # allow pushing commits/tags
128+
129+
needs:
130+
- build-with-docker
131+
- build
132+
133+
steps:
134+
- name: Check out code
135+
uses: actions/checkout@v3
136+
137+
- name: Set up JDK
138+
uses: actions/setup-java@v3
139+
with:
140+
distribution: "temurin"
141+
java-version: "21"
142+
143+
- name: Determine release version
144+
id: vars
145+
run: |
146+
# Derive the release version (drop "-SNAPSHOT") from Gradle project or input
147+
VERSION_INPUT="${{ github.event.inputs.release_version || '' }}"
148+
if [ -n "$VERSION_INPUT" ]; then
149+
RELEASE_VERSION="$VERSION_INPUT"
150+
else
151+
RELEASE_VERSION=$(grep -E 'version=' gradle.properties | sed -E 's/version=//')
152+
fi
153+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV
154+
155+
- name: Remove -SNAPSHOT suffix (prepare release version)
156+
if: ${{ github.event_name == 'workflow_dispatch' }}
157+
run: |
158+
sed -i -E "s/${RELEASE_VERSION}-SNAPSHOT/$RELEASE_VERSION/" gradle.properties || true
159+
git config user.name "github-actions"
160+
git config user.email "[email protected]"
161+
git commit -am "chore: release $RELEASE_VERSION [skip ci]"
162+
163+
- name: Create Git tag for release
164+
if: ${{ github.event_name == 'workflow_dispatch' }}
165+
run: |
166+
git tag -a "v${RELEASE_VERSION}" -m "Release $RELEASE_VERSION"
167+
git push origin HEAD:master --follow-tags
168+
169+
- name: Download Docker binaries
170+
uses: actions/[email protected]
171+
with:
172+
pattern: docker-built-shared-objects-*
173+
merge-multiple: true
174+
path: src/main/resources/
175+
176+
- name: Download Mac binaries
177+
uses: actions/[email protected]
178+
with:
179+
name: macos-built-shared-objects
180+
path: src/main/resources/
181+
182+
- name: Download and test
183+
run: |
184+
./gradlew clean test assemble -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true
185+
186+
- name: List files in jars
187+
run: |
188+
ls -lh build/libs
189+
for f in build/libs/*.jar; do
190+
echo "File: $f"
191+
unzip -l "$f"
192+
done
193+
194+
- name: Publish to Sonatype OSSRH (Maven Central)
195+
env:
196+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
197+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
198+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
199+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
200+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
201+
OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }}
202+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -Ph3GithubArtifactsUse=true -Ph3GithubArtifactsByRun=true
203+
204+
- name: Create GitHub Release (with changelog notes)
205+
# This uses an action to create a release on GitHub
206+
uses: softprops/action-gh-release@v1
207+
with:
208+
tag_name: "v${{ env.RELEASE_VERSION }}"
209+
name: "${{ env.RELEASE_VERSION }}"
210+
body_path: CHANGELOG.md # assumes changelog contains latest release notes at top
211+
env:
212+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
213+
214+
- name: Bump to next snapshot version
215+
if: ${{ github.event_name != 'workflow_dispatch' }}
216+
run: |
217+
# Bump minor version (for example) and append -SNAPSHOT for continued development
218+
NEXT_VERSION=$(echo $RELEASE_VERSION | awk -F. -v OFS="." '{$NF += 1; print $0}') # increment last segment
219+
NEXT_VERSION="$NEXT_VERSION-SNAPSHOT"
220+
sed -i -E "s/$RELEASE_VERSION/$NEXT_VERSION/" gradle.properties || true
221+
git config user.name "github-actions"
222+
git config user.email "[email protected]"
223+
git commit -am "chore: start next development cycle $NEXT_VERSION [skip ci]"
224+
git push origin HEAD:master

CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
# Change Log
21
All notable changes to this project will be documented in this file.
32
This project adheres to a [versioning policy](./docs/versioning.md).
43

54
The public API of this library consists of the public functions declared in
65
file [H3Core.java](./src/main/java/com/uber/h3core/H3Core.java), and support
76
for the Linux x64 and Darwin x64 platforms.
87

9-
## Unreleased Changes
8+
## [4.3.0] - 2025-06-26
9+
### Added
10+
- `polygonToCellsExperimental` functions from H3 v4.2.0. (#163)
11+
- `gridRing` function from H3 v4.3.0. (#169)
12+
13+
### Fixed
14+
- Corrected order of `polygonToCellsExperimental` arguments. (#166)
15+
- Fixed build on ARM Linux. (#162)
16+
17+
### Changed
18+
- Converted build system to Gradle and automated deploys. Added separate build steps for mac OS on M1 (ARM) and x64. (#167, #168)
19+
- Upgraded the core library to v4.2.1. (#165)
1020

1121
## [4.1.2] - 2024-11-01
12-
## Fixed
22+
Note: This release is not available in Maven Central.
23+
24+
### Fixed
1325
- Fixed a memory leak in `polygonToCells` and optimize JNI calls. (#150)
1426
- Use `Files.createTempFile` so temporary file permissions are more restrictive. (#141)
1527
- Fixed a potential segfault in `cellsToMultiPolygon` on error. (#129)
1628

17-
## Changed
29+
### Changed
1830
- Optimize JNI calls. (#154)
1931
- Added JNI config and tests for native image. (#153, #155)
2032
- Bumped dockcross versions (#151, #152)

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ plugins {
1919
}
2020

2121
group = 'com.uber'
22-
version = '4.1.3-SNAPSHOT'
2322
description = 'Java bindings for H3, a hierarchical hexagonal geospatial indexing system.'
2423

2524
java {
@@ -181,7 +180,8 @@ signing {
181180
nexusPublishing {
182181
repositories {
183182
sonatype {
184-
stagingProfileId.set(System.getenv("OSSRH_STAGING_PROFILE_ID"))
183+
// Performance optimization, not needed:
184+
// stagingProfileId.set(System.getenv("OSSRH_STAGING_PROFILE_ID"))
185185
username.set(System.getenv("OSSRH_USERNAME"))
186186
password.set(System.getenv("OSSRH_PASSWORD"))
187187
// For newer Sonatype accounts (after Feb 2021) use "s01.oss.sonatype.org":

docs/releasing.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
The H3-Java library is published to Maven Central via OSSRH.
44

5+
Before releasing, make sure the version of the project is in the form `1.2.3-SNAPSHOT` where `1.2.3` is the version you wish to release. The release is triggered via GitHub Actions, when a tag of the form `v1.2.3` is pushed. (Workflow dispatch can be used but is not tested.)
6+
7+
## Old instructions for manual releasing
8+
59
You must be a member of the `com.uber` group to release the library via OSSRH. You must have a [signing key](http://central.sonatype.org/pages/working-with-pgp-signatures.html) setup, and you must have your OSSRH username and password in the appropriate [Maven settings file](http://central.sonatype.org/pages/apache-maven.html).
610

711
Release builds pull artifacts from Github Actions. This is needed so that the deployed artifact contains all supported operating system/architecture combinations. (In particular, Mac OS artifacts must be built natively.) In order to release, there must be a completed build of the Git commit to release on Github. The build must be less than 30 days old, as artifacts are only kept for that time.
@@ -13,14 +17,14 @@ Release builds pull artifacts from Github Actions. This is needed so that the de
1317
5. If this looks good, close and release the build in [Sonatype Nexus Manager](https://oss.sonatype.org/).
1418
6. Update `CHANGELOG.md` to have an Unreleased section, and commit. The release is now done and development can resume from this point.
1519

16-
## Troubleshooting
20+
### Troubleshooting
1721

18-
### Dependencies for `pull-from-github.sh`
22+
#### Dependencies for `pull-from-github.sh`
1923

2024
* You should install the [Github CLI](https://cli.github.com) and authenticate with it first. You may need to use a personal access token (classic) with workflows scope.
2125
* `jq`
2226

23-
### gpg: signing failed: Inappropriate ioctl for device
27+
#### gpg: signing failed: Inappropriate ioctl for device
2428

2529
Per [StackOverflow](https://stackoverflow.com/questions/57591432/gpg-signing-failed-inappropriate-ioctl-for-device-on-macos-with-maven), run the following before `mvn release:perform`:
2630

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
# Blocked on https://github.com/nbaztec/coveralls-jacoco-gradle-plugin/issues/66
55
org.gradle.configuration-cache=false
66

7+
# No spaces on the following line, needed by release.yml:
8+
version=4.3.0-SNAPSHOT
9+

0 commit comments

Comments
 (0)