Skip to content

Merge branch 'main' into workflow-yaml-fixes #21

Merge branch 'main' into workflow-yaml-fixes

Merge branch 'main' into workflow-yaml-fixes #21

name: Changelog Sync
on:
release:
types: [published, edited]
workflow_dispatch:
inputs:
sync_all:
description: 'Sync all releases to changelog'
required: false
type: boolean
default: false
concurrency:
group: changelog-sync-${{ github.ref || 'workflow-dispatch' }}
cancel-in-progress: false
permissions:
contents: write
pull-requests: write
jobs:
sync-changelog:

Check failure on line 23 in .github/workflows/changelog-sync.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/changelog-sync.yml

Invalid workflow file

You have an error in your yaml syntax on line 23
name: Sync Changelog with Releases
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Setup Git
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Sync single release
run: |
echo "test"
- name: Sync all releases
if: github.event_name == 'workflow_dispatch' && github.event.inputs.sync_all == 'true'
run: |
echo "Syncing all releases to changelog..."
# Get all releases
gh release list --limit 50 --json tagName,name,body,publishedAt | jq -r '.[] | "\(.tagName)|\(.publishedAt)|\(.body)"' > releases.txt
# Process each release
while IFS='|' read -r tag_name published_at body; do
if [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
version=${tag_name#v}
release_date=$(date -d "$published_at" +"%Y-%m-%d" 2>/dev/null || date -u +"%Y-%m-%d")
echo "Processing release $tag_name..."
# Check if version exists in changelog
if ! grep -q "## \[$version\]" CHANGELOG.md; then
echo "Adding $version to changelog..."
# Add basic entry (detailed sync will happen on next release event)
export VERSION=$version
export RELEASE_DATE=$release_date
python3 << 'EOF'
import os
import re
version = os.environ['VERSION']
release_date = os.environ['RELEASE_DATE']
with open('CHANGELOG.md', 'r') as f:
content = f.read()
changelog_entry = f"## [{version}] - {release_date}\n\n### Changed\n- Release {version}\n\n"
# Insert in chronological order
lines = content.split('\n')
new_lines = []
inserted = False
for line in lines:
if line.startswith('## [') and not inserted and not line.startswith('## [Unreleased]'):
# Check if we should insert before this version
match = re.match(r'## \[([^\]]+)\]', line)
if match:
existing_version = match.group(1)
# Simple version comparison (may need improvement for complex versions)
if version > existing_version:
new_lines.extend(changelog_entry.split('\n'))
inserted = True
new_lines.append(line)
if not inserted:
# Add at the end before any existing versions
for i, line in enumerate(new_lines):
if line.startswith('## [') and not line.startswith('## [Unreleased]'):
new_lines.insert(i, '')
new_lines.insert(i, changelog_entry.strip())
break
with open('CHANGELOG.md', 'w') as f:
f.write('\n'.join(new_lines))
EOF
fi
fi
done < releases.txt
rm -f releases.txt
- name: Commit changes
run: |
if ! git diff --quiet CHANGELOG.md; then
git add CHANGELOG.md
if [ "${{ github.event_name }}" = "release" ]; then
git commit -m "docs: sync changelog with release ${{ github.event.release.tag_name }} [skip ci]"
else
git commit -m "docs: sync changelog with all releases [skip ci]"
fi
git push
echo "✅ Changelog synchronized with releases!"
else
echo "ℹ️ No changes needed in changelog"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
update-release-descriptions:
name: Update Release Descriptions
runs-on: ubuntu-latest
needs: sync-changelog
if: github.event_name == 'workflow_dispatch' && github.event.inputs.sync_all == 'true'
steps:
- name: Checkout code
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
- name: Update all release descriptions
run: |
echo "Updating all release descriptions with enhanced format..."
# Get releases that might need updating
gh release list --limit 20 --json tagName,body | jq -r '.[] | select(.body | length < 500 or (contains("### 📦 Assets") | not)) | .tagName' > releases_to_update.txt
while read -r tag_name; do
if [[ "$tag_name" =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
echo "Triggering enhanced release workflow for $tag_name..."
# Trigger the enhanced release workflow
gh workflow run release-consolidated.yml -f tag="$tag_name"
# Wait a bit to avoid rate limiting
sleep 5
fi
done < releases_to_update.txt
rm -f releases_to_update.txt
echo "✅ Triggered enhanced release updates for outdated releases"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}