Skip to content

Commit 4c26a4b

Browse files
author
Sentience Dev
committed
Merge pull request #37 from SentienceAPI/fix_release7
verbosity
2 parents 137436f + 90db3b3 commit 4c26a4b

File tree

1 file changed

+46
-17
lines changed

1 file changed

+46
-17
lines changed

.github/workflows/sync-extension.yml

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,18 @@ jobs:
4141
TAG="${{ github.event.client_payload.release_tag }}"
4242
else
4343
# Scheduled check - get latest release
44-
TAG=$(curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
45-
"https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest" | jq -r '.tag_name // empty')
44+
HTTP_CODE=$(curl -s -o latest_release.json -w "%{http_code}" \
45+
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
46+
"https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest")
47+
48+
if [ "$HTTP_CODE" != "200" ]; then
49+
echo "❌ Failed to fetch latest release. HTTP Code: $HTTP_CODE"
50+
cat latest_release.json
51+
exit 1
52+
fi
53+
54+
TAG=$(cat latest_release.json | jq -r '.tag_name // empty')
4655
47-
# Check if we already processed this tag
4856
if git ls-remote --exit-code --heads origin "sync-extension-$TAG"; then
4957
echo "Branch for $TAG already exists, skipping."
5058
echo "skip=true" >> $GITHUB_OUTPUT
@@ -73,41 +81,62 @@ jobs:
7381
echo "⬇️ Fetching release info for $TAG from $REPO..."
7482
7583
# Capture response to file for debugging
76-
curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
77-
"https://api.github.com/repos/$REPO/releases/tags/$TAG" > release.json
84+
HTTP_CODE=$(curl -s -w "%{http_code}" -o release.json \
85+
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
86+
"https://api.github.com/repos/$REPO/releases/tags/$TAG")
87+
88+
if [ "$HTTP_CODE" != "200" ]; then
89+
echo "❌ Failed to fetch release info. HTTP Code: $HTTP_CODE"
90+
echo "Response Body:"
91+
cat release.json
92+
exit 1
93+
fi
7894
7995
# Check if we got a valid release object
8096
if grep -q "Not Found" release.json; then
8197
echo "❌ Critical Error: Release tag $TAG not found in repo $REPO"
82-
cat release.json
8398
exit 1
8499
fi
85100
86101
# Robust extraction
87-
ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .browser_download_url')
102+
ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .url')
88103
89104
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
90105
echo "❌ Critical Error: extension-files.tar.gz not found in release assets!"
91106
echo "Available assets:"
92-
cat release.json | jq -r '.assets[].name' || echo "No assets found or invalid JSON"
107+
cat release.json | jq -r '.assets[].name'
93108
exit 1
94109
fi
95110
96-
# 2. Download the tarball
97-
echo "📦 Downloading tarball from $ASSET_URL..."
98-
curl -L -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
111+
# 2. Download the tarball using API URL
112+
echo "📦 Downloading tarball from asset API endpoint..."
113+
HTTP_CODE=$(curl -L -s -w "%{http_code}" -o extension.tar.gz \
114+
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
99115
-H "Accept: application/octet-stream" \
100-
"$ASSET_URL" -o extension.tar.gz
116+
"$ASSET_URL")
101117
102-
# 3. Extract it
118+
if [ "$HTTP_CODE" != "200" ] && [ "$HTTP_CODE" != "302" ]; then
119+
echo "❌ Failed to download asset. HTTP Code: $HTTP_CODE"
120+
if [ $(stat -c%s extension.tar.gz) -lt 1000 ]; then
121+
cat extension.tar.gz
122+
fi
123+
exit 1
124+
fi
125+
126+
# 3. Verify File Type
127+
FILE_TYPE=$(file -b --mime-type extension.tar.gz)
128+
echo "📄 Downloaded file type: $FILE_TYPE"
129+
130+
if [[ "$FILE_TYPE" != *"gzip"* ]] && [[ "$FILE_TYPE" != *"octet-stream"* ]]; then
131+
echo "❌ Error: Downloaded file is not a gzip archive. It is: $FILE_TYPE"
132+
exit 1
133+
fi
134+
135+
# 4. Extract
103136
echo "📂 Extracting..."
104137
tar -xzf extension.tar.gz
105138
rm extension.tar.gz
106139
107-
# 4. Verify extraction
108-
echo "✅ Extraction complete. Contents:"
109-
ls -la
110-
111140
if [ ! -f "manifest.json" ]; then
112141
echo "❌ Error: manifest.json missing after extraction"
113142
exit 1

0 commit comments

Comments
 (0)