ci: add permissions: contents: write for apt-repo push #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Android ARM64 Wheels | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| repo: | |
| description: 'GitHub repo (org/name)' | |
| required: false | |
| default: 'crate-py/rpds' | |
| type: string | |
| push: | |
| paths: | |
| - '.github/workflows/build-android-wheels.yml' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| python-version: ['3.13'] | |
| steps: | |
| - name: Checkout ${{ inputs.repo || 'crate-py/rpds' }} | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ inputs.repo || 'crate-py/rpds' }} | |
| path: src | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install system deps | |
| run: sudo apt-get update -qq && sudo apt-get install -y -qq lld dpkg-dev unzip | |
| - name: Build wheel (cross-compile aarch64-linux-android) | |
| uses: PyO3/maturin-action@v1 | |
| env: | |
| CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER: ld.lld | |
| with: | |
| maturin-version: latest | |
| rust-toolchain: stable | |
| target: aarch64-linux-android | |
| args: > | |
| --manifest-path src/Cargo.toml | |
| --release | |
| --interpreter python${{ matrix.python-version }} | |
| --out dist | |
| - name: Build .deb + push apt-repo | |
| run: | | |
| set -e | |
| WHEEL=$(ls dist/*.whl | head -1) | |
| WHEEL_BASE=$(basename "$WHEEL" .whl) | |
| echo "WHEEL: $WHEEL_BASE" | |
| # Parse wheel name: rpds_py-2026.6.3-cp314-cp314-android_24_arm64_v8a.whl | |
| PKG="python-$(echo "$WHEEL_BASE" | cut -d- -f1 | tr '_' '-')" | |
| VER=$(echo "$WHEEL_BASE" | cut -d- -f2) | |
| echo "PKG=$PKG VER=$VER" | |
| # Build .deb | |
| TMP=$(mktemp -d) | |
| DEB_ROOT="$TMP/deb" | |
| SITE="$DEB_ROOT/data/data/com.termux/files/usr/lib/python3.14/site-packages" | |
| mkdir -p "$SITE" "$DEB_ROOT/DEBIAN" | |
| unzip -q "$WHEEL" -d "$SITE" | |
| SIZE=$(du -sk "$DEB_ROOT/data" 2>/dev/null | cut -f1) | |
| printf 'Package: %s\nVersion: %s\nArchitecture: aarch64\nMaintainer: ClaudeCode-Termux\nInstalled-Size: %s\nDescription: %s (auto-built from %s)\nDepends: python\n' \ | |
| "$PKG" "$VER" "${SIZE:-100}" "$PKG" "${{ inputs.repo || 'crate-py/rpds' }}" \ | |
| > "$DEB_ROOT/DEBIAN/control" | |
| cat "$DEB_ROOT/DEBIAN/control" | |
| DEB_FILE="dist/${PKG}_${VER}_aarch64.deb" | |
| dpkg-deb --root-owner-group -Zxz -b "$DEB_ROOT" "$DEB_FILE" | |
| ls -lh "$DEB_FILE" | |
| # Push to apt-repo branch | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "actions@github.com" | |
| REPO_URL="https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" | |
| if ! git clone --depth 1 -b apt-repo "$REPO_URL" apt_repo 2>/dev/null; then | |
| git clone --depth 1 "$REPO_URL" apt_repo | |
| cd apt_repo | |
| git checkout --orphan apt-repo | |
| git rm -rf . | |
| git commit --allow-empty -m "init apt-repo" | |
| cd .. | |
| fi | |
| cd apt_repo | |
| git checkout apt-repo | |
| mkdir -p pool | |
| cp "../$DEB_FILE" pool/ | |
| cd pool | |
| dpkg-scanpackages --multiversion . > ../Packages | |
| cd .. | |
| gzip -9c Packages > Packages.gz | |
| echo "=== pool/ ===" | |
| ls -lh pool/ | |
| echo "=== Packages (first 10 lines) ===" | |
| head -10 Packages | |
| git add -A | |
| if ! git diff --staged --quiet; then | |
| git commit -m "➕ $PKG v$VER" | |
| git push origin apt-repo | |
| echo "✅ Pushed to apt-repo" | |
| else | |
| echo "⏭ No changes (already exists)" | |
| fi | |
| - name: Upload artifact (backup) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: rpds-py-aarch64-android | |
| path: dist/*.whl | |
| retention-days: 7 |