Handle version equal as not outdated (#43) #59
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: 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 --working-dir rector-local --ansi | |
| # downgrade to PHP 7.2 | |
| - run: rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php.php --ansi | |
| # clear the dev files | |
| - run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig composer.lock composer-dependency-analyser.php | |
| # prefix and scope | |
| - run: sh prefix-code.sh | |
| # remove the original .github, to fully override it with the target repository one below | |
| - run: rm -rf .github | |
| # copy PHP 7.2 composer + workflows | |
| - run: cp -r build/target-repository/. . | |
| # clear the build files | |
| - run: rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php php-scoper.phar rector-local | |
| # 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/jack | |
| path: remote-repository | |
| token: ${{ secrets.WORKFLOWS_TOKEN }} | |
| # remove remote files, to avoid piling up dead code in remote repository | |
| # the remote .gitignore must go too, as it ignores the /vendor that is shipped in this scoped build | |
| - run: rm -rf remote-repository/bin remote-repository/src remote-repository/vendor remote-repository/docs remote-repository/.github remote-repository/.gitignore | |
| # 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 Jack 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 "Jack ${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/}" |