Skip to content

Commit a45610e

Browse files
DOsingaDouwe Osinga
andauthored
gh fall back (#7695)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
1 parent b4546f6 commit a45610e

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

scripts/pre-release.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,30 @@ if [[ -z "$DOWNLOAD_URL" ]]; then
3434
fi
3535
echo "Downloading $DOWNLOAD_URL"
3636

37-
# Download and extract (nightly.link double-zips)
38-
curl -sL -o "$TMPDIR/goose.zip" "$DOWNLOAD_URL"
37+
# Download artifact — try nightly.link first, fall back to gh CLI
38+
if ! curl -fSL --connect-timeout 10 -o "$TMPDIR/goose.zip" "$DOWNLOAD_URL" 2>/dev/null; then
39+
echo "nightly.link unavailable, falling back to GitHub API..."
40+
RUN_ID=$(echo "$DOWNLOAD_URL" | grep -oE 'actions/runs/[0-9]+' | cut -d/ -f3)
41+
ARTIFACT_NAME=$(echo "$DOWNLOAD_URL" | sed 's/\.zip$//' | xargs basename)
42+
ARTIFACT_ID=$(gh api "repos/$REPO/actions/runs/$RUN_ID/artifacts" \
43+
--jq ".artifacts[] | select(.name==\"$ARTIFACT_NAME\") | .id")
44+
if [[ -z "$ARTIFACT_ID" ]]; then
45+
echo "Could not find artifact '$ARTIFACT_NAME' for run $RUN_ID"
46+
exit 1
47+
fi
48+
gh api "repos/$REPO/actions/artifacts/$ARTIFACT_ID/zip" > "$TMPDIR/goose.zip"
49+
fi
50+
echo "Done."
51+
3952
unzip -o -q "$TMPDIR/goose.zip" -d "$TMPDIR/extracted"
4053

4154
INNER_ZIP=$(find "$TMPDIR/extracted" -name "*.zip" | head -1)
4255
if [[ -n "$INNER_ZIP" ]]; then
4356
unzip -o -q "$INNER_ZIP" -d "$TMPDIR/extracted"
4457
fi
4558

59+
echo "unzipped"
60+
4661
APP=$(find "$TMPDIR/extracted" -name "*.app" -maxdepth 2 | head -1)
4762
if [[ -z "$APP" ]]; then
4863
echo "No .app found in archive."

0 commit comments

Comments
 (0)