2020-12-25 23:17:31 +00:00
# builds the content of https://github.com/rectorphp/rector-prefixed
2021-03-23 00:08:23 +00:00
# inspiration from https://github.com/phpstan/phpstan-src/blob/master/.github/workflows/phar.yml
2020-12-25 23:17:31 +00:00
name : Build Scoped Rector
on :
push :
2020-12-27 21:14:39 +00:00
branches :
2021-03-11 20:29:21 +00:00
- main
2021-03-18 01:48:44 +00:00
tags :
2021-02-11 12:37:40 +00:00
- '*'
2021-03-18 22:03:54 +00:00
env :
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
COMPOSER_ROOT_VERSION : "dev-main"
2020-12-25 23:17:31 +00:00
jobs :
build_scoped_rector :
runs-on : ubuntu-latest
steps :
-
uses : actions/checkout@v2
2021-03-18 01:48:44 +00:00
with :
fetch-depth : 0
2020-12-25 23:17:31 +00:00
-
uses : shivammathur/setup-php@v2
with :
2021-03-13 20:41:14 +00:00
php-version : 7.3
2021-03-18 01:48:44 +00:00
coverage : none
2020-12-25 23:17:31 +00:00
# fixes https://github.com/rectorphp/rector/pull/4559/checks?check_run_id=1359814403, see https://github.com/shivammathur/setup-php#composer-github-oauth
env :
COMPOSER_TOKEN : ${{ secrets.ACCESS_TOKEN }}
2021-03-18 01:48:44 +00:00
# install only prod dependencies - do not use ramsey, it uses cache including "dev", we want to avoid it here
- run : composer install --no-dev --ansi
# 1. copy files to $NESTED_DIRECTORY directory Exclude the scoped/nested directories to prevent rsync from copying in a loop
- run : rsync --exclude rector-build -av * rector-build --quiet
- run : rm -rf rector-build/packages-tests rector-build/rules-tests rector-build/tests
# 2. downgrade rector
- run : sh build/downgrade-rector.sh rector-build
# 3. prefix classes
- run : sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
# 4. lint the code for PHP 7.1 - this must happen here, as setup-php allows only one PHP version switch: https://github.com/shivammathur/setup-php/issues/434
-
uses : shivammathur/setup-php@v2
with :
php-version : 7.1
coverage : none
- run : composer create-project php-parallel-lint/php-parallel-lint php-parallel-lint --ansi
2021-03-19 00:44:42 +00:00
- run : php-parallel-lint/parallel-lint rector-prefixed-downgraded --exclude rector-prefixed-downgraded/stubs --exclude rector-prefixed-downgraded/vendor/symfony/polyfill-intl-grapheme/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill-mbstring/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/error-handler/Resources --exclude rector-prefixed-downgraded/vendor/symfony/http-kernel/Resources --exclude rector-prefixed-downgraded/vendor/symfony/polyfill/src/Mbstring/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill/src/Apcu/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill/src/Iconv/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill/src/Intl/Idn/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill/src/Intl/Normalizer/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/symfony/polyfill/src/Intl/Grapheme/bootstrap80.php --exclude rector-prefixed-downgraded/vendor/rector/rector-nette/tests
2021-03-18 01:48:44 +00:00
# 5. copy repository meta files
- run : cp -R build/target-repository/. rector-prefixed-downgraded
2021-03-22 22:17:58 +00:00
# 6. clone remote repository, so we can push it
2021-03-22 21:29:08 +00:00
-
2021-03-22 22:17:58 +00:00
uses : "actions/checkout@v2"
with :
2021-03-22 22:28:54 +00:00
repository : rectorphp/rector-prefixed
2021-03-22 22:17:58 +00:00
path : remote-repository
2021-03-22 22:18:17 +00:00
token : ${{ secrets.ACCESS_TOKEN }}
2021-03-22 22:17:58 +00:00
2021-03-23 22:50:36 +00:00
# remove remote files, to avoid piling up dead code in remote repository
2021-03-23 22:59:19 +00:00
- run : rm -rf remote-repository/config remote-repository/src remote-repository/rules remote-repository/packages remote-repository/vendor
2021-03-23 22:50:36 +00:00
- run : cp -a rector-prefixed-downgraded/. remote-repository
2021-03-22 22:17:58 +00:00
# 7. setup git
-
working-directory : remote-repository
2021-03-22 21:29:08 +00:00
run : |
git config user.email "tomas.vot@gmail.com"
git config user.name "Tomas Votruba"
2021-03-23 00:08:23 +00:00
# commit metadata
-
name : "Get Git log"
id : git-log
run : echo ::set-output name=log::$(git log ${{ github.event.before }}..${{ github.event.after }} --reverse --pretty='%H %s' | sed -e 's/^/https:\/\/github.com\/rectorphp\/rector\/commit\//')
2021-03-22 22:17:58 +00:00
# 8.A publish it to remote repository without tag
2021-03-18 01:48:44 +00:00
-
2021-03-22 21:18:33 +00:00
name : "Commit Prefixed - main"
2021-03-22 22:17:58 +00:00
working-directory : remote-repository
2021-03-18 01:48:44 +00:00
if : "!startsWith(github.ref, 'refs/tags/')"
2021-03-22 20:47:21 +00:00
run : |
2021-03-22 21:37:19 +00:00
git add --all
2021-03-23 00:08:23 +00:00
git commit -m "Updated Rector to commit ${{ github.event.after }}" -m "${{ steps.git-log.outputs.log }}"
2021-03-22 21:18:33 +00:00
git push --quiet origin main
2021-03-22 20:47:21 +00:00
2021-03-22 22:17:58 +00:00
# 8.B publish it to remote repository with tag
2020-12-25 23:17:31 +00:00
-
2021-03-22 21:18:33 +00:00
name : "Commit Prefixed - tag"
2021-03-22 22:17:58 +00:00
working-directory : remote-repository
2021-03-18 01:48:44 +00:00
if : "startsWith(github.ref, 'refs/tags/')"
2021-03-22 21:18:33 +00:00
run : |
2021-03-22 21:37:19 +00:00
git add --all
2021-03-23 00:08:23 +00:00
git commit -m "Rector ${GITHUB_REF#refs/tags/}" -m "${{ steps.git-log.outputs.log }}"
2021-03-22 21:18:33 +00:00
git push --quiet origin main
git tag ${GITHUB_REF#refs/tags/} -m "${GITHUB_REF#refs/tags/}"
git push --quiet origin ${GITHUB_REF#refs/tags/}