Skip to content

prepare release

prepare release #272

name: Split monorepo - dev-master
on:
push:
# Thanks to this (otherwise superfluous) comment, this configuration
# will not be commented out (i.e. disabled) for the downstream repo
branches:
- main
env:
CHECKOUT_SUBMODULES: "recursive"
jobs:
provide_data:
name: Provide data
# see json juggling: https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#example-6
# see https://stackoverflow.com/a/62953566/1348344
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: ${{ env.CHECKOUT_SUBMODULES }}
# required for matrix of packages set
- uses: shivammathur/setup-php@v2
with:
php-version: 8.1
coverage: none
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: "ramsey/composer-install@v2"
# git diff to generate matrix with modified packages only
- uses: technote-space/get-diff-action@v6
with:
PATTERNS: layers/*/*/*/**
# get package json list - if filter is empty, don't launch any split
# Enhancement: produce the packages already, avoid potentially sending thousands of CLI args
# Steps to process string:
# 1. remove single quotes
# 2. Extract 4 first layers only (for package path) and get unique entries
# 3. Add --filter= in between entries
- id: output_data
run: |
quote=\'
clean_diff="$(echo "${{ env.GIT_DIFF }}" | sed -e s/$quote//g)"
packages_in_diff="$(echo $clean_diff | grep -E -o 'layers/[A-Za-z0-9_\-]*/[A-Za-z0-9_\-]*/[A-Za-z0-9_\-]*/' | sort -u)"
echo "[Packages in diff] $(echo $packages_in_diff | tr '\n' ' ')"
filter_arg="--filter=$(echo $packages_in_diff | sed -e 's/ / --filter=/g')"
exclude_package_paths="$(vendor/bin/monorepo-builder skip-monorepo-split-packages --config=config/monorepo-builder/skip-monorepo-split-packages.php)"
echo "[Excluded package paths] $(echo $exclude_package_paths)"
exclude_package_path_arg="--exclude-package-path=$(echo $exclude_package_paths | sed -e 's/ / --exclude-package-path=/g')"
echo "matrix=$(vendor/bin/monorepo-builder package-entries-json --config=config/monorepo-builder/package-entries-json.php $(echo $filter_arg) $(echo $exclude_package_path_arg))" >> $GITHUB_OUTPUT
echo "git_base_branch=$(vendor/bin/monorepo-builder env-var GIT_BASE_BRANCH --config=config/monorepo-builder/env-var.php)" >> $GITHUB_OUTPUT
echo "git_user_name=$(vendor/bin/monorepo-builder env-var GIT_USER_NAME --config=config/monorepo-builder/env-var.php)" >> $GITHUB_OUTPUT
echo "git_user_email=$(vendor/bin/monorepo-builder env-var GIT_USER_EMAIL --config=config/monorepo-builder/env-var.php)" >> $GITHUB_OUTPUT
# this step is needed, so the output gets to the next defined job
outputs:
matrix: ${{ steps.output_data.outputs.matrix }}
git_base_branch: ${{ steps.output_data.outputs.git_base_branch }}
git_user_name: ${{ steps.output_data.outputs.git_user_name }}
git_user_email: ${{ steps.output_data.outputs.git_user_email }}
split_monorepo:
needs: provide_data
if: needs.provide_data.outputs.matrix != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.provide_data.outputs.matrix)}}
name: Monorepo Split of ${{ matrix.package.name }} (${{ matrix.package.path }})
steps:
- uses: actions/checkout@v4
with:
submodules: ${{ env.CHECKOUT_SUBMODULES }}
# Uses an action in the root directory
- name: Split ${{ matrix.package.name }} (${{ matrix.package.path }})
if: "!startsWith(github.ref, 'refs/tags/')"
uses: symplify/monorepo-split-github-action@1.1
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
with:
branch: "${{ needs.provide_data.outputs.git_base_branch }}"
package-directory: '${{ matrix.package.path }}'
split-repository-organization: '${{ matrix.package.organization }}'
split-repository-name: '${{ matrix.package.name }}'
user-name: "${{ needs.provide_data.outputs.git_user_name }}"
user-email: "${{ needs.provide_data.outputs.git_user_email }}"