@@ -78,9 +78,12 @@ local_version() {
7878}
7979
8080registry_version () {
81- # latest version on crates.io, "-" if not published
81+ # latest version on crates.io, "-" if not published. crates.io rejects
82+ # requests without a User-Agent (HTTP 403), so send one — otherwise this
83+ # always returns "-" and the skip check below never fires.
8284 local crate=" $1 "
83- curl -fsS " https://crates.io/api/v1/crates/$crate " 2> /dev/null \
85+ curl -fsS -H " User-Agent: tako-publish (dancixx@gmail.com)" \
86+ " https://crates.io/api/v1/crates/$crate " 2> /dev/null \
8487 | python3 -c " import sys,json; d=json.load(sys.stdin); print(d.get('crate',{}).get('newest_version','-'))" \
8588 2> /dev/null || echo " -"
8689}
@@ -106,12 +109,32 @@ publish_one() {
106109 return 0
107110 fi
108111
112+ local logf status
113+ logf=$( mktemp)
109114 set -x
115+ set +e
110116 cargo publish -p " $crate " \
111117 ${extra[@]+" ${extra[@]} " } \
112118 ${DRY_RUN[@]+" ${DRY_RUN[@]} " } \
113- ${ALLOW_DIRTY[@]+" ${ALLOW_DIRTY[@]} " }
119+ ${ALLOW_DIRTY[@]+" ${ALLOW_DIRTY[@]} " } 2>&1 | tee " $logf "
120+ status=${PIPESTATUS[0]}
121+ set -e
114122 set +x
123+
124+ if [[ $status -ne 0 ]]; then
125+ # Fallback skip: if the registry pre-check missed an existing version (API
126+ # lag, transient fetch failure), cargo still refuses with "already exists"
127+ # / "already uploaded". Treat that as a skip so the script stays re-runnable
128+ # instead of aborting under `set -e`.
129+ if grep -qiE " already (exists|uploaded)" " $logf " ; then
130+ echo " already on crates.io — skipping"
131+ rm -f " $logf "
132+ return 0
133+ fi
134+ rm -f " $logf "
135+ return " $status "
136+ fi
137+ rm -f " $logf "
115138}
116139
117140for spec in " ${PUBLISH_ORDER[@]} " ; do
0 commit comments