Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ jobs:
with:
fetch-depth: 0

- name: Update release-please manifest
run: |
# Update .release-please-manifest.json to keep release-please in sync
VERSION="${{ needs.version.outputs.version }}"
VERSION_NO_V="${VERSION#v}"

# Update manifest file
jq --arg version "$VERSION_NO_V" '."."] = $version' .release-please-manifest.json > manifest.tmp
mv manifest.tmp .release-please-manifest.json

# Commit manifest update
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .release-please-manifest.json
git commit -m "chore: sync manifest with manual release $VERSION [skip ci]"
git push origin main

- name: Create tag
run: |
git config user.name "github-actions[bot]"
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,26 @@ permissions:
pull-requests: write

jobs:
# First, sync manifest with actual tags to prevent drift
sync-manifest:
runs-on: ubuntu-latest
steps:
- name: Trigger manifest sync
uses: actions/github-script@v7
with:
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'sync-release-manifest.yml',
ref: 'main'
});

// Wait for sync to complete
await new Promise(resolve => setTimeout(resolve, 5000));

release-please:
runs-on: ubuntu-latest
needs: sync-manifest
steps:
- uses: google-github-actions/release-please-action@v4
85 changes: 85 additions & 0 deletions .github/workflows/sync-release-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Sync Release Manifest

# Auto-heal release-please manifest if it drifts from actual tags
# Runs before release-please to ensure consistency

on:
schedule:
# Run daily at 00:00 UTC
- cron: '0 0 * * *'
workflow_dispatch: # Allow manual trigger
push:
branches:
- main

jobs:
sync-manifest:
name: Sync Manifest with Git Tags
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check for manifest drift
id: check
run: |
# Get latest tag
LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || echo "v0.0.0")
LATEST_VERSION="${LATEST_TAG#v}"

# Get manifest version
MANIFEST_VERSION=$(jq -r '."."]' .release-please-manifest.json)

echo "Latest tag: $LATEST_TAG ($LATEST_VERSION)"
echo "Manifest version: $MANIFEST_VERSION"

# Check if they match
if [ "$LATEST_VERSION" != "$MANIFEST_VERSION" ]; then
echo "drift=true" >> $GITHUB_OUTPUT
echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "manifest_version=$MANIFEST_VERSION" >> $GITHUB_OUTPUT
echo "⚠️ Drift detected! Manifest needs update."
else
echo "drift=false" >> $GITHUB_OUTPUT
echo "✅ Manifest is in sync with tags."
fi

- name: Update manifest if drifted
if: steps.check.outputs.drift == 'true'
run: |
VERSION="${{ steps.check.outputs.latest_version }}"

# Update manifest
jq --arg version "$VERSION" '."."] = $version' .release-please-manifest.json > manifest.tmp
mv manifest.tmp .release-please-manifest.json

# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Commit and push
git add .release-please-manifest.json
git commit -m "chore: auto-sync manifest to $VERSION (was ${{ steps.check.outputs.manifest_version }}) [skip ci]"
git push origin main

echo "✅ Manifest synced: ${{ steps.check.outputs.manifest_version }} → $VERSION"

- name: Summary
run: |
if [ "${{ steps.check.outputs.drift }}" == "true" ]; then
echo "### 🔄 Manifest Auto-Synced" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Previous version:** ${{ steps.check.outputs.manifest_version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Latest tag:** ${{ steps.check.outputs.latest_version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Action:** Manifest updated automatically" >> $GITHUB_STEP_SUMMARY
else
echo "### ✅ Manifest In Sync" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "No action needed. Manifest matches latest tag." >> $GITHUB_STEP_SUMMARY
fi