|
29 | 29 | echo "version=$(python ./setup.py --version)" >> $GITHUB_OUTPUT |
30 | 30 | echo "Version detected: $(python ./setup.py --version)" |
31 | 31 |
|
| 32 | + - name: Validate version alignment |
| 33 | + run: | |
| 34 | + VERSION="${{ steps.getversion.outputs.version }}" |
| 35 | + ERRORS=0 |
| 36 | +
|
| 37 | + # Check CHANGELOG.md has the version section |
| 38 | + if ! grep -q "^## \[$VERSION\]" CHANGELOG.md; then |
| 39 | + echo "::error file=CHANGELOG.md::CHANGELOG.md is missing a section for version [$VERSION]. The workflow extracts release notes from the CHANGELOG, so this section must exist before releasing. Expected format: '## [$VERSION] - YYYY-MM-DD'" |
| 40 | + ERRORS=1 |
| 41 | + fi |
| 42 | +
|
| 43 | + # Check README.md has the version |
| 44 | + if ! grep -q "rev: v$VERSION" README.md; then |
| 45 | + CURRENT_README_VERSION=$(grep -m 1 "rev: v" README.md | sed -n 's/.*rev: v\([0-9.]*\).*/\1/p') |
| 46 | + echo "::error file=README.md::README.md version (v$CURRENT_README_VERSION) does not match setup.py version ($VERSION). Update all 'rev: v' references in README.md to 'rev: v$VERSION' before releasing." |
| 47 | + ERRORS=1 |
| 48 | + fi |
| 49 | +
|
| 50 | + # Check version link exists in CHANGELOG.md |
| 51 | + if ! grep -q "^\[$VERSION\]:" CHANGELOG.md; then |
| 52 | + echo "::error file=CHANGELOG.md::CHANGELOG.md is missing a version comparison link for [$VERSION]. Add '[$VERSION]: https://github.com/homebysix/pre-commit-macadmin/compare/vPREVIOUS...v$VERSION' at the bottom of CHANGELOG.md." |
| 53 | + ERRORS=1 |
| 54 | + fi |
| 55 | +
|
| 56 | + if [ $ERRORS -gt 0 ]; then |
| 57 | + echo "" |
| 58 | + echo "❌ Version alignment check failed. Please ensure:" |
| 59 | + echo " 1. CHANGELOG.md has a '## [$VERSION]' section with release notes" |
| 60 | + echo " 2. README.md has 'rev: v$VERSION' in all examples" |
| 61 | + echo " 3. CHANGELOG.md has a '[$VERSION]:' comparison link at the bottom" |
| 62 | + echo "" |
| 63 | + exit 1 |
| 64 | + fi |
| 65 | +
|
| 66 | + echo "✅ Version $VERSION is properly aligned across all files" |
| 67 | +
|
32 | 68 | - name: Fetch tags |
33 | 69 | run: git fetch --tags origin |
34 | 70 |
|
@@ -84,56 +120,32 @@ jobs: |
84 | 120 | echo "next=$NEXT_VERSION" >> $GITHUB_OUTPUT |
85 | 121 | echo "Next version will be: $NEXT_VERSION" |
86 | 122 |
|
87 | | - - name: Update setup.py version |
| 123 | + - name: Merge main to dev |
88 | 124 | if: steps.tagcheck.outputs.should_release == 'true' |
89 | 125 | run: | |
90 | | - sed -i 's/version="${{ steps.getversion.outputs.version }}"/version="${{ steps.nextversion.outputs.next }}"/' setup.py |
| 126 | + git config user.name "github-actions[bot]" |
| 127 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 128 | + git fetch origin dev |
| 129 | + git checkout dev |
| 130 | + git merge origin/main --no-edit |
91 | 131 |
|
92 | | - - name: Update README.md version |
| 132 | + - name: Update setup.py version on dev |
93 | 133 | if: steps.tagcheck.outputs.should_release == 'true' |
94 | 134 | run: | |
95 | | - sed -i 's/rev: v${{ steps.getversion.outputs.version }}/rev: v${{ steps.nextversion.outputs.next }}/g' README.md |
| 135 | + sed -i 's/version="${{ steps.getversion.outputs.version }}"/version="${{ steps.nextversion.outputs.next }}"/' setup.py |
96 | 136 |
|
97 | | - - name: Update CHANGELOG.md |
| 137 | + - name: Update README.md version on dev |
98 | 138 | if: steps.tagcheck.outputs.should_release == 'true' |
99 | 139 | run: | |
100 | | - CURRENT="${{ steps.getversion.outputs.version }}" |
101 | | - NEXT="${{ steps.nextversion.outputs.next }}" |
102 | | - TODAY=$(date +%Y-%m-%d) |
103 | | -
|
104 | | - # Create temp file with new changelog section |
105 | | - cat > /tmp/changelog_update.txt << 'ENDOFCHANGELOG' |
106 | | - ## [Unreleased] |
107 | | -
|
108 | | - Nothing yet. |
109 | | -
|
110 | | - ## [NEXT_VERSION] - TODAY_PLACEHOLDER |
111 | | - ENDOFCHANGELOG |
112 | | -
|
113 | | - # Replace placeholders |
114 | | - sed -i "s/NEXT_VERSION/$NEXT/g" /tmp/changelog_update.txt |
115 | | - sed -i "s/TODAY_PLACEHOLDER/$TODAY/g" /tmp/changelog_update.txt |
116 | | -
|
117 | | - # Insert new section after the first "## [Unreleased]" line |
118 | | - sed -i "/## \[Unreleased\]/r /tmp/changelog_update.txt" CHANGELOG.md |
119 | | - # Remove the old "## [Unreleased]" and "Nothing yet." lines |
120 | | - sed -i '1,/Nothing yet\./ { /## \[Unreleased\]/d; /Nothing yet\./d }' CHANGELOG.md |
121 | | -
|
122 | | - # Update version comparison links at bottom |
123 | | - # Update [Unreleased] link |
124 | | - sed -i "s|\[Unreleased\]:.*|[Unreleased]: https://github.com/homebysix/pre-commit-macadmin/compare/v$NEXT...HEAD|" CHANGELOG.md |
125 | | - # Add new version link after [Unreleased] |
126 | | - sed -i "/\[Unreleased\]:/a [$NEXT]: https://github.com/homebysix/pre-commit-macadmin/compare/v$CURRENT...v$NEXT" CHANGELOG.md |
| 140 | + sed -i 's/rev: v${{ steps.getversion.outputs.version }}/rev: v${{ steps.nextversion.outputs.next }}/g' README.md |
127 | 141 |
|
128 | | - - name: Commit version bump |
| 142 | + - name: Commit version bump on dev |
129 | 143 | if: steps.tagcheck.outputs.should_release == 'true' |
130 | 144 | run: | |
131 | | - git config user.name "github-actions[bot]" |
132 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
133 | | - git add setup.py README.md CHANGELOG.md |
134 | | - git commit -m "Bump to ${{ steps.nextversion.outputs.next }} [skip ci]" |
| 145 | + git add setup.py README.md |
| 146 | + git commit -m "Bump to ${{ steps.nextversion.outputs.next }}" |
135 | 147 |
|
136 | | - - name: Push changes |
| 148 | + - name: Push dev branch |
137 | 149 | if: steps.tagcheck.outputs.should_release == 'true' |
138 | 150 | run: | |
139 | | - git push origin main |
| 151 | + git push origin dev |
0 commit comments