Update release_from_version.yml

This commit is contained in:
2025-12-18 19:10:46 -06:00
parent 5d63ecb8b7
commit b6cc8e6f31

View File

@@ -2,17 +2,13 @@ name: Release from Version Branch Pipeline
on:
workflow_dispatch:
inputs:
source_branch:
description: "Source dev branch. Example dev/03.06.00"
required: true
permissions:
contents: write
jobs:
rename_branch:
name: 01 Promote dev to version
guard:
name: 00 Guard enforce dev version branch
runs-on: ubuntu-latest
outputs:
@@ -20,38 +16,45 @@ jobs:
version_branch: ${{ steps.extract.outputs.version_branch }}
steps:
- name: Extract Version from Branch Name
- name: Validate calling branch and extract version
id: extract
run: |
set -euo pipefail
SRC="${{ inputs.source_branch }}"
BRANCH="${GITHUB_REF_NAME}"
echo "Invoked from branch: $BRANCH"
echo "$SRC" | grep -E '^dev/[0-9]+\.[0-9]+\.[0-9]+$'
echo "$BRANCH" | grep -E '^dev/[0-9]+\.[0-9]+\.[0-9]+$'
VERSION="${SRC#dev/}"
VERSION="${BRANCH#dev/}"
VERSION_BRANCH="version/$VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "version_branch=$VERSION_BRANCH" >> "$GITHUB_OUTPUT"
- name: Checkout Source Branch
promote_branch:
name: 01 Promote dev to version
runs-on: ubuntu-latest
needs: guard
steps:
- name: Checkout dev branch
uses: actions/checkout@v4
with:
ref: ${{ inputs.source_branch }}
ref: dev/${{ needs.guard.outputs.version }}
fetch-depth: 0
- name: Configure Git Identity
- name: Configure Git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Promote dev branch to version branch
- name: Promote branch
run: |
set -euo pipefail
SRC="${{ inputs.source_branch }}"
DST="${{ steps.extract.outputs.version_branch }}"
SRC="dev/${{ needs.guard.outputs.version }}"
DST="${{ needs.guard.outputs.version_branch }}"
git fetch origin
@@ -63,3 +66,127 @@ jobs:
git checkout -B "$DST" "origin/$SRC"
git push origin "$DST"
git push origin --delete "$SRC"
update_dates:
name: 02 Normalize release dates
runs-on: ubuntu-latest
needs: promote_branch
steps:
- name: Checkout version branch
uses: actions/checkout@v4
with:
ref: ${{ needs.guard.outputs.version_branch }}
fetch-depth: 0
- name: Configure Git identity
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update release dates
run: |
set -euo pipefail
TODAY="$(date -u +%Y-%m-%d)"
VERSION="${{ needs.guard.outputs.version }}"
if [ -f scripts/update_dates.sh ]; then
chmod +x scripts/update_dates.sh
scripts/update_dates.sh "$TODAY" "$VERSION"
else
find . -type f -name "*.xml" \
-not -path "./.git/*" \
-exec sed -i "s#<date>[^<]*</date>#<date>${TODAY}</date>#g" {} \;
if [ -f CHANGELOG.md ]; then
sed -i -E "s#^(## \\[${VERSION}\\]) [0-9]{4}-[0-9]{2}-[0-9]{2}#\\1 ${TODAY}#g" CHANGELOG.md
fi
fi
- name: Commit date updates
run: |
if git diff --quiet; then
echo "No date changes detected."
exit 0
fi
git add -A
git commit -m "chore(release): normalize release dates"
git push origin HEAD
build_zip:
name: 03 Build ZIP
runs-on: ubuntu-latest
needs: update_dates
steps:
- name: Checkout version branch
uses: actions/checkout@v4
with:
ref: ${{ needs.guard.outputs.version_branch }}
- name: Build ZIP from src
run: |
set -euo pipefail
VERSION="${{ needs.guard.outputs.version }}"
REPO="${{ github.event.repository.name }}"
ZIP="${REPO}-${VERSION}.zip"
if [ ! -d src ]; then
echo "ERROR: src directory missing."
exit 1
fi
mkdir -p dist
cd src
zip -r "../dist/$ZIP" .
cd ..
- name: Upload ZIP artifact
uses: actions/upload-artifact@v4
with:
name: release-zip
path: dist/*.zip
retention-days: 7
prerelease:
name: 04 Create prerelease
runs-on: ubuntu-latest
needs: build_zip
steps:
- name: Checkout version branch
uses: actions/checkout@v4
with:
ref: ${{ needs.guard.outputs.version_branch }}
- name: Download ZIP artifact
uses: actions/download-artifact@v4
with:
name: release-zip
path: dist
- name: Generate release notes
run: |
set -euo pipefail
VERSION="${{ needs.guard.outputs.version }}"
if [ -f CHANGELOG.md ]; then
awk "/^## \\[$VERSION\\]/{flag=1;next}/^## \\[/{flag=0}flag" CHANGELOG.md > RELEASE_NOTES.md || true
fi
if [ ! -s RELEASE_NOTES.md ]; then
echo "Prerelease $VERSION" > RELEASE_NOTES.md
fi
- name: Create GitHub prerelease
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.guard.outputs.version }}
name: Prerelease ${{ needs.guard.outputs.version }}
prerelease: true
body_path: RELEASE_NOTES.md
files: dist/*.zip