Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf

23 changes: 11 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ on:
jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Extract version from tag or input
id: version
run: |
Expand All @@ -39,32 +39,32 @@ jobs:
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"

- name: Update version in pyproject.toml
run: |
VERSION="${{ steps.version.outputs.version }}"
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml

- name: Update version in __init__.py
run: |
VERSION="${{ steps.version.outputs.version }}"
sed -i "s/^__version__ = \".*\"/__version__ = \"$VERSION\"/" sentience/__init__.py

- name: Build package
run: |
python -m build

- name: Check package
run: |
twine check dist/*

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*

- name: Create GitHub Release
if: github.event_name == 'workflow_dispatch'
uses: softprops/action-gh-release@v1
Expand All @@ -73,7 +73,7 @@ jobs:
name: Release v${{ steps.version.outputs.version }}
body: |
Release v${{ steps.version.outputs.version }} of sentience-python

## Installation
```bash
pip install sentience-python==${{ steps.version.outputs.version }}
Expand All @@ -82,4 +82,3 @@ jobs:
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

62 changes: 31 additions & 31 deletions .github/workflows/sync-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ jobs:
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout sdk-python
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Fetch all history for proper branching

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Determine release tag
id: release
run: |
Expand All @@ -45,58 +45,58 @@ jobs:
HTTP_CODE=$(curl -s -o latest_release.json -w "%{http_code}" \
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
"https://api.github.com/repos/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/latest")

if [ "$HTTP_CODE" != "200" ]; then
echo "❌ Failed to fetch latest release. HTTP Code: $HTTP_CODE"
cat latest_release.json
exit 1
fi

TAG=$(cat latest_release.json | jq -r '.tag_name // empty')

# Check if we already processed this tag
if git ls-remote --exit-code --heads origin "sync-extension-$TAG"; then
echo "Branch for $TAG already exists, skipping."
echo "skip=true" >> $GITHUB_OUTPUT
exit 0
fi
fi

if [ -z "$TAG" ]; then
echo "Could not determine release tag."
exit 1
fi

echo "Syncing tag: $TAG"
echo "tag=$TAG" >> $GITHUB_OUTPUT

- name: Download extension files
if: steps.release.outputs.skip != 'true'
run: |
TAG="${{ steps.release.outputs.tag }}"
REPO="${{ secrets.SENTIENCE_CHROME_REPO }}"

# Setup temp directory
mkdir -p extension-temp
cd extension-temp

echo "⬇️ Fetching release info for $TAG from $REPO..."

# 1. Get Release Info
HTTP_CODE=$(curl -s -w "%{http_code}" -o release.json \
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
"https://api.github.com/repos/$REPO/releases/tags/$TAG")

if [ "$HTTP_CODE" != "200" ]; then
echo "❌ Failed to fetch release info. HTTP Code: $HTTP_CODE"
echo "Response Body:"
cat release.json
exit 1
fi

# Check for asset URL
ASSET_URL=$(cat release.json | jq -r '.assets[]? | select(.name == "extension-files.tar.gz") | .url')

if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" == "null" ]; then
echo "❌ Critical Error: extension-files.tar.gz not found in release assets!"
echo "Available assets:"
Expand All @@ -107,7 +107,7 @@ jobs:
echo "📦 Downloading tarball from asset API endpoint..."
# NOTE: For private repos, we must use the API URL (.url) with Accept: application/octet-stream header
# Using .browser_download_url often redirects to S3 which breaks auth headers

HTTP_CODE=$(curl -L -s -w "%{http_code}" -o extension.tar.gz \
-H "Authorization: token ${{ secrets.SENTIENCE_CHROME_TOKEN }}" \
-H "Accept: application/octet-stream" \
Expand All @@ -125,7 +125,7 @@ jobs:
# 3. Verify File Type before extracting
FILE_TYPE=$(file -b --mime-type extension.tar.gz)
echo "📄 Downloaded file type: $FILE_TYPE"

if [[ "$FILE_TYPE" != *"gzip"* ]] && [[ "$FILE_TYPE" != *"octet-stream"* ]]; then
echo "❌ Error: Downloaded file is not a gzip archive. It is: $FILE_TYPE"
echo "First 100 bytes:"
Expand All @@ -137,50 +137,50 @@ jobs:
echo "📂 Extracting..."
tar -xzf extension.tar.gz
rm extension.tar.gz

if [ ! -f "manifest.json" ]; then
echo "❌ Error: manifest.json missing after extraction"
exit 1
fi

- name: Update extension files
if: steps.release.outputs.skip != 'true'
run: |
# Target directory in sdk-python (inside the package source)
TARGET_DIR="sentience/extension"

# Ensure target directory exists and is clean
rm -rf "$TARGET_DIR"
mkdir -p "$TARGET_DIR"

# Copy files from temp directory
cp -r extension-temp/* "$TARGET_DIR/"

# Verify copy
if [ ! -f "$TARGET_DIR/manifest.json" ]; then
echo "❌ Failed to copy manifest.json to $TARGET_DIR"
exit 1
fi

# Cleanup
rm -rf extension-temp

echo "✅ Extension files updated in $TARGET_DIR"
ls -la "$TARGET_DIR"

- name: Check for changes
if: steps.release.outputs.skip != 'true'
id: changes
run: |
git add sentience/extension/

if git diff --staged --quiet; then
echo "No changes detected."
echo "changed=false" >> $GITHUB_OUTPUT
else
echo "Changes detected."
echo "changed=true" >> $GITHUB_OUTPUT

# Show staged files
echo "📊 Staged file sizes:"
git diff --staged --name-only | while read file; do
Expand All @@ -190,7 +190,7 @@ jobs:
fi
done
fi

- name: Create Pull Request
if: steps.release.outputs.skip != 'true' && steps.changes.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v5
Expand All @@ -200,14 +200,14 @@ jobs:
title: "Sync Extension: ${{ steps.release.outputs.tag }}"
body: |
This PR syncs extension files from sentience-chrome release ${{ steps.release.outputs.tag }}.

**Files updated:**
- Extension manifest and scripts
- WASM binary and bindings

**Source:** [sentience-chrome release ${{ steps.release.outputs.tag }}](https://github.com/${{ secrets.SENTIENCE_CHROME_REPO }}/releases/tag/${{ steps.release.outputs.tag }})
branch: sync-extension-${{ steps.release.outputs.tag }}
delete-branch: true
labels: |
automated
extension-sync
extension-sync
13 changes: 6 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.11']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Playwright browsers
run: |
python -m pip install --upgrade pip
pip install playwright
playwright install chromium

- name: Install dependencies
run: |
pip install -e ".[dev]"

- name: Build extension (if needed)
if: runner.os != 'Windows'
shell: bash
Expand All @@ -42,10 +42,9 @@ jobs:
else
echo "Extension directory not found, skipping build"
fi

- name: Run tests
run: |
pytest tests/ -v
env:
CI: true

Loading