|
| 1 | +name: Sync Release Manifest |
| 2 | + |
| 3 | +# Auto-heal release-please manifest if it drifts from actual tags |
| 4 | +# Runs before release-please to ensure consistency |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + # Run daily at 00:00 UTC |
| 9 | + - cron: '0 0 * * *' |
| 10 | + workflow_dispatch: # Allow manual trigger |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - main |
| 14 | + |
| 15 | +jobs: |
| 16 | + sync-manifest: |
| 17 | + name: Sync Manifest with Git Tags |
| 18 | + runs-on: ubuntu-latest |
| 19 | + permissions: |
| 20 | + contents: write |
| 21 | + pull-requests: write |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v5 |
| 25 | + with: |
| 26 | + fetch-depth: 0 |
| 27 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + |
| 29 | + - name: Check for manifest drift |
| 30 | + id: check |
| 31 | + run: | |
| 32 | + # Get latest tag |
| 33 | + LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -1 || echo "v0.0.0") |
| 34 | + LATEST_VERSION="${LATEST_TAG#v}" |
| 35 | +
|
| 36 | + # Get manifest version |
| 37 | + MANIFEST_VERSION=$(jq -r '."."]' .release-please-manifest.json) |
| 38 | +
|
| 39 | + echo "Latest tag: $LATEST_TAG ($LATEST_VERSION)" |
| 40 | + echo "Manifest version: $MANIFEST_VERSION" |
| 41 | +
|
| 42 | + # Check if they match |
| 43 | + if [ "$LATEST_VERSION" != "$MANIFEST_VERSION" ]; then |
| 44 | + echo "drift=true" >> $GITHUB_OUTPUT |
| 45 | + echo "latest_version=$LATEST_VERSION" >> $GITHUB_OUTPUT |
| 46 | + echo "manifest_version=$MANIFEST_VERSION" >> $GITHUB_OUTPUT |
| 47 | + echo "⚠️ Drift detected! Manifest needs update." |
| 48 | + else |
| 49 | + echo "drift=false" >> $GITHUB_OUTPUT |
| 50 | + echo "✅ Manifest is in sync with tags." |
| 51 | + fi |
| 52 | +
|
| 53 | + - name: Update manifest if drifted |
| 54 | + if: steps.check.outputs.drift == 'true' |
| 55 | + run: | |
| 56 | + VERSION="${{ steps.check.outputs.latest_version }}" |
| 57 | +
|
| 58 | + # Update manifest |
| 59 | + jq --arg version "$VERSION" '."."] = $version' .release-please-manifest.json > manifest.tmp |
| 60 | + mv manifest.tmp .release-please-manifest.json |
| 61 | +
|
| 62 | + # Configure git |
| 63 | + git config user.name "github-actions[bot]" |
| 64 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 65 | +
|
| 66 | + # Commit and push |
| 67 | + git add .release-please-manifest.json |
| 68 | + git commit -m "chore: auto-sync manifest to $VERSION (was ${{ steps.check.outputs.manifest_version }}) [skip ci]" |
| 69 | + git push origin main |
| 70 | +
|
| 71 | + echo "✅ Manifest synced: ${{ steps.check.outputs.manifest_version }} → $VERSION" |
| 72 | +
|
| 73 | + - name: Summary |
| 74 | + run: | |
| 75 | + if [ "${{ steps.check.outputs.drift }}" == "true" ]; then |
| 76 | + echo "### 🔄 Manifest Auto-Synced" >> $GITHUB_STEP_SUMMARY |
| 77 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 78 | + echo "- **Previous version:** ${{ steps.check.outputs.manifest_version }}" >> $GITHUB_STEP_SUMMARY |
| 79 | + echo "- **Latest tag:** ${{ steps.check.outputs.latest_version }}" >> $GITHUB_STEP_SUMMARY |
| 80 | + echo "- **Action:** Manifest updated automatically" >> $GITHUB_STEP_SUMMARY |
| 81 | + else |
| 82 | + echo "### ✅ Manifest In Sync" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 84 | + echo "No action needed. Manifest matches latest tag." >> $GITHUB_STEP_SUMMARY |
| 85 | + fi |
0 commit comments