@ondeinference / onde / commits / c1d2c89

Prevent force-pushing tags in release workflow

Avoids moving existing tags to prevent breaking SPM consumers. Adds a warning and skip if the tag already exists on the remote.

Seto Elkahfi committed Apr 9, 2026 at 22:21 UTC c1d2c89d14b01594d841d9a2419a372e4144c824
1 file changed +13 -2
.github/workflows/release-sdk-swift.yml
+13 -2
@@ -153,6 +153,17 @@ jobs:
153 git commit -m "Release $VERSION"
154 fi
155
156 - git tag -f "$VERSION"
156 + # Push the commit to main first so the tag points to the latest HEAD
157 git push origin HEAD:main
158 - git push origin "$VERSION" --force
158 +
159 + # Create an annotated tag only if it doesn't already exist on the remote.
160 + # Never force-overwrite — SPM caches the resolved commit SHA per tag,
161 + # so moving a tag silently breaks every consumer's Package.resolved.
162 + if git ls-remote --tags origin "refs/tags/$VERSION" | grep -q "refs/tags/$VERSION"; then
163 + echo "::warning::Tag $VERSION already exists on onde-swift — skipping tag push."
164 + echo "To re-release this version, delete the remote tag first:"
165 + echo " git push origin :refs/tags/$VERSION"
166 + else
167 + git tag -a "$VERSION" -m "Release $VERSION"
168 + git push origin "refs/tags/$VERSION"
169 + fi