From c3d8c39eb4b1ec45b2d0144e470c44e41447e1e2 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Feb 2026 14:48:04 +0000 Subject: [PATCH] Allow release workflow to replace assets on existing releases The release job now handles re-running against an existing release: - Checks out the repo and force-moves the version tag to the current commit - Deletes any existing assets on the release before uploading the new zip - Renames the step to "Create or update release" to reflect the new behavior https://claude.ai/code/session_01FWSK8s3zk7obtW7SkvGXtY --- .github/workflows/build.yml | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1822c11..5d945c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -104,11 +104,38 @@ jobs: QL_VERSION: ${{ inputs.quantlib_version || '1.41' }} steps: + - uses: actions/checkout@v4 + + - name: Move tag to current commit + run: | + TAG="v${{ env.QL_VERSION }}" + git tag -f "$TAG" + git push origin "$TAG" --force + - uses: actions/download-artifact@v4 with: name: "QuantLib-${{ env.QL_VERSION }}-x64-dll" - - name: Create Release + - name: Delete existing release assets + env: + GH_TOKEN: ${{ github.token }} + run: | + TAG="v${{ env.QL_VERSION }}" + echo "Checking for existing release with tag $TAG..." + RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/$TAG \ + --jq '.id' 2>/dev/null || true) + if [ -n "$RELEASE_ID" ]; then + echo "Found release $RELEASE_ID — deleting existing assets..." + gh api repos/${{ github.repository }}/releases/$RELEASE_ID/assets \ + --jq '.[].id' | while read ASSET_ID; do + echo " Deleting asset $ASSET_ID" + gh api -X DELETE repos/${{ github.repository }}/releases/assets/$ASSET_ID + done + else + echo "No existing release for $TAG — nothing to clean up." + fi + + - name: Create or update release uses: softprops/action-gh-release@v2 with: tag_name: "v${{ env.QL_VERSION }}"