feat: Add Maven Central release workflow - #24
Conversation
Automates the release process: extracts version from build.gradle, builds and signs the artifact, publishes to Maven Central, and creates a GitHub release with the shadow jar.
There was a problem hiding this comment.
Pull request overview
Adds an automated GitHub Actions release pipeline to publish the lib artifact to Maven Central when the library version is bumped, and updates project docs/version references accordingly.
Changes:
- Bump library version to
0.3.0and update README dependency snippets to match. - Add
.github/workflows/release.ymlto publish/sign to Maven Central and create a GitHub release onmainpushes that modifylib/build.gradle. - Document Java 17 runtime requirement in README.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
lib/build.gradle |
Version bump to 0.3.0 to drive the release trigger. |
README.md |
Updates install snippets to 0.3.0 and clarifies Java 17 requirement. |
.github/workflows/release.yml |
New workflow to publish to Maven Central and create a GitHub release. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Cache Gradle packages | ||
| if: steps.tag_check.outputs.exists == 'false' | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ~/.gradle/caches | ||
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-gradle- |
There was a problem hiding this comment.
actions/cache@v3 is deprecated (Node 16) and can stop working on GitHub-hosted runners. Bump this to actions/cache@v4 (and keep it aligned with other workflows) to avoid sudden CI breakage.
There was a problem hiding this comment.
Bumped to actions/cache@v4.
| - name: Check if tag already exists | ||
| id: tag_check | ||
| run: | | ||
| if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then | ||
| echo "Tag v${{ steps.version.outputs.version }} already exists, skipping release." | ||
| echo "exists=true" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "Tag v${{ steps.version.outputs.version }} does not exist, proceeding with release." | ||
| echo "exists=false" >> "$GITHUB_OUTPUT" | ||
| fi |
There was a problem hiding this comment.
The workflow can run concurrently for multiple pushes that touch lib/build.gradle. Without a concurrency group, two runs can both observe the tag as missing and attempt to publish/create the same release in parallel, leading to duplicate publish attempts or failed releases. Add a workflow/job-level concurrency key (e.g., grouped by version or by workflow) to serialize/cancel overlapping runs.
There was a problem hiding this comment.
Added a concurrency group with cancel-in-progress: false so overlapping runs are queued rather than cancelled.
| if: steps.tag_check.outputs.exists == 'false' | ||
| run: | | ||
| echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --batch --import |
There was a problem hiding this comment.
GPG_PRIVATE_KEY is base64-decoded before import, which means the secret must be stored base64-encoded; however the repo docs (e.g., CONTRIBUTING release prerequisites) don’t specify this encoding requirement. Either update the documentation to explicitly require base64 for GPG_PRIVATE_KEY, or remove the base64 --decode and import an ASCII-armored key directly to match typical secret setup.
There was a problem hiding this comment.
Added a comment in the workflow documenting the base64 encoding requirement with the command to generate it.
- Bump actions/cache from v3 to v4 (Node 16 deprecation) - Add concurrency group to prevent parallel release attempts - Document base64 encoding requirement for GPG_PRIVATE_KEY secret
Summary
mainthat modifylib/build.gradle(i.e., version bumps)publishToCentralPortalRequired secrets
GPG_PRIVATE_KEY/GPG_PASSPHRASE— for artifact signingMAVEN_CENTRAL_USERNAME/MAVEN_CENTRAL_PASSWORD— Maven Central credentialsTest plan
lib/build.gradleto trigger the workflow