From dfd50cc48de131e8ed00ab7ebc60c6b388eebbe4 Mon Sep 17 00:00:00 2001 From: Moko Consulting Date: Thu, 28 May 2026 14:14:42 -0500 Subject: [PATCH] =?UTF-8?q?fix(workflows):=20proper=20suffix=20handling=20?= =?UTF-8?q?=E2=80=94=20use=20version=5Fset=5Fplatform=20instead=20of=20sed?= =?UTF-8?q?=20[skip=20bump]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mokogitea/workflows/auto-bump.yml | 10 +-- .mokogitea/workflows/auto-release.yml | 92 ++++++++++++++------------ .mokogitea/workflows/pre-release.yml | 11 ++- .mokogitea/workflows/update-server.yml | 15 ++--- 4 files changed, 63 insertions(+), 65 deletions(-) diff --git a/.mokogitea/workflows/auto-bump.yml b/.mokogitea/workflows/auto-bump.yml index 9330fcc..4d0ffc0 100644 --- a/.mokogitea/workflows/auto-bump.yml +++ b/.mokogitea/workflows/auto-bump.yml @@ -63,16 +63,10 @@ jobs: VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null) || true [ -z "$VERSION" ] && { echo "No version found — skipping"; exit 0; } - # Propagate to platform manifests + # Propagate to platform manifests with -dev suffix php ${MOKO_CLI}/version_set_platform.php \ - --path . --version "$VERSION" --branch dev 2>/dev/null || true + --path . --version "$VERSION" --branch dev --stability dev 2>/dev/null || true php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true - - # Append -dev suffix to all manifest tags - find . -maxdepth 4 -name "*.xml" ! -path "./.git/*" ! -path "./build/*" \ - -exec grep -l "${VERSION}" {} \; 2>/dev/null | while read f; do - sed -i "s|${VERSION}|${VERSION}-dev|g" "$f" - done VERSION="${VERSION}-dev" # Commit if anything changed diff --git a/.mokogitea/workflows/auto-release.yml b/.mokogitea/workflows/auto-release.yml index 7c44796..8cdf410 100644 --- a/.mokogitea/workflows/auto-release.yml +++ b/.mokogitea/workflows/auto-release.yml @@ -140,10 +140,6 @@ jobs: - name: Detect platform id: platform run: | - if [ ! -f ".mokogitea/manifest.xml" ]; then - echo "::error::.mokogitea/manifest.xml not found — cannot release without platform manifest" - exit 1 - fi php /tmp/moko-platform-api/cli/manifest_read.php --path . --github-output MANIFEST=$(find . -maxdepth 3 -name "*.xml" ! -path "./.git/*" -exec grep -l '/dev/null | head -1 || true) MOD_FILE=$(find . -maxdepth 4 -name "mod*.class.php" ! -path "./.git/*" -exec grep -l 'extends DolibarrModules' {} \; 2>/dev/null | head -1 || true) @@ -159,6 +155,8 @@ jobs: echo "skip=true" >> "$GITHUB_OUTPUT" exit 0 fi + # Strip any pre-release suffix merged from dev (e.g. 01.02.20-dev → 01.02.20) + VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//') MAJOR=$(echo "$VERSION" | cut -d. -f1) echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "release_tag=stable" >> "$GITHUB_OUTPUT" @@ -263,8 +261,38 @@ jobs: php /tmp/moko-platform-api/cli/badge_update.php --path . --version "${VERSION}" 2>/dev/null || true php /tmp/moko-platform-api/cli/version_check.php --path . --fix 2>/dev/null || true - # NOTE: Commit is deferred until after updates.xml is written (after Step 8) - # so all changes (version bump + manifests + updates.xml) go in one atomic push. + # Step 5 (updates.xml) moved after Step 8 to include SHA-256 checksum + + - name: "Step 4b: Promote and prune CHANGELOG" + if: >- + steps.version.outputs.skip != 'true' && + steps.check.outputs.already_released != 'true' + run: | + VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}" + MOKO_API="/tmp/moko-platform-api/cli" + if [ -f "CHANGELOG.md" ]; then + php ${MOKO_API}/changelog_promote.php --path . --version "$VERSION" 2>&1 || true + php ${MOKO_API}/changelog_prune.php --path . --keep 5 2>&1 || true + fi + + - name: Commit release changes + if: >- + steps.version.outputs.skip != 'true' && + steps.check.outputs.already_released != 'true' + run: | + if git diff --quiet && git diff --cached --quiet; then + echo "No changes to commit" + exit 0 + fi + VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}" + git config --local user.email "gitea-actions[bot]@mokoconsulting.tech" + git config --local user.name "gitea-actions[bot]" + # Set push URL with token for branch-protected repos + git remote set-url origin "https://jmiller:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git" + git add -A + git commit -m "chore(release): build ${VERSION} [skip ci]" \ + --author="gitea-actions[bot] " + git push -u origin HEAD # -- STEP 6: Create tag --------------------------------------------------- - name: "Step 6: Create git tag" @@ -334,10 +362,13 @@ jobs: VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}" SHA256="${{ steps.package.outputs.sha256_zip }}" - if [ ! -f "updates.xml" ]; then - echo "No updates.xml — skipping" - exit 0 - fi + # Fetch latest updates.xml from main so preserve logic has all channels + GA_TOKEN="${{ secrets.GA_TOKEN }}" + API="${GITEA_URL}/api/v1/repos/${{ github.repository }}" + curl -sf -H "Authorization: token ${GA_TOKEN}" \ + "${API}/contents/updates.xml?ref=main" 2>/dev/null | \ + python3 -c "import sys,json,base64; print(base64.b64decode(json.load(sys.stdin)['content']).decode())" \ + > updates.xml 2>/dev/null || true SHA_FLAG="" [ -n "$SHA256" ] && SHA_FLAG="--sha ${SHA256}" @@ -347,40 +378,17 @@ jobs: --gitea-url "${GITEA_URL}" --org "${GITEA_ORG}" --repo "${GITEA_REPO}" \ ${SHA_FLAG} --github-output - # -- Commit all release changes (version bump + manifests + updates.xml) -- - - name: "Commit release changes" - if: >- - steps.version.outputs.skip != 'true' && - steps.check.outputs.already_released != 'true' - run: | - VERSION="${{ steps.bump.outputs.version || steps.version.outputs.version }}" - - # Re-align all version files (second pass catches anything the build touched) - php /tmp/moko-platform-api/cli/version_set_platform.php \ - --path . --version "$VERSION" --branch main 2>/dev/null || true - php /tmp/moko-platform-api/cli/version_check.php --path . --fix 2>/dev/null || true - - echo "=== Pre-commit version check ===" - php /tmp/moko-platform-api/cli/version_check.php --path . || true - echo "=== Files changed ===" - git status --short - - git config --local user.email "gitea-actions[bot]@mokoconsulting.tech" - git config --local user.name "gitea-actions[bot]" - git remote set-url origin "https://jmiller:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git" - git add -A - - if git diff --cached --quiet; then - echo "No changes to commit" - exit 0 + # Commit updates.xml if changed + if ! git diff --quiet updates.xml 2>/dev/null; then + git config --local user.email "gitea-actions[bot]@mokoconsulting.tech" + git config --local user.name "gitea-actions[bot]" + git remote set-url origin "https://jmiller:${{ secrets.GA_TOKEN }}@git.mokoconsulting.tech/${{ github.repository }}.git" + git add updates.xml + git commit -m "chore: update stable channel ${VERSION} [skip ci]" \ + --author="gitea-actions[bot] " + git push origin HEAD 2>&1 || true fi - git commit -m "chore(release): build ${VERSION} [skip ci]" \ - --author="gitea-actions[bot] " - # Push to main explicitly — Gitea Actions checks out a detached HEAD - # for PR merge events, so "git push origin HEAD" creates a dangling ref - git push origin HEAD:refs/heads/main - # -- STEP 8b: Update release description with changelog ---------------------- - name: "Step 8b: Update release body" if: steps.version.outputs.skip != 'true' diff --git a/.mokogitea/workflows/pre-release.yml b/.mokogitea/workflows/pre-release.yml index 49b91e8..edbe60e 100644 --- a/.mokogitea/workflows/pre-release.yml +++ b/.mokogitea/workflows/pre-release.yml @@ -87,18 +87,17 @@ jobs: VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null) [ -z "$VERSION" ] && VERSION="00.00.01" + # Strip any existing suffix from version before applying stability + VERSION=$(echo "$VERSION" | sed 's/-\(dev\|alpha\|beta\|rc\)$//') + php ${MOKO_CLI}/version_set_platform.php \ - --path . --version "$VERSION" --branch "${{ github.ref_name }}" 2>/dev/null || true + --path . --version "$VERSION" --branch "${{ github.ref_name }}" --stability "$STABILITY" 2>/dev/null || true # Verify version consistency across all files php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true - # Append suffix to all manifest tags + # Update VERSION variable with suffix if [ -n "$SUFFIX" ]; then - find . -maxdepth 4 -name "*.xml" ! -path "./.git/*" ! -path "./build/*" \ - -exec grep -l "${VERSION}" {} \; 2>/dev/null | while read f; do - sed -i "s|${VERSION}|${VERSION}${SUFFIX}|g" "$f" - done VERSION="${VERSION}${SUFFIX}" fi diff --git a/.mokogitea/workflows/update-server.yml b/.mokogitea/workflows/update-server.yml index 6d49e17..b99a5f2 100644 --- a/.mokogitea/workflows/update-server.yml +++ b/.mokogitea/workflows/update-server.yml @@ -113,10 +113,6 @@ jobs: VERSION=$(php ${MOKO_CLI}/version_read.php --path . 2>/dev/null || echo "0.0.0") - # Propagate version to all manifest files - php ${MOKO_CLI}/version_set_platform.php --path . --version "$VERSION" --branch "$BRANCH" 2>/dev/null || true - php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true - # Determine stability from branch or manual input if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then STABILITY="${{ inputs.stability }}" @@ -139,12 +135,13 @@ jobs: *) SUFFIX=""; TAG="stable" ;; esac - # Append suffix to all manifest tags (non-stable only) + # Propagate version with stability suffix to all manifest files + php ${MOKO_CLI}/version_set_platform.php \ + --path . --version "$VERSION" --branch "$BRANCH" --stability "$STABILITY" 2>/dev/null || true + php ${MOKO_CLI}/version_check.php --path . --fix 2>/dev/null || true + + # Re-read version (now includes suffix from version_set_platform) if [ -n "$SUFFIX" ]; then - find . -maxdepth 4 -name "*.xml" ! -path "./.git/*" ! -path "./build/*" \ - -exec grep -l "${VERSION}" {} \; 2>/dev/null | while read f; do - sed -i "s|${VERSION}|${VERSION}${SUFFIX}|g" "$f" - done VERSION="${VERSION}${SUFFIX}" fi