@@ -19,19 +19,19 @@ jobs:
1919 permissions :
2020 contents : write
2121 pull-requests : write
22-
22+
2323 steps :
2424 - name : Checkout sdk-python
2525 uses : actions/checkout@v4
2626 with :
2727 token : ${{ secrets.GITHUB_TOKEN }}
2828 fetch-depth : 0 # Fetch all history for proper branching
29-
29+
3030 - name : Set up Python
3131 uses : actions/setup-python@v5
3232 with :
3333 python-version : ' 3.11'
34-
34+
3535 - name : Determine release tag
3636 id : release
3737 run : |
@@ -45,58 +45,58 @@ jobs:
4545 HTTP_CODE=$(curl -s -o latest_release.json -w "%{http_code}" \
4646 -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
4747 "https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest")
48-
48+
4949 if [ "$HTTP_CODE" != "200" ]; then
5050 echo "❌ Failed to fetch latest release. HTTP Code: $HTTP_CODE"
5151 cat latest_release.json
5252 exit 1
5353 fi
54-
54+
5555 TAG=$(cat latest_release.json | jq -r '.tag_name // empty')
56-
56+
5757 # Check if we already processed this tag
5858 if git ls-remote --exit-code --heads origin "sync-extension-$TAG"; then
5959 echo "Branch for $TAG already exists, skipping."
6060 echo "skip=true" >> $GITHUB_OUTPUT
6161 exit 0
6262 fi
6363 fi
64-
64+
6565 if [ -z "$TAG" ]; then
6666 echo "Could not determine release tag."
6767 exit 1
6868 fi
69-
69+
7070 echo "Syncing tag: $TAG"
7171 echo "tag=$TAG" >> $GITHUB_OUTPUT
72-
72+
7373 - name : Download extension files
7474 if : steps.release.outputs.skip != 'true'
7575 run : |
7676 TAG="${{ steps.release.outputs.tag }}"
7777 REPO="${{ secrets.SENTIENCE_CHROME_REPO }}"
78-
78+
7979 # Setup temp directory
8080 mkdir -p extension-temp
8181 cd extension-temp
82-
82+
8383 echo "⬇️ Fetching release info for $TAG from $REPO..."
84-
84+
8585 # 1. Get Release Info
8686 HTTP_CODE=$(curl -s -w "%{http_code}" -o release.json \
8787 -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
8888 "https://api.github.com/repos/$REPO/releases/tags/$TAG")
89-
89+
9090 if [ "$HTTP_CODE" != "200" ]; then
9191 echo "❌ Failed to fetch release info. HTTP Code: $HTTP_CODE"
9292 echo "Response Body:"
9393 cat release.json
9494 exit 1
9595 fi
96-
96+
9797 # Check for asset URL
9898 ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .url')
99-
99+
100100 if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
101101 echo "❌ Critical Error: extension-files.tar.gz not found in release assets!"
102102 echo "Available assets:"
@@ -107,7 +107,7 @@ jobs:
107107 echo "📦 Downloading tarball from asset API endpoint..."
108108 # NOTE: For private repos, we must use the API URL (.url) with Accept: application/octet-stream header
109109 # Using .browser_download_url often redirects to S3 which breaks auth headers
110-
110+
111111 HTTP_CODE=$(curl -L -s -w "%{http_code}" -o extension.tar.gz \
112112 -H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
113113 -H "Accept: application/octet-stream" \
@@ -125,7 +125,7 @@ jobs:
125125 # 3. Verify File Type before extracting
126126 FILE_TYPE=$(file -b --mime-type extension.tar.gz)
127127 echo "📄 Downloaded file type: $FILE_TYPE"
128-
128+
129129 if [[ "$FILE_TYPE" != *"gzip"* ]] && [[ "$FILE_TYPE" != *"octet-stream"* ]]; then
130130 echo "❌ Error: Downloaded file is not a gzip archive. It is: $FILE_TYPE"
131131 echo "First 100 bytes:"
@@ -137,50 +137,50 @@ jobs:
137137 echo "📂 Extracting..."
138138 tar -xzf extension.tar.gz
139139 rm extension.tar.gz
140-
140+
141141 if [ ! -f "manifest.json" ]; then
142142 echo "❌ Error: manifest.json missing after extraction"
143143 exit 1
144144 fi
145-
145+
146146 - name : Update extension files
147147 if : steps.release.outputs.skip != 'true'
148148 run : |
149149 # Target directory in sdk-python (inside the package source)
150150 TARGET_DIR="sentience/extension"
151-
151+
152152 # Ensure target directory exists and is clean
153153 rm -rf "$TARGET_DIR"
154154 mkdir -p "$TARGET_DIR"
155-
155+
156156 # Copy files from temp directory
157157 cp -r extension-temp/* "$TARGET_DIR/"
158-
158+
159159 # Verify copy
160160 if [ ! -f "$TARGET_DIR/manifest.json" ]; then
161161 echo "❌ Failed to copy manifest.json to $TARGET_DIR"
162162 exit 1
163163 fi
164-
164+
165165 # Cleanup
166166 rm -rf extension-temp
167-
167+
168168 echo "✅ Extension files updated in $TARGET_DIR"
169169 ls -la "$TARGET_DIR"
170-
170+
171171 - name : Check for changes
172172 if : steps.release.outputs.skip != 'true'
173173 id : changes
174174 run : |
175175 git add sentience/extension/
176-
176+
177177 if git diff --staged --quiet; then
178178 echo "No changes detected."
179179 echo "changed=false" >> $GITHUB_OUTPUT
180180 else
181181 echo "Changes detected."
182182 echo "changed=true" >> $GITHUB_OUTPUT
183-
183+
184184 # Show staged files
185185 echo "📊 Staged file sizes:"
186186 git diff --staged --name-only | while read file; do
@@ -190,7 +190,7 @@ jobs:
190190 fi
191191 done
192192 fi
193-
193+
194194 - name : Create Pull Request
195195 if : steps.release.outputs.skip != 'true' && steps.changes.outputs.changed == 'true'
196196 uses : peter-evans/create-pull-request@v5
@@ -200,14 +200,14 @@ jobs:
200200 title : " Sync Extension: ${{ steps.release.outputs.tag }}"
201201 body : |
202202 This PR syncs extension files from sentience-chrome release ${{ steps.release.outputs.tag }}.
203-
203+
204204 **Files updated:**
205205 - Extension manifest and scripts
206206 - WASM binary and bindings
207-
207+
208208 **Source:** [sentience-chrome release ${{ steps.release.outputs.tag }}](https://github.com/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/tag/${{ steps.release.outputs.tag }})
209209 branch : sync-extension-${{ steps.release.outputs.tag }}
210210 delete-branch : true
211211 labels : |
212212 automated
213- extension-sync
213+ extension-sync
0 commit comments