chore: Sync MokoStandards 04.03.00 #105

Closed
jmiller-moko wants to merge 38 commits from chore/sync-mokostandards-v04.03.00 into main
Showing only changes of commit 3570893d22 - Show all commits

View File

@@ -9,7 +9,7 @@
# INGROUP: MokoStandards.Automation # INGROUP: MokoStandards.Automation
# REPO: https://github.com/mokoconsulting-tech/MokoStandards # REPO: https://github.com/mokoconsulting-tech/MokoStandards
# PATH: /templates/workflows/shared/sync-version-on-merge.yml # PATH: /templates/workflows/shared/sync-version-on-merge.yml
# VERSION: 04.01.00 # VERSION: 04.03.00
# BRIEF: Auto-bump patch version on every push to main and propagate to all file headers # BRIEF: Auto-bump patch version on every push to main and propagate to all file headers
# NOTE: Synced via bulk-repo-sync to .github/workflows/sync-version-on-merge.yml in all governed repos. # NOTE: Synced via bulk-repo-sync to .github/workflows/sync-version-on-merge.yml in all governed repos.
# README.md is the single source of truth for the repository version. # README.md is the single source of truth for the repository version.
@@ -32,6 +32,9 @@ permissions:
contents: write contents: write
issues: write issues: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs: jobs:
sync-version: sync-version:
name: Propagate README version name: Propagate README version
@@ -45,7 +48,7 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Set up PHP - name: Set up PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2.31.0 uses: shivammathur/setup-php@fcafdd6392932010c2bd5094439b8e33be2a8a09 # v2.37.0
with: with:
php-version: '8.1' php-version: '8.1'
tools: composer tools: composer
@@ -55,7 +58,7 @@ jobs:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }} GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || github.token }}"}}' COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || github.token }}"}}'
run: | run: |
git clone --depth 1 --quiet \ git clone --depth 1 --branch version/04.03.00 --quiet \
"https://x-access-token:${GH_TOKEN}@github.com/mokoconsulting-tech/MokoStandards.git" \ "https://x-access-token:${GH_TOKEN}@github.com/mokoconsulting-tech/MokoStandards.git" \
/tmp/mokostandards /tmp/mokostandards
cd /tmp/mokostandards cd /tmp/mokostandards
@@ -64,31 +67,20 @@ jobs:
- name: Auto-bump patch version - name: Auto-bump patch version
if: ${{ github.event_name == 'push' && github.actor != 'github-actions[bot]' }} if: ${{ github.event_name == 'push' && github.actor != 'github-actions[bot]' }}
run: | run: |
# If README.md was part of this push, the author already bumped the version — skip.
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -q '^README\.md$'; then if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -q '^README\.md$'; then
echo "README.md changed in this push — skipping auto-bump" echo "README.md changed in this push — skipping auto-bump"
exit 0 exit 0
fi fi
CURRENT=$(grep -oP '^\s*VERSION:\s*\K[0-9]{2}\.[0-9]{2}\.[0-9]{2}' README.md | head -1) RESULT=$(php /tmp/mokostandards/api/cli/version_bump.php --path .) || {
if [ -z "$CURRENT" ]; then echo "⚠️ Could not bump version — skipping"
echo "⚠️ No VERSION found in README.md — skipping auto-bump"
exit 0 exit 0
fi }
echo "Auto-bumping patch: $RESULT"
# Increment the patch component (zero-padded to 2 digits)
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
NEW_PATCH=$(printf '%02d' $(( 10#$PATCH + 1 )))
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "Auto-bumping patch: $CURRENT → $NEW_VERSION"
sed -i "s/^\(\s*VERSION:\s*\)${CURRENT}/\1${NEW_VERSION}/" README.md
git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]" git config --local user.name "github-actions[bot]"
git add README.md git add README.md
git commit -m "chore(version): auto-bump patch ${CURRENT} → ${NEW_VERSION} [skip ci]" \ git commit -m "chore(version): auto-bump patch ${RESULT} [skip ci]" \
--author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>" --author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
git push git push
@@ -96,7 +88,7 @@ jobs:
id: readme_version id: readme_version
run: | run: |
git pull --ff-only 2>/dev/null || true git pull --ff-only 2>/dev/null || true
VERSION=$(grep -oP '^\s*VERSION:\s*\K[0-9]{2}\.[0-9]{2}\.[0-9]{2}' README.md | head -1) VERSION=$(php /tmp/mokostandards/api/cli/version_read.php --path . 2>/dev/null)
if [ -z "$VERSION" ]; then if [ -z "$VERSION" ]; then
echo "⚠️ No VERSION in README.md — skipping propagation" echo "⚠️ No VERSION in README.md — skipping propagation"
echo "skip=true" >> $GITHUB_OUTPUT echo "skip=true" >> $GITHUB_OUTPUT
@@ -119,8 +111,9 @@ jobs:
- name: Commit updated files - name: Commit updated files
if: ${{ steps.readme_version.outputs.skip != 'true' && inputs.dry_run != true }} if: ${{ steps.readme_version.outputs.skip != 'true' && inputs.dry_run != true }}
run: | run: |
git pull --ff-only 2>/dev/null || true
if git diff --quiet; then if git diff --quiet; then
echo " No version changes needed" echo " No version changes needed — already up to date"
exit 0 exit 0
fi fi
VERSION="${{ steps.readme_version.outputs.version }}" VERSION="${{ steps.readme_version.outputs.version }}"