fix: make release workflow idempotent
- Check if version is already updated before trying to update - Check if tag already exists before creating - Check if GitHub release already exists before creating - This allows re-running the workflow after partial failures Previously, if the workflow failed after updating version but before completing the release, it couldn't be re-run with the same version.
This commit is contained in:
50
.github/workflows/release-manual.yml
vendored
50
.github/workflows/release-manual.yml
vendored
@@ -31,16 +31,26 @@ jobs:
|
|||||||
- name: Update versions and push
|
- name: Update versions and push
|
||||||
id: push
|
id: push
|
||||||
run: |
|
run: |
|
||||||
./scripts/bump_version.sh ${{ inputs.version }}
|
# Check current version
|
||||||
git config user.name "GitHub Actions"
|
CURRENT_VERSION=$(grep "^version" packages/leann-core/pyproject.toml | cut -d'"' -f2)
|
||||||
git config user.email "actions@github.com"
|
echo "Current version: $CURRENT_VERSION"
|
||||||
git add packages/*/pyproject.toml
|
echo "Target version: ${{ inputs.version }}"
|
||||||
git commit -m "chore: release v${{ inputs.version }}"
|
|
||||||
git push origin main
|
if [ "$CURRENT_VERSION" = "${{ inputs.version }}" ]; then
|
||||||
|
echo "⚠️ Version is already ${{ inputs.version }}, skipping update"
|
||||||
|
COMMIT_SHA=$(git rev-parse HEAD)
|
||||||
|
else
|
||||||
|
./scripts/bump_version.sh ${{ inputs.version }}
|
||||||
|
git config user.name "GitHub Actions"
|
||||||
|
git config user.email "actions@github.com"
|
||||||
|
git add packages/*/pyproject.toml
|
||||||
|
git commit -m "chore: release v${{ inputs.version }}"
|
||||||
|
git push origin main
|
||||||
|
COMMIT_SHA=$(git rev-parse HEAD)
|
||||||
|
echo "✅ Pushed version update: $COMMIT_SHA"
|
||||||
|
fi
|
||||||
|
|
||||||
COMMIT_SHA=$(git rev-parse HEAD)
|
|
||||||
echo "commit-sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
|
echo "commit-sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
|
||||||
echo "✅ Pushed version update: $COMMIT_SHA"
|
|
||||||
|
|
||||||
build-packages:
|
build-packages:
|
||||||
name: Build packages
|
name: Build packages
|
||||||
@@ -93,12 +103,24 @@ jobs:
|
|||||||
|
|
||||||
- name: Create release
|
- name: Create release
|
||||||
run: |
|
run: |
|
||||||
git tag "v${{ inputs.version }}"
|
# Check if tag already exists
|
||||||
git push origin "v${{ inputs.version }}"
|
if git rev-parse "v${{ inputs.version }}" >/dev/null 2>&1; then
|
||||||
|
echo "⚠️ Tag v${{ inputs.version }} already exists, skipping tag creation"
|
||||||
|
else
|
||||||
|
git tag "v${{ inputs.version }}"
|
||||||
|
git push origin "v${{ inputs.version }}"
|
||||||
|
echo "✅ Created and pushed tag v${{ inputs.version }}"
|
||||||
|
fi
|
||||||
|
|
||||||
gh release create "v${{ inputs.version }}" \
|
# Check if release already exists
|
||||||
--title "Release v${{ inputs.version }}" \
|
if gh release view "v${{ inputs.version }}" >/dev/null 2>&1; then
|
||||||
--notes "🚀 Released to PyPI: https://pypi.org/project/leann/${{ inputs.version }}/" \
|
echo "⚠️ Release v${{ inputs.version }} already exists, skipping release creation"
|
||||||
--latest
|
else
|
||||||
|
gh release create "v${{ inputs.version }}" \
|
||||||
|
--title "Release v${{ inputs.version }}" \
|
||||||
|
--notes "🚀 Released to PyPI: https://pypi.org/project/leann/${{ inputs.version }}/" \
|
||||||
|
--latest
|
||||||
|
echo "✅ Created GitHub release v${{ inputs.version }}"
|
||||||
|
fi
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
Reference in New Issue
Block a user