Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/pod-trunk-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Wrapper around `pod trunk push` that treats a 409 Conflict
# ("Unable to accept duplicate entry") from trunk as success.
#
# Why: trunk sometimes returns 504 Gateway Timeout while the spec
# still lands in CocoaPods/Specs (Heroku 30s router cap on the
# GitHub Commits API call). Without this wrapper, re-running the
# failed publish job fails again with 409 "duplicate entry",
# keeping the workflow red even though the release is actually done.

set -uo pipefail

if [ $# -lt 1 ]; then
echo "usage: $0 <Pod.podspec> [pod trunk push args...]" >&2
exit 64
fi

PODSPEC="$1"; shift

set +e
OUT="$(pod trunk push "$PODSPEC" "$@" 2>&1)"
RC=$?
set -e
printf '%s\n' "$OUT"

if [ "$RC" -eq 0 ]; then
exit 0
fi

if grep -qE 'HTTP/1\.[01] 409 Conflict|Unable to accept duplicate entry' <<<"$OUT"; then
echo "[pod-trunk-push] trunk returned 409 — version already published, treating as success"
exit 0
fi

exit "$RC"
6 changes: 3 additions & 3 deletions .github/workflows/publish-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Deploy to Cocoapods MindboxLogger
run: |
pod lib lint MindboxLogger.podspec --allow-warnings
pod trunk push MindboxLogger.podspec --allow-warnings --verbose
./.github/pod-trunk-push.sh MindboxLogger.podspec --allow-warnings --verbose
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }}

Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
pod repo update
set -eo pipefail
pod lib lint MindboxNotifications.podspec --allow-warnings
pod trunk push MindboxNotifications.podspec --allow-warnings --verbose
./.github/pod-trunk-push.sh MindboxNotifications.podspec --allow-warnings --verbose
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }}

Expand All @@ -130,7 +130,7 @@ jobs:
pod repo update
set -eo pipefail
pod lib lint Mindbox.podspec --allow-warnings
pod trunk push Mindbox.podspec --allow-warnings --verbose
./.github/pod-trunk-push.sh Mindbox.podspec --allow-warnings --verbose
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TOKEN }}

Expand Down