Skip to content

Commit a5b295e

Browse files
authored
fix(release): make workflow idempotent and resilient (#291)
* fix(release): make workflow idempotent and resilient - Replace softprops/action-gh-release with gh CLI to handle existing releases (update instead of fail on re-runs) - Add continue-on-error to version bump step so Docker image pushes aren't marked as failed when the PR step has issues Signed-off-by: Aseem Shrey <LuD1161@users.noreply.github.com> * fix(release): use unique branch names for version bump PRs Append workflow run ID to the bump branch name so re-running the release for the same version doesn't fail due to branch conflicts. Also cleans up any stale bump branches from previous runs. Signed-off-by: Aseem Shrey <LuD1161@users.noreply.github.com> --------- Signed-off-by: Aseem Shrey <LuD1161@users.noreply.github.com> Co-authored-by: Aseem Shrey <LuD1161@users.noreply.github.com>
1 parent 6b3e039 commit a5b295e

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

.github/workflows/release.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,32 @@ jobs:
200200
cat CHANGELOG.md >> $GITHUB_OUTPUT
201201
echo "EOF" >> $GITHUB_OUTPUT
202202
203-
- name: Create GitHub Release
204-
uses: softprops/action-gh-release@v1
205-
with:
206-
tag_name: ${{ steps.version.outputs.version }}
207-
name: Release ${{ steps.version.outputs.version }}
208-
body_path: CHANGELOG.md
209-
draft: false
210-
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
203+
- name: Create or update GitHub Release
211204
env:
212-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
205+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
206+
run: |
207+
VERSION="${{ steps.version.outputs.version }}"
208+
IS_PRERELEASE="${{ contains(steps.version.outputs.version, '-') }}"
209+
PRERELEASE_FLAG=""
210+
if [ "$IS_PRERELEASE" = "true" ]; then
211+
PRERELEASE_FLAG="--prerelease"
212+
fi
213+
214+
# Check if release already exists
215+
if gh release view "$VERSION" --repo "${{ github.repository }}" > /dev/null 2>&1; then
216+
echo "Release $VERSION already exists, updating..."
217+
gh release edit "$VERSION" \
218+
--repo "${{ github.repository }}" \
219+
--notes-file CHANGELOG.md \
220+
$PRERELEASE_FLAG
221+
else
222+
echo "Creating new release $VERSION..."
223+
gh release create "$VERSION" \
224+
--repo "${{ github.repository }}" \
225+
--title "Release $VERSION" \
226+
--notes-file CHANGELOG.md \
227+
$PRERELEASE_FLAG
228+
fi
213229
214230
- name: Update version check service
215231
env:
@@ -264,17 +280,23 @@ jobs:
264280
265281
- name: Bump package.json version via PR
266282
if: steps.is_latest.outputs.is_latest == 'true'
283+
continue-on-error: true
267284
env:
268285
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
269286
run: |
270287
VERSION_CLEAN="${{ steps.version.outputs.version_clean }}"
271-
BRANCH="chore/bump-version-${VERSION_CLEAN}"
288+
RUN_ID="${{ github.run_id }}"
289+
BRANCH="chore/bump-version-${VERSION_CLEAN}-${RUN_ID}"
272290
echo "Bumping root package.json version to ${VERSION_CLEAN}..."
273291
274292
git config user.name "github-actions[bot]"
275293
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
276294
277295
git fetch origin main
296+
297+
# Clean up any existing bump branch for this version
298+
git push origin --delete "chore/bump-version-${VERSION_CLEAN}" 2>/dev/null || true
299+
278300
git checkout -b "$BRANCH" origin/main
279301
280302
# Update the root package.json version

0 commit comments

Comments
 (0)