chore: update .github/workflows/auto-release.yml from MokoStandards
This commit is contained in:
82
.github/workflows/auto-release.yml
vendored
82
.github/workflows/auto-release.yml
vendored
@@ -9,7 +9,7 @@
|
|||||||
# INGROUP: MokoStandards.Release
|
# INGROUP: MokoStandards.Release
|
||||||
# REPO: https://github.com/mokoconsulting-tech/MokoStandards
|
# REPO: https://github.com/mokoconsulting-tech/MokoStandards
|
||||||
# PATH: /templates/workflows/shared/auto-release.yml
|
# PATH: /templates/workflows/shared/auto-release.yml
|
||||||
# VERSION: 04.01.00
|
# VERSION: 04.02.00
|
||||||
# BRIEF: Auto-create a GitHub Release on every push to main with version from README.md
|
# BRIEF: Auto-create a GitHub Release on every push to main with version from README.md
|
||||||
# NOTE: Synced via bulk-repo-sync to .github/workflows/auto-release.yml in all governed repos.
|
# NOTE: Synced via bulk-repo-sync to .github/workflows/auto-release.yml in all governed repos.
|
||||||
# For Dolibarr (crm-module) repos, also updates $this->version in the module descriptor.
|
# For Dolibarr (crm-module) repos, also updates $this->version in the module descriptor.
|
||||||
@@ -41,10 +41,21 @@ jobs:
|
|||||||
token: ${{ secrets.GH_TOKEN || github.token }}
|
token: ${{ secrets.GH_TOKEN || github.token }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup MokoStandards tools
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
|
||||||
|
COMPOSER_AUTH: '{"github-oauth":{"github.com":"${{ secrets.GH_TOKEN || github.token }}"}}'
|
||||||
|
run: |
|
||||||
|
git clone --depth 1 --branch version/04.02.00 --quiet \
|
||||||
|
"https://x-access-token:${GH_TOKEN}@github.com/mokoconsulting-tech/MokoStandards.git" \
|
||||||
|
/tmp/mokostandards
|
||||||
|
cd /tmp/mokostandards
|
||||||
|
composer install --no-dev --no-interaction --quiet
|
||||||
|
|
||||||
- name: Extract version from README.md
|
- name: Extract version from README.md
|
||||||
id: version
|
id: version
|
||||||
run: |
|
run: |
|
||||||
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 found in README.md — skipping release"
|
echo "⚠️ No VERSION found in README.md — skipping release"
|
||||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||||
@@ -67,32 +78,13 @@ jobs:
|
|||||||
echo "exists=false" >> "$GITHUB_OUTPUT"
|
echo "exists=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Update Dolibarr module version
|
- name: Set platform version
|
||||||
if: >-
|
if: >-
|
||||||
steps.version.outputs.skip != 'true' &&
|
steps.version.outputs.skip != 'true' &&
|
||||||
steps.tag_check.outputs.exists != 'true'
|
steps.tag_check.outputs.exists != 'true'
|
||||||
run: |
|
run: |
|
||||||
PLATFORM=""
|
|
||||||
if [ -f ".moko-standards" ]; then
|
|
||||||
PLATFORM=$(grep -E '^platform:' .moko-standards | sed 's/.*:[[:space:]]*//' | tr -d '"')
|
|
||||||
fi
|
|
||||||
|
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
php /tmp/mokostandards/api/cli/version_set_platform.php --path . --version "$VERSION"
|
||||||
if [ "$PLATFORM" = "crm-module" ]; then
|
|
||||||
echo "📦 Dolibarr release — setting module version to '${VERSION}'"
|
|
||||||
# Update $this->version in the module descriptor (core/modules/mod*.class.php)
|
|
||||||
find . -path "*/core/modules/mod*.class.php" -exec \
|
|
||||||
sed -i "s/\(\$this->version\s*=\s*\)['\"][^'\"]*['\"]/\1'${VERSION}'/" {} + 2>/dev/null || true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$PLATFORM" = "waas-component" ]; then
|
|
||||||
echo "📦 Joomla release — setting manifest version to '${VERSION}'"
|
|
||||||
# Update <version> tag in Joomla XML manifest files
|
|
||||||
find . -maxdepth 2 -name "*.xml" -exec grep -l '<extension' {} \; 2>/dev/null | while read -r manifest; do
|
|
||||||
sed -i "s|<version>[^<]*</version>|<version>${VERSION}</version>|" "$manifest" 2>/dev/null || true
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Commit the version update if anything changed
|
# Commit the version update if anything changed
|
||||||
if ! git diff --quiet; then
|
if ! git diff --quiet; then
|
||||||
@@ -111,13 +103,7 @@ jobs:
|
|||||||
id: changelog
|
id: changelog
|
||||||
run: |
|
run: |
|
||||||
VERSION="${{ steps.version.outputs.version }}"
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
NOTES=$(php /tmp/mokostandards/api/cli/release_notes.php --path . --version "$VERSION" 2>/dev/null)
|
||||||
# Try to extract the section for this version from CHANGELOG.md
|
|
||||||
NOTES=""
|
|
||||||
if [ -f "CHANGELOG.md" ]; then
|
|
||||||
# Extract text between this version's heading and the next heading
|
|
||||||
NOTES=$(awk "/^##.*${VERSION}/,/^## /" CHANGELOG.md | head -50 | sed '1d;$d')
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$NOTES" ]; then
|
if [ -z "$NOTES" ]; then
|
||||||
NOTES="Release ${VERSION}"
|
NOTES="Release ${VERSION}"
|
||||||
@@ -149,6 +135,42 @@ jobs:
|
|||||||
|
|
||||||
echo "🚀 Release ${VERSION} created: $TAG"
|
echo "🚀 Release ${VERSION} created: $TAG"
|
||||||
|
|
||||||
|
- name: Write update.json for Dolibarr update checks
|
||||||
|
if: >-
|
||||||
|
steps.version.outputs.skip != 'true' &&
|
||||||
|
steps.tag_check.outputs.exists != 'true'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
|
||||||
|
run: |
|
||||||
|
PLATFORM=""
|
||||||
|
if [ -f ".moko-standards" ]; then
|
||||||
|
PLATFORM=$(grep -E '^platform:' .moko-standards | sed 's/.*:[[:space:]]*//' | tr -d '"')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PLATFORM" = "crm-module" ]; then
|
||||||
|
VERSION="${{ steps.version.outputs.version }}"
|
||||||
|
TAG="${{ steps.version.outputs.tag }}"
|
||||||
|
|
||||||
|
# update.json — read by Dolibarr's module update checker via $this->url_last_version
|
||||||
|
# Points to: https://raw.githubusercontent.com/mokoconsulting-tech/{repo}/main/update.json
|
||||||
|
jq -n \
|
||||||
|
--arg version "$VERSION" \
|
||||||
|
--arg tag "$TAG" \
|
||||||
|
--arg repo "${{ github.repository }}" \
|
||||||
|
--arg release "https://github.com/${{ github.repository }}/releases/tag/${TAG}" \
|
||||||
|
--arg updated "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||||
|
'{version: $version, tag: $tag, repo: $repo, release_url: $release, updated: $updated}' \
|
||||||
|
> update.json
|
||||||
|
|
||||||
|
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git config --local user.name "github-actions[bot]"
|
||||||
|
git add update.json
|
||||||
|
git commit -m "chore(release): update update.json to ${VERSION} [skip ci]" \
|
||||||
|
--author="github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||||
|
git push
|
||||||
|
echo "📦 update.json written with version ${VERSION}" >> $GITHUB_STEP_SUMMARY
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Summary
|
- name: Summary
|
||||||
if: steps.version.outputs.skip != 'true'
|
if: steps.version.outputs.skip != 'true'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user