Closed dscho closed 1 year ago
I assume we'd want to quit the workflow pretty early (as opposed to building the package and then only skipping deployment), right?
I assume we'd want to quit the workflow pretty early (as opposed to building the package and then only skipping deployment), right?
That's my thinking, too. We'd most likely want to essentially perform a HEAD
call to the corresponding URL, and if it comes back as 404 we can continue, otherwise we should immediately fail.
Something along these lines:
case "$PACKAGE_TO_BUILD" in
mingw-w64-*)
if test -z "$ARCHITECTURE"
then
ARCHITECTURE=x86_64
ARCHITECTURE2=i686
fi
SUFFIX=-any
;;
*)
SUFFIX=-$ARCHITECTURE
;;
esac
case "$ARCHITECTURE" in
x86_64) DIR=x86-64;;
*) DIR=$ARCHITECTURE;;
esac
FILENAME="$(. PKGBUILD && echo "$pkgname-$pkgver-$pkgrel$SUFFIX.pkg.tar.xz")"
if curl -fI https://wingit.blob.core.windows.net/$DIR/$FILENAME
then
echo "$FILENAME" was already built and deployed!" >&2
exit 1
fi
if test -n "$ARCHITECTURE2"
then
FILENAME2="$(echo "$FILENAME" | sed "s/x86.64/$ARCHITECTURE2/g")"
if curl -fI https://wingit.blob.core.windows.net/$DIR/$FILENAME
then
echo "$FILENAME" was already built and deployed!" >&2
exit 1
fi
fi
Probably not as-is, there's a great chance that this can be written in a much neater way, e.g. using shell functions. And it should probably really look at the HTTP exit status and verify that it is 404 (instead of any transient error) rather than relying on curl
's exit code (which would always be 22 with -f
if anything fails).
I mistakenly re-deployed an existing
mingw-w64-curl
version yesterday. Which overwrote those packages. With a version that behaves differently. Let's refuse to do this also in thebuild-and-deploy
workflow in addition to doing it in the GitForWindowsHelper GitHub App.