feat: source-aware version bumps and pre-releases #31

Merged
jmiller merged 1 commits from feat/source-aware-bumps into main 2026-06-23 22:13:59 +00:00
2 changed files with 98 additions and 2 deletions
+46 -1
View File
@@ -41,9 +41,53 @@ jobs:
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
token: ${{ secrets.MOKOGITEA_TOKEN }}
fetch-depth: 1
fetch-depth: 2
- name: Check for source changes
id: source-check
run: |
# Read platform and source directory from manifest
PLATFORM=""
SOURCE_DIR=""
if [ -f ".mokogitea/manifest.xml" ]; then
PLATFORM=$(grep -oP '<platform>\K[^<]+' .mokogitea/manifest.xml 2>/dev/null || true)
SOURCE_DIR=$(grep -oP '<source-dir>\K[^<]+' .mokogitea/manifest.xml 2>/dev/null || true)
ENTRY=$(grep -oP '<entry-point>\K[^<]+' .mokogitea/manifest.xml 2>/dev/null || true)
SOURCE_DIR="${SOURCE_DIR:-$ENTRY}"
fi
# Default source dirs by platform
if [ -z "$SOURCE_DIR" ]; then
case "$PLATFORM" in
joomla) SOURCE_DIR="src/ source/ htdocs/" ;;
dolibarr) SOURCE_DIR="src/ htdocs/" ;;
*) SOURCE_DIR="" ;;
esac
fi
# If no platform or source dir, always bump (generic repos)
if [ -z "$SOURCE_DIR" ]; then
echo "has_source_changes=true" >> "$GITHUB_OUTPUT"
echo "No platform manifest — defaulting to bump"
exit 0
fi
# Check if the last commit touched any source files
CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || true)
HAS_CHANGES=false
for DIR in $SOURCE_DIR; do
DIR="${DIR%/}"
if echo "$CHANGED" | grep -q "^${DIR}/"; then
HAS_CHANGES=true
break
fi
done
echo "has_source_changes=$HAS_CHANGES" >> "$GITHUB_OUTPUT"
echo "Platform: ${PLATFORM:-generic}, Source: ${SOURCE_DIR}, Changes: ${HAS_CHANGES}"
- name: Setup mokocli tools
if: steps.source-check.outputs.has_source_changes == 'true'
run: |
if ! command -v composer &> /dev/null; then
sudo apt-get update -qq && sudo apt-get install -y -qq php-cli php-mbstring php-xml php-zip php-curl composer >/dev/null 2>&1
@@ -59,6 +103,7 @@ jobs:
fi
- name: Bump version
if: steps.source-check.outputs.has_source_changes == 'true'
run: |
php ${MOKO_CLI}/version_auto_bump.php \
--path . --branch "${GITHUB_REF_NAME}" \
+52 -1
View File
@@ -55,11 +55,56 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 2
token: ${{ secrets.MOKOGITEA_TOKEN }}
ref: ${{ github.ref_name }}
- name: Check for source changes
id: source-check
if: github.event_name == 'push'
run: |
# Read platform and source directory from manifest
PLATFORM=""
SOURCE_DIR=""
if [ -f ".mokogitea/manifest.xml" ]; then
PLATFORM=$(grep -oP '<platform>\K[^<]+' .mokogitea/manifest.xml 2>/dev/null || true)
SOURCE_DIR=$(grep -oP '<source-dir>\K[^<]+' .mokogitea/manifest.xml 2>/dev/null || true)
ENTRY=$(grep -oP '<entry-point>\K[^<]+' .mokogitea/manifest.xml 2>/dev/null || true)
SOURCE_DIR="${SOURCE_DIR:-$ENTRY}"
fi
# Default source dirs by platform
if [ -z "$SOURCE_DIR" ]; then
case "$PLATFORM" in
joomla) SOURCE_DIR="src/ source/ htdocs/" ;;
dolibarr) SOURCE_DIR="src/ htdocs/" ;;
*) SOURCE_DIR="" ;;
esac
fi
# If no platform or source dir, always build (generic repos)
if [ -z "$SOURCE_DIR" ]; then
echo "has_source_changes=true" >> "$GITHUB_OUTPUT"
echo "No platform manifest — defaulting to build"
exit 0
fi
# Check if the last commit touched any source files
CHANGED=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || true)
HAS_CHANGES=false
for DIR in $SOURCE_DIR; do
DIR="${DIR%/}"
if echo "$CHANGED" | grep -q "^${DIR}/"; then
HAS_CHANGES=true
break
fi
done
echo "has_source_changes=$HAS_CHANGES" >> "$GITHUB_OUTPUT"
echo "Platform: ${PLATFORM:-generic}, Source: ${SOURCE_DIR}, Changes: ${HAS_CHANGES}"
- name: Setup mokocli tools
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
env:
MOKO_CLONE_TOKEN: ${{ secrets.MOKOGITEA_TOKEN }}
MOKO_CLONE_HOST: git.mokoconsulting.tech/MokoConsulting
@@ -81,6 +126,7 @@ jobs:
fi
- name: Detect platform
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
id: platform
run: |
# Auto-detect and update platform if not set in manifest
@@ -88,6 +134,7 @@ jobs:
php ${MOKO_CLI}/manifest_read.php --path . --github-output
- name: Resolve metadata and bump version
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
id: meta
run: |
# Auto-detect stability from branch name on push, or use input on dispatch
@@ -164,6 +211,7 @@ jobs:
echo "=== Pre-Release: ${EXT_ELEMENT} ${VERSION}${SUFFIX} ==="
- name: Create release
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
id: release
run: |
TAG="${{ steps.meta.outputs.tag }}"
@@ -175,6 +223,7 @@ jobs:
--repo "${GITEA_REPO}" --branch "${{ github.ref_name }}" --prerelease
- name: Update release notes from CHANGELOG.md
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
run: |
TAG="${{ steps.meta.outputs.tag }}"
VERSION="${{ steps.meta.outputs.version }}"
@@ -210,6 +259,7 @@ jobs:
fi
- name: Build package and upload
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
id: package
run: |
VERSION="${{ steps.meta.outputs.version }}"
@@ -224,6 +274,7 @@ jobs:
# No need to build, commit, or sync updates.xml from workflows
- name: "Delete lesser pre-release channels (cascade)"
if: github.event_name == 'workflow_dispatch' || steps.source-check.outputs.has_source_changes == 'true'
continue-on-error: true
run: |
API_BASE="${GITEA_URL}/api/v1/repos/${GITEA_ORG}/${GITEA_REPO}"