Skip to content

update build to anywherephp #232

update build to anywherephp

update build to anywherephp #232

name: Downgraded Release
on:
push:
branches:
- main
tags:
- '*'
jobs:
downgrade_release:
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v5"
with:
token: ${{ secrets.WORKFLOWS_TOKEN || github.token }}
-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.4
coverage: none
# invoke patches
- run: composer install --ansi
# but no dev packages
- run: composer update --no-dev --ansi
# get rector to "rector-local" directory, to avoid downgrading itself in the /vendor
- run: mkdir rector-local
- run: composer require rector/rector:^2.0 --working-dir rector-local --ansi
# downgrade to PHP 7.4
- run: rector-local/vendor/bin/rector process src config --config build/rector-downgrade-php.php --ansi
# clear the dev files
- run: rm -rf tests rector-local ecs.php phpstan.neon phpunit.xml .editorconfig stubs
# remove the original .github, to fully override it with the target repository one below
- run: rm -rf .github
# copy PHP 7.4 composer + workflows + empty .gitignore
- run: cp -r build/target-repository/. .
# clear the dev files
- run: rm -rf build rector.php phpstan-for-tests.neon tests stubs
# clone the remote repository, so we can commit on top of its history and push without --force
# inspired by https://github.com/easy-coding-standard/ecs-src/blob/main/.github/workflows/buid_release.yaml
-
uses: "actions/checkout@v5"
with:
repository: anywherephp/phpstan-rules
path: remote-repository
token: ${{ secrets.WORKFLOWS_TOKEN }}
# remove remote files, to avoid piling up dead code in remote repository
- run: rm -rf remote-repository/src remote-repository/config remote-repository/.github
# copy the downgraded code to the remote repository
- run: rsync -a --exclude .git --exclude remote-repository ./ remote-repository/
# setup git user
-
working-directory: remote-repository
run: |
git config user.email "tomas@getrector.org"
git config user.name "rector-bot"
# publish to remote repository without tag
-
name: "Push Downgraded Code - branch"
working-directory: remote-repository
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
git add --all
git commit -m "Updated PHPStanRules to commit ${{ github.event.after }}"
git push --quiet origin main
# publish to remote repository with tag
-
name: "Push Downgraded Code - tag"
working-directory: remote-repository
if: "startsWith(github.ref, 'refs/tags/')"
run: |
git add --all
git commit --allow-empty -m "PHPStanRules ${GITHUB_REF#refs/tags/}"
git push --quiet origin main
git tag "${GITHUB_REF#refs/tags/}" -m "${GITHUB_REF#refs/tags/}"
git push --quiet origin "${GITHUB_REF#refs/tags/}"