4242 else
4343 # Scheduled check - get latest release
4444 TAG=$(curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
45- "[ https://api.github.com/repos/$](https://api.github.com/repos/$) {{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest" | jq -r '.tag_name // empty')
45+ "https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest" | jq -r '.tag_name // empty')
4646
4747 # Check if we already processed this tag
4848 if git ls-remote --exit-code --heads origin "sync-extension-$TAG"; then
@@ -70,28 +70,48 @@ jobs:
7070 mkdir -p extension-temp
7171 cd extension-temp
7272
73- echo "⬇️ Fetching release assets for $TAG from $REPO..."
73+ echo "⬇️ Fetching release info for $TAG from $REPO..."
7474
75- ASSET_URL=$(curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
76- "[https://api.github.com/repos/$REPO/releases/tags/$TAG](https://api.github.com/repos/$REPO/releases/tags/$TAG)" | \
77- jq -r '.assets[] | select(.name == "extension-files.tar.gz") | .browser_download_url')
75+ # Capture response to file for debugging
76+ # Use -f to fail on HTTP errors (404/403) so we don't parse error HTML
77+ curl -s -f -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
78+ "https://api.github.com/repos/$REPO/releases/tags/$TAG" > release.json || {
79+ echo "❌ Failed to fetch release info. Response:"
80+ cat release.json || echo "(No response body)"
81+ exit 1
82+ }
83+
84+ # Check if we got a valid release object (sanity check)
85+ if grep -q "Not Found" release.json; then
86+ echo "❌ Critical Error: Release tag $TAG not found in repo $REPO"
87+ exit 1
88+ fi
89+
90+ # Robust extraction with safe navigation operator
91+ ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .browser_download_url')
7892
7993 if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
8094 echo "❌ Critical Error: extension-files.tar.gz not found in release assets!"
81- curl -s -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
82- "[https://api.github.com/repos/$REPO/releases/tags/$TAG](https://api.github.com/repos/$REPO/releases/tags/$TAG)" | jq -r '.assets[].name'
95+ echo "Available assets:"
96+ cat release.json | jq -r '.assets[].name' || echo "No assets found or invalid JSON"
8397 exit 1
8498 fi
8599
100+ # 2. Download the tarball
86101 echo "📦 Downloading tarball from $ASSET_URL..."
87102 curl -L -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
88103 -H "Accept: application/octet-stream" \
89104 "$ASSET_URL" -o extension.tar.gz
90105
106+ # 3. Extract it
91107 echo "📂 Extracting..."
92108 tar -xzf extension.tar.gz
93109 rm extension.tar.gz
94110
111+ # 4. Verify extraction
112+ echo "✅ Extraction complete. Contents:"
113+ ls -la
114+
95115 if [ ! -f "manifest.json" ]; then
96116 echo "❌ Error: manifest.json missing after extraction"
97117 exit 1
@@ -101,11 +121,11 @@ jobs:
101121 if : steps.release.outputs.skip != 'true'
102122 run : |
103123 # Target directory in sdk-python (inside the package source)
104- # Assuming structure: sdk-python/sentience/extension
105124 TARGET_DIR="sentience/extension"
106125
107126 # Ensure target directory exists and is clean
108127 # Note: We preserve the directory structure, just update contents
128+ rm -rf "$TARGET_DIR"
109129 mkdir -p "$TARGET_DIR"
110130
111131 # Copy files from temp directory
@@ -165,4 +185,4 @@ jobs:
165185 delete-branch : true
166186 labels : |
167187 automated
168- extension-sync
188+ extension-sync
0 commit comments