Skip to content

Commit da1160e

Browse files
authored
MOBILE-0000: Treat trunk 409 Conflict as success in pod push wrapper (#709)
CocoaPods trunk sometimes returns 504 Gateway Timeout while the spec still lands in CocoaPods/Specs. Re-running the failed publish job then fails again with 409 "Unable to accept duplicate entry", keeping the release red even though it is actually done. Wrap pod trunk push in .github/pod-trunk-push.sh and treat 409 as a successful no-op so a single re-run closes the release cleanly.
1 parent f342d0f commit da1160e

2 files changed

Lines changed: 38 additions & 3 deletions

File tree

.github/pod-trunk-push.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# Wrapper around `pod trunk push` that treats a 409 Conflict
3+
# ("Unable to accept duplicate entry") from trunk as success.
4+
#
5+
# Why: trunk sometimes returns 504 Gateway Timeout while the spec
6+
# still lands in CocoaPods/Specs (Heroku 30s router cap on the
7+
# GitHub Commits API call). Without this wrapper, re-running the
8+
# failed publish job fails again with 409 "duplicate entry",
9+
# keeping the workflow red even though the release is actually done.
10+
11+
set -uo pipefail
12+
13+
if [ $# -lt 1 ]; then
14+
echo "usage: $0 <Pod.podspec> [pod trunk push args...]" >&2
15+
exit 64
16+
fi
17+
18+
PODSPEC="$1"; shift
19+
20+
set +e
21+
OUT="$(pod trunk push "$PODSPEC" "$@" 2>&1)"
22+
RC=$?
23+
set -e
24+
printf '%s\n' "$OUT"
25+
26+
if [ "$RC" -eq 0 ]; then
27+
exit 0
28+
fi
29+
30+
if grep -qE 'HTTP/1\.[01] 409 Conflict|Unable to accept duplicate entry' <<<"$OUT"; then
31+
echo "[pod-trunk-push] trunk returned 409 — version already published, treating as success"
32+
exit 0
33+
fi
34+
35+
exit "$RC"

.github/workflows/publish-reusable.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
- name: Deploy to Cocoapods MindboxLogger
5656
run: |
5757
pod lib lint MindboxLogger.podspec --allow-warnings
58-
pod trunk push MindboxLogger.podspec --allow-warnings --verbose
58+
./.github/pod-trunk-push.sh MindboxLogger.podspec --allow-warnings --verbose
5959
env:
6060
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }}
6161

@@ -103,7 +103,7 @@ jobs:
103103
pod repo update
104104
set -eo pipefail
105105
pod lib lint MindboxNotifications.podspec --allow-warnings
106-
pod trunk push MindboxNotifications.podspec --allow-warnings --verbose
106+
./.github/pod-trunk-push.sh MindboxNotifications.podspec --allow-warnings --verbose
107107
env:
108108
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }}
109109

@@ -130,7 +130,7 @@ jobs:
130130
pod repo update
131131
set -eo pipefail
132132
pod lib lint Mindbox.podspec --allow-warnings
133-
pod trunk push Mindbox.podspec --allow-warnings --verbose
133+
./.github/pod-trunk-push.sh Mindbox.podspec --allow-warnings --verbose
134134
env:
135135
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }}
136136

0 commit comments

Comments
 (0)