refactor: split modules to separate repos

This commit is contained in:
2026-06-02 14:05:27 +08:00
parent 7bb9383c2b
commit e4e1eb824b
2 changed files with 16 additions and 100 deletions
+15 -99
View File
@@ -1,25 +1,18 @@
# This workflow publishes one or more modules to Maven Central when a version tag is pushed # Publishes onixbyte-tuple to Maven Central when a version tag is pushed to main.
# to the main branch.
# #
# Supported tag formats: # Supported tag format: <major>.<minor>.<patch>[-suffix] (e.g. 3.3.1, 3.3.1-alpha)
# <module>/v<version> — publish a single module (e.g. tuple/v3.3.1)
# <module>+<module>/v<version> — publish multiple modules (e.g. tuple+crypto-toolbox/v3.3.1)
# v<version> — publish all modules (e.g. v3.4.0)
#
# Valid module names: common-toolbox, tuple, identity-generator, crypto-toolbox, math-toolbox, version-catalogue
name: Publish Packages to Maven Central name: Publish Package to Maven Central
on: on:
push: push:
tags: tags:
- 'v[0-9]*.[0-9]*.[0-9]*' - '[0-9]*.[0-9]*.[0-9]*'
- '*/v[0-9]*.[0-9]*.[0-9]*'
jobs: jobs:
publish: publish:
name: Build and Publish name: Build and Publish
runs-on: self-hosted runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
@@ -38,63 +31,12 @@ jobs:
fi fi
echo "✓ Tag ${{ github.ref_name }} is on main" echo "✓ Tag ${{ github.ref_name }} is on main"
- name: Parse Tag - name: Extract Version
id: parse-tag id: version
run: | run: |
declare -A MODULE_PROPS=( VERSION="${{ github.ref_name }}"
["common-toolbox"]="commonToolboxVersion" echo "version=${VERSION}" >> $GITHUB_OUTPUT
["tuple"]="tupleVersion" echo "Version: ${VERSION}"
["identity-generator"]="identityGeneratorVersion"
["crypto-toolbox"]="cryptoToolboxVersion"
["math-toolbox"]="mathToolboxVersion"
["version-catalogue"]="versionCatalogueVersion"
)
TAG="${{ github.ref_name }}"
echo "Tag: ${TAG}"
# <module>[+<module>...]/v<version> — one or more specific modules
if [[ "${TAG}" =~ ^([a-z][a-z0-9-]+(\+[a-z][a-z0-9-]+)*)/v?([0-9]+\.[0-9]+\.[0-9]+.*)$ ]]; then
IFS='+' read -ra MODULES <<< "${BASH_REMATCH[1]}"
VERSION="${BASH_REMATCH[3]}"
# v<version> — all modules
else
MODULES=("common-toolbox" "tuple" "identity-generator" "crypto-toolbox" "math-toolbox" "version-catalogue")
VERSION="${TAG#v}"
fi
# Validate all modules
for m in "${MODULES[@]}"; do
if [ -z "${MODULE_PROPS[$m]}" ]; then
echo "::error::Unknown module: ${m}"
echo "Valid modules: ${!MODULE_PROPS[*]}"
exit 1
fi
done
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "count=${#MODULES[@]}" >> $GITHUB_OUTPUT
for m in "${MODULES[@]}"; do
echo "→ ${m} @ ${VERSION}"
done
# Store module list as a multi-line output
{
echo "modules<<MODULES_EOF"
printf '%s\n' "${MODULES[@]}"
echo "MODULES_EOF"
} >> $GITHUB_OUTPUT
# Store property mappings
{
echo "props<<PROPS_EOF"
for m in "${MODULES[@]}"; do
echo "${m}=${MODULE_PROPS[$m]}"
done
echo "PROPS_EOF"
} >> $GITHUB_OUTPUT
- name: Setup GPG TTY - name: Setup GPG TTY
run: export GPG_TTY=$(tty) run: export GPG_TTY=$(tty)
@@ -134,42 +76,16 @@ jobs:
- name: Build with Gradle - name: Build with Gradle
env: env:
MODULES: ${{ steps.parse-tag.outputs.modules }} VERSION: ${{ steps.version.outputs.version }}
PROPS: ${{ steps.parse-tag.outputs.props }} run: ./gradlew build "-PartefactVersion=${VERSION}"
VERSION: ${{ steps.parse-tag.outputs.version }}
run: |
declare -A MODULE_PROPS
while IFS='=' read -r key value; do
MODULE_PROPS[$key]="$value"
done <<< "$PROPS"
while IFS= read -r MODULE; do
echo "::group::Building ${MODULE}"
PROP="${MODULE_PROPS[$MODULE]}"
./gradlew ":${MODULE}:build" "-P${PROP}=${VERSION}"
echo "::endgroup::"
done <<< "$MODULES"
- name: List Output Items - name: List Output Items
run: ls -l ./**/build/libs run: ls -l ./build/libs
- name: Publish to Maven Central - name: Publish to Maven Central
env: env:
MODULES: ${{ steps.parse-tag.outputs.modules }} VERSION: ${{ steps.version.outputs.version }}
PROPS: ${{ steps.parse-tag.outputs.props }} run: ./gradlew publish "-PartefactVersion=${VERSION}"
VERSION: ${{ steps.parse-tag.outputs.version }}
run: |
declare -A MODULE_PROPS
while IFS='=' read -r key value; do
MODULE_PROPS[$key]="$value"
done <<< "$PROPS"
while IFS= read -r MODULE; do
echo "::group::Publishing ${MODULE}"
PROP="${MODULE_PROPS[$MODULE]}"
./gradlew ":${MODULE}:publish" "-P${PROP}=${VERSION}"
echo "::endgroup::"
done <<< "$MODULES"
- name: Create Deployment on Central Publisher Portal - name: Create Deployment on Central Publisher Portal
run: | run: |
+1 -1
View File
@@ -20,7 +20,7 @@
# SOFTWARE. # SOFTWARE.
# #
artefactVersion=3.3.0 artefactVersion=3.4.0
commonToolboxVersion=3.4.0 commonToolboxVersion=3.4.0
tupleVersion=3.3.0 tupleVersion=3.3.0
identityGeneratorVersion=3.3.0 identityGeneratorVersion=3.3.0