Skip to content
Open
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
44 changes: 10 additions & 34 deletions .github/workflows/subsplit-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ name: "Sub-split packages"

on:
push:
branches: [main]
branches: ["*"]
tags: ["v*"]
workflow_dispatch:

env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}

jobs:
get_packages:
name: Get packages
Expand All @@ -24,10 +21,11 @@ jobs:

- name: Get packages
id: get_json
run: echo "::set-output name=json::$(bin/get-packages)"
run: echo "json=$(bin/get-packages)" >> $GITHUB_OUTPUT

- name: Output packages
run: echo "${{ steps.get_json.outputs.json }}"

outputs:
matrix: ${{ steps.get_json.outputs.json }}

Expand All @@ -41,34 +39,12 @@ jobs:
package: ${{ fromJson(needs.get_packages.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
# no tag
- if: "!startsWith(github.ref, 'refs/tags/')"
uses: "symplify/monorepo-split-github-action@v2.3.0"
with:
# ↓ split "packages/console" directory
package_directory: "${{ matrix.package.directory }}"

# ↓ into https://github.com/tempestphp/tempest-console repository
repository_organization: "${{ matrix.package.organization }}"
repository_name: "${{ matrix.package.repository }}"

# ↓ the user signed under the split commit
user_name: "aidan-casey"
user_email: "aidan@caseyhouse.net"

# with tag
- if: "startsWith(github.ref, 'refs/tags/')"
uses: "symplify/monorepo-split-github-action@v2.3.0"
with:
tag: ${GITHUB_REF#refs/tags/}

# ↓ split "packages/console" directory
package_directory: "${{ matrix.package.directory }}"

# ↓ into https://github.com/tempestphp/tempest-console repository
repository_organization: "${{ matrix.package.organization }}"
repository_name: "${{ matrix.package.repository }}"
- name: Set up git-filter-repo
run: pip install git-filter-repo

# ↓ the user signed under the split commit
user_name: "aidan-casey"
user_email: "aidan@caseyhouse.net"
- name: Split Package
env:
SUBSPLIT_TOKEN: ${{ secrets.ACCESS_TOKEN }}
run:
./bin/split "${{ matrix.package.name }}"
28 changes: 28 additions & 0 deletions bin/split
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

PACKAGE_NAME=$1
SUBSPLIT_DIR="${PACKAGE_NAME}_subsplit"

# Clone our Tempest repository and jump into it.
git clone https://github.com/tempestphp/tempest-framework "$SUBSPLIT_DIR"
cd "$SUBSPLIT_DIR"

# Get the current default branch of the Tempest repo.
DEFAULT_BRANCH=$(git branch --show-current)

# Filter the history down to only the one package.
git filter-repo --subdirectory-filter "packages/${PACKAGE_NAME}"

# Setup our remote repository we are splitting to.
git remote add origin "https://x-access-token:${SUBSPLIT_TOKEN}@github.com/tempestphp/tempest-${PACKAGE_NAME}.git"
git branch -m "$DEFAULT_BRANCH"

# Push all branches + history to the repo.
git push --force --all origin

# Push all releases / tags to the repo.
git push --force --tags origin

# Cleanup
cd ../
rm -rf "${SUBSPLIT_DIR}"