Update version constraints for development #6
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: Packages Split | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - '*' | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Tag to split (leave empty for branch-only split)' | |
| required: false | |
| type: string | |
| jobs: | |
| packages_split: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| package: | |
| - local_path: 'src/contracts' | |
| split_repository: 'PHP-CA-contracts' | |
| tag_suffix: '' | |
| - local_path: 'src/library' | |
| split_repository: 'PHP-CA-library' | |
| tag_suffix: '' | |
| - local_path: 'src/config-manager' | |
| split_repository: 'PHP-CA-config-manager' | |
| tag_suffix: '' | |
| - local_path: 'src/cli' | |
| split_repository: 'CLI-PHP-CA' | |
| tag_suffix: '-src' | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ secrets.SPLIT_APP_ID }} | |
| private-key: ${{ secrets.SPLIT_APP_PRIVATE_KEY }} | |
| owner: kduma-OSS-splits | |
| - name: Initialize split repo if empty | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: | | |
| REPO="kduma-OSS-splits/${{ matrix.package.split_repository }}" | |
| TMPDIR=$(mktemp -d) | |
| git clone "https://x-access-token:${GH_TOKEN}@github.com/$REPO.git" "$TMPDIR" 2>&1 || true | |
| if ! git -C "$TMPDIR" rev-parse HEAD >/dev/null 2>&1; then | |
| echo "Repository $REPO is empty, initializing with empty commit on master..." | |
| git -C "$TMPDIR" checkout -b master | |
| git -C "$TMPDIR" config user.name "github-actions[bot]" | |
| git -C "$TMPDIR" config user.email "github-actions[bot]@users.noreply.github.com" | |
| git -C "$TMPDIR" commit --allow-empty -m "Initial commit" | |
| git -C "$TMPDIR" push origin master | |
| echo "Initialized $REPO with master branch" | |
| else | |
| echo "Repository $REPO already has commits, skipping initialization" | |
| fi | |
| rm -rf "$TMPDIR" | |
| - name: Resolve tag | |
| id: resolve-tag | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ inputs.tag }}" ]]; then | |
| SOURCE_TAG="${{ inputs.tag }}" | |
| elif [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| SOURCE_TAG="${{ github.ref_name }}" | |
| else | |
| SOURCE_TAG="" | |
| fi | |
| echo "source_tag=${SOURCE_TAG}" >> "$GITHUB_OUTPUT" | |
| if [[ -n "$SOURCE_TAG" ]]; then | |
| echo "split_tag=${SOURCE_TAG}${{ matrix.package.tag_suffix }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "split_tag=" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Checkout tag | |
| if: steps.resolve-tag.outputs.source_tag != '' | |
| run: git checkout "refs/tags/${{ steps.resolve-tag.outputs.source_tag }}" | |
| - name: Split (no tag) | |
| if: steps.resolve-tag.outputs.split_tag == '' | |
| uses: danharrin/monorepo-split-github-action@v2.4.0 | |
| env: | |
| PAT: x-access-token:${{ steps.app-token.outputs.token }} | |
| with: | |
| package_directory: ${{ matrix.package.local_path }} | |
| repository_organization: 'kduma-OSS-splits' | |
| repository_name: ${{ matrix.package.split_repository }} | |
| branch: 'master' | |
| user_name: 'github-actions[bot]' | |
| user_email: 'github-actions[bot]@users.noreply.github.com' | |
| - name: Split (with tag) | |
| if: steps.resolve-tag.outputs.split_tag != '' | |
| uses: danharrin/monorepo-split-github-action@v2.4.0 | |
| env: | |
| PAT: x-access-token:${{ steps.app-token.outputs.token }} | |
| with: | |
| tag: ${{ steps.resolve-tag.outputs.split_tag }} | |
| package_directory: ${{ matrix.package.local_path }} | |
| repository_organization: 'kduma-OSS-splits' | |
| repository_name: ${{ matrix.package.split_repository }} | |
| branch: 'master' | |
| user_name: 'github-actions[bot]' | |
| user_email: 'github-actions[bot]@users.noreply.github.com' |