Sync Changelog #185
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================================================ | |
| # Sync Changelog from GitHub Releases | |
| # ============================================================================ | |
| # | |
| # Appends new release content to the monthly changelog file. | |
| # Creates new monthly file if it doesn't exist. | |
| # | |
| # Structure: changelog/YYYY-MM.mdx (one file per month) | |
| # | |
| # Triggers: | |
| # - Daily at midnight UTC | |
| # - Manual trigger | |
| # | |
| # ============================================================================ | |
| name: Sync Changelog | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout docs repository | |
| uses: actions/checkout@v4 | |
| - name: Fetch recent releases | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh api repos/HyperscapeAI/hyperscape/releases --jq '.[0:10]' > /tmp/releases.json | |
| echo "Found $(jq length /tmp/releases.json) releases" | |
| - name: Process releases into monthly files | |
| run: | | |
| CHANGES_MADE=false | |
| jq -c '.[]' /tmp/releases.json | while read release; do | |
| TAG=$(echo "$release" | jq -r '.tag_name') | |
| NAME=$(echo "$release" | jq -r '.name // .tag_name') | |
| BODY=$(echo "$release" | jq -r '.body // ""') | |
| DATE=$(echo "$release" | jq -r '.published_at') | |
| # Parse date for monthly file | |
| YEAR=$(echo "$DATE" | cut -d'-' -f1) | |
| MONTH=$(echo "$DATE" | cut -d'-' -f2) | |
| DAY=$(echo "$DATE" | cut -d'T' -f1 | cut -d'-' -f3) | |
| FILEPATH="changelog/$YEAR-$MONTH.mdx" | |
| # Check if this release is already in the file | |
| if [ -f "$FILEPATH" ] && grep -q "$TAG" "$FILEPATH"; then | |
| echo "⏭️ Skipping $TAG (already in $FILEPATH)" | |
| continue | |
| fi | |
| # Create file if it doesn't exist | |
| if [ ! -f "$FILEPATH" ]; then | |
| MONTH_NAME=$(date -d "$YEAR-$MONTH-01" "+%B" 2>/dev/null || echo "Month $MONTH") | |
| cat > "$FILEPATH" << EOF | |
| --- | |
| title: "$MONTH_NAME $YEAR" | |
| description: "Updates and releases for $MONTH_NAME $YEAR" | |
| --- | |
| EOF | |
| echo "📁 Created: $FILEPATH" | |
| fi | |
| # Append release to file | |
| cat >> "$FILEPATH" << EOF | |
| ## $NAME ($TAG) | |
| *Released: $YEAR-$MONTH-$DAY* | |
| $BODY | |
| --- | |
| EOF | |
| echo "✅ Added $TAG to $FILEPATH" | |
| CHANGES_MADE=true | |
| done | |
| echo "changes_made=$CHANGES_MADE" >> $GITHUB_ENV | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if git diff --quiet && git diff --cached --quiet; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create Pull Request | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "docs(changelog): sync releases" | |
| title: "📝 Sync Changelog from Releases" | |
| body: | | |
| ## Automatic Changelog Sync | |
| Added new releases to monthly changelog files. | |
| **Manual Steps:** | |
| 1. Update `changelog/index.mdx` if new months were added | |
| 2. Update `docs.json` navigation if needed | |
| --- | |
| _Auto-generated by sync-changelog workflow_ | |
| branch: auto/sync-changelog | |
| delete-branch: true | |
| labels: | | |
| documentation | |
| automated |