Skip to content

Subtree Split

Subtree Split #11

Workflow file for this run

name: Subtree Split
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag to split (e.g. v0.5.0)'
required: true
workflow_run:
workflows: ["Release"]
types: [completed]
permissions:
contents: read
jobs:
split-php:
name: Split PHP Wrapper
runs-on: ubuntu-latest
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.inputs.tag || github.event.workflow_run.head_branch }}
persist-credentials: false
- name: Get tag name
id: tag
run: |
TAG="${{ github.event.inputs.tag || '' }}"
if [ -z "$TAG" ]; then
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
fi
if [ -z "$TAG" ]; then
echo "No tag found, skipping"
exit 1
fi
echo "name=$TAG" >> "$GITHUB_OUTPUT"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Subtree split wrappers/php
run: git subtree split --prefix=wrappers/php -b php-split
- name: Download release binaries
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="${{ steps.tag.outputs.name }}"
git worktree add /tmp/split-work php-split
mkdir -p /tmp/split-work/lib/{x86_64-linux,aarch64-linux,x86_64-darwin,aarch64-darwin,x86_64-windows}
mkdir -p /tmp/archives
for platform in x86_64-linux aarch64-linux x86_64-darwin aarch64-darwin x86_64-windows; do
echo "Downloading anvildb-${platform}.tar.gz..."
gh release download "$TAG" \
--pattern "anvildb-${platform}.tar.gz" \
--dir /tmp/archives || echo "Warning: no binary for ${platform}"
if [ -f "/tmp/archives/anvildb-${platform}.tar.gz" ]; then
tar -xzf "/tmp/archives/anvildb-${platform}.tar.gz" -C /tmp/split-work/lib/
fi
done
- name: Verify token exists
run: |
if [ -z "$SPLIT_TOKEN" ]; then
echo "::error::SPLIT_TOKEN secret is empty!"
exit 1
fi
echo "SPLIT_TOKEN is set (length: ${#SPLIT_TOKEN})"
env:
SPLIT_TOKEN: ${{ secrets.SPLIT_TOKEN }}
- name: Commit binaries and push
env:
SPLIT_TOKEN: ${{ secrets.SPLIT_TOKEN }}
run: |
TAG="${{ steps.tag.outputs.name }}"
cd /tmp/split-work
git add lib/
git commit -m "chore: add precompiled binaries for ${TAG}" || echo "No binaries to commit"
git tag -f "$TAG"
git push https://x-access-token:${SPLIT_TOKEN}@github.com/kevinsillo/anvildb-php.git php-split:main --force
git push https://x-access-token:${SPLIT_TOKEN}@github.com/kevinsillo/anvildb-php.git "$TAG" --force
- name: Cleanup
run: |
git worktree remove /tmp/split-work --force || true
git branch -D php-split || true