Skip to content

Commit 73ff4c0

Browse files
claudefumitoh
authored andcommitted
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
1 parent 38ff047 commit 73ff4c0

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

.github/workflows/build.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,38 @@ jobs:
104104
QL_VERSION: ${{ inputs.quantlib_version || '1.41' }}
105105

106106
steps:
107+
- uses: actions/checkout@v4
108+
109+
- name: Move tag to current commit
110+
run: |
111+
TAG="v${{ env.QL_VERSION }}"
112+
git tag -f "$TAG"
113+
git push origin "$TAG" --force
114+
107115
- uses: actions/download-artifact@v4
108116
with:
109117
name: "QuantLib-${{ env.QL_VERSION }}-x64-dll"
110118

111-
- name: Create Release
119+
- name: Delete existing release assets
120+
env:
121+
GH_TOKEN: ${{ github.token }}
122+
run: |
123+
TAG="v${{ env.QL_VERSION }}"
124+
echo "Checking for existing release with tag $TAG..."
125+
RELEASE_ID=$(gh api repos/${{ github.repository }}/releases/tags/$TAG \
126+
--jq '.id' 2>/dev/null || true)
127+
if [ -n "$RELEASE_ID" ]; then
128+
echo "Found release $RELEASE_ID — deleting existing assets..."
129+
gh api repos/${{ github.repository }}/releases/$RELEASE_ID/assets \
130+
--jq '.[].id' | while read ASSET_ID; do
131+
echo " Deleting asset $ASSET_ID"
132+
gh api -X DELETE repos/${{ github.repository }}/releases/assets/$ASSET_ID
133+
done
134+
else
135+
echo "No existing release for $TAG — nothing to clean up."
136+
fi
137+
138+
- name: Create or update release
112139
uses: softprops/action-gh-release@v2
113140
with:
114141
tag_name: "v${{ env.QL_VERSION }}"

0 commit comments

Comments
 (0)