Skip to content

Commit caf4d0d

Browse files
committed
fix: update documentation version references and add rollback mechanism on release failure
1 parent dddf800 commit caf4d0d

1 file changed

Lines changed: 28 additions & 17 deletions

File tree

.github/workflows/publish-maven.yml

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ jobs:
9191
echo "- **Release version:** $RELEASE_VERSION" >> $GITHUB_STEP_SUMMARY
9292
echo "- **Next development version:** $DEV_VERSION" >> $GITHUB_STEP_SUMMARY
9393
94+
- name: Update documentation with release version
95+
id: update-docs
96+
run: |
97+
VERSION="${{ steps.versions.outputs.release_version }}"
98+
99+
# Update version in README.md
100+
sed -i "s|<version>[0-9]*\.[0-9]*\.[0-9]*</version>|<version>${VERSION}</version>|g" README.md
101+
sed -i "s|copilot-sdk:[0-9]*\.[0-9]*\.[0-9]*|copilot-sdk:${VERSION}|g" README.md
102+
103+
# Update version in jbang-example.java
104+
sed -i "s|copilot-sdk:[0-9]*\.[0-9]*\.[0-9]*|copilot-sdk:${VERSION}|g" jbang-example.java
105+
106+
# Commit the documentation changes before release:prepare (requires clean working directory)
107+
git add README.md jbang-example.java
108+
git commit -m "docs: update version references to ${VERSION}"
109+
110+
# Save the commit SHA for potential rollback
111+
echo "docs_commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
112+
113+
git push origin main
114+
94115
- name: Prepare Release
95116
run: |
96117
mvn -B release:prepare \
@@ -114,25 +135,15 @@ jobs:
114135
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
115136
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
116137

117-
- name: Update documentation with the released version
138+
- name: Rollback documentation commit on failure
139+
if: failure() && steps.update-docs.outputs.docs_commit_sha != ''
118140
run: |
119-
VERSION="${{ steps.versions.outputs.release_version }}"
120-
121-
# Update version in README.md
122-
sed -i "s|<version>[0-9]*\.[0-9]*\.[0-9]*</version>|<version>${VERSION}</version>|g" README.md
123-
sed -i "s|copilot-sdk:[0-9]*\.[0-9]*\.[0-9]*|copilot-sdk:${VERSION}|g" README.md
124-
125-
# Update version in jbang-example.java
126-
sed -i "s|copilot-sdk:[0-9]*\.[0-9]*\.[0-9]*|copilot-sdk:${VERSION}|g" jbang-example.java
127-
128-
# Stage the documentation changes (will be committed by release:prepare)
129-
git add README.md jbang-example.java
130-
131-
# Commit
132-
git commit -m "Update documentation for version ${VERSION}"
133-
134-
# Push
141+
echo "Release failed, rolling back documentation commit..."
142+
git revert --no-edit ${{ steps.update-docs.outputs.docs_commit_sha }}
135143
git push origin main
144+
145+
# Also run Maven release:rollback to clean up any partial release state
146+
mvn -B release:rollback || true
136147
137148
github-release:
138149
name: Create GitHub Release

0 commit comments

Comments
 (0)