refactor(build): decouple per-module versioning
Each module uses its own version property instead of a shared artefactVersion, so changes to one module no longer force a version bump across all modules. CI now supports per-module release tags with the format <module>/v<version>.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support
|
||||
# documentation.
|
||||
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
|
||||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
|
||||
# This workflow publishes one or all modules to Maven Central when a GitHub Release is published.
|
||||
#
|
||||
# Supported release tag formats:
|
||||
# <module-name>/v<version> — publish a single module (e.g. tuple/v3.3.1)
|
||||
# v<version> — publish all modules (e.g. v3.3.0, backward compat)
|
||||
#
|
||||
# Valid module names: common-toolbox, tuple, identity-generator, crypto-toolbox, math-toolbox, version-catalogue
|
||||
|
||||
name: Publish Packages to GitHub Packages with Gradle
|
||||
name: Publish Packages to Maven Central
|
||||
|
||||
on:
|
||||
release:
|
||||
@@ -13,7 +14,7 @@ on:
|
||||
- published
|
||||
|
||||
jobs:
|
||||
build:
|
||||
publish:
|
||||
name: Build and Publish
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
@@ -24,6 +25,47 @@ jobs:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.2.2
|
||||
|
||||
- name: Parse Release Tag
|
||||
id: parse-tag
|
||||
run: |
|
||||
TAG="${{ github.event.release.tag_name }}"
|
||||
echo "Release tag: ${TAG}"
|
||||
|
||||
# <module>/v<version> — single module
|
||||
if [[ "${TAG}" =~ ^([a-z][a-z0-9-]*)/v?([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
|
||||
MODULE="${BASH_REMATCH[1]}"
|
||||
VERSION="${BASH_REMATCH[2]}"
|
||||
|
||||
case "${MODULE}" in
|
||||
common-toolbox) PROP="commonToolboxVersion" ;;
|
||||
tuple) PROP="tupleVersion" ;;
|
||||
identity-generator) PROP="identityGeneratorVersion" ;;
|
||||
crypto-toolbox) PROP="cryptoToolboxVersion" ;;
|
||||
math-toolbox) PROP="mathToolboxVersion" ;;
|
||||
version-catalogue) PROP="versionCatalogueVersion" ;;
|
||||
*)
|
||||
echo "::error::Unknown module: ${MODULE}"
|
||||
echo "Valid modules: common-toolbox, tuple, identity-generator, crypto-toolbox, math-toolbox, version-catalogue"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "module=${MODULE}" >> $GITHUB_OUTPUT
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "gradle_property=${PROP}" >> $GITHUB_OUTPUT
|
||||
echo "gradle_project=:${MODULE}" >> $GITHUB_OUTPUT
|
||||
echo "single_module=true" >> $GITHUB_OUTPUT
|
||||
|
||||
echo "→ Publishing single module: ${MODULE} @ ${VERSION}"
|
||||
|
||||
# v<version> — all modules (backward compat)
|
||||
else
|
||||
VERSION="${TAG#v}"
|
||||
echo "version=${VERSION}" >> $GITHUB_OUTPUT
|
||||
echo "single_module=false" >> $GITHUB_OUTPUT
|
||||
echo "→ Publishing all modules @ ${VERSION}"
|
||||
fi
|
||||
|
||||
- name: Setup GPG TTY
|
||||
run: export GPG_TTY=$(tty)
|
||||
|
||||
@@ -61,19 +103,50 @@ jobs:
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
# Overwrite artefactVersion with tag name
|
||||
run: ./gradlew build -PartefactVersion=${{ github.event.release.tag_name }}
|
||||
env:
|
||||
SINGLE: ${{ steps.parse-tag.outputs.single_module }}
|
||||
PROJECT: ${{ steps.parse-tag.outputs.gradle_project }}
|
||||
PROPERTY: ${{ steps.parse-tag.outputs.gradle_property }}
|
||||
VERSION: ${{ steps.parse-tag.outputs.version }}
|
||||
run: |
|
||||
if [ "${SINGLE}" = "true" ]; then
|
||||
./gradlew "${PROJECT}:build" "-P${PROPERTY}=${VERSION}"
|
||||
else
|
||||
./gradlew build \
|
||||
-PcommonToolboxVersion="${VERSION}" \
|
||||
-PtupleVersion="${VERSION}" \
|
||||
-PidentityGeneratorVersion="${VERSION}" \
|
||||
-PcryptoToolboxVersion="${VERSION}" \
|
||||
-PmathToolboxVersion="${VERSION}" \
|
||||
-PversionCatalogueVersion="${VERSION}"
|
||||
fi
|
||||
|
||||
- name: List Output Items
|
||||
run: ls -l ./**/build/libs
|
||||
|
||||
- name: Publish to Maven Central
|
||||
run: ./gradlew publish
|
||||
env:
|
||||
SINGLE: ${{ steps.parse-tag.outputs.single_module }}
|
||||
PROJECT: ${{ steps.parse-tag.outputs.gradle_project }}
|
||||
PROPERTY: ${{ steps.parse-tag.outputs.gradle_property }}
|
||||
VERSION: ${{ steps.parse-tag.outputs.version }}
|
||||
run: |
|
||||
if [ "${SINGLE}" = "true" ]; then
|
||||
./gradlew "${PROJECT}:publish" "-P${PROPERTY}=${VERSION}"
|
||||
else
|
||||
./gradlew publish \
|
||||
-PcommonToolboxVersion="${VERSION}" \
|
||||
-PtupleVersion="${VERSION}" \
|
||||
-PidentityGeneratorVersion="${VERSION}" \
|
||||
-PcryptoToolboxVersion="${VERSION}" \
|
||||
-PmathToolboxVersion="${VERSION}" \
|
||||
-PversionCatalogueVersion="${VERSION}"
|
||||
fi
|
||||
|
||||
- name: Create Deployment on Central Publisher Portal
|
||||
run: |
|
||||
curl --fail -X 'POST' \
|
||||
'https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.onixbyte?publishing_type=user_managed' \
|
||||
-H 'accept: */*' \
|
||||
-H 'Authorization: Bearer ${{ secrets.MAVEN_PORTAL_TOKEN }}' \
|
||||
-d ''
|
||||
'https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/com.onixbyte?publishing_type=user_managed' \
|
||||
-H 'accept: */*' \
|
||||
-H 'Authorization: Bearer ${{ secrets.MAVEN_PORTAL_TOKEN }}' \
|
||||
-d ''
|
||||
|
||||
Reference in New Issue
Block a user