|
| 1 | +name: Downgraded Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches |
| 7 | + - '*' |
| 8 | + |
| 9 | +jobs: |
| 10 | + downgrade_release: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: "actions/checkout@v3" |
| 15 | + with: |
| 16 | + token: ${{ secrets.WORKFLOWS_TOKEN }} |
| 17 | + |
| 18 | + - |
| 19 | + uses: "shivammathur/setup-php@v2" |
| 20 | + with: |
| 21 | + php-version: 8.3 |
| 22 | + coverage: none |
| 23 | + |
| 24 | + # invoke patches |
| 25 | + - run: composer install --ansi |
| 26 | + |
| 27 | + # but no dev packages |
| 28 | + - run: composer update --no-dev --ansi |
| 29 | + |
| 30 | + # get rector to "rector-local" directory, to avoid downgrading itself in the /vendor |
| 31 | + - run: mkdir rector-local |
| 32 | + - run: composer require rector/rector --working-dir rector-local --ansi |
| 33 | + |
| 34 | + # downgrade to PHP 7.4 |
| 35 | + - run: rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php.php --ansi |
| 36 | + |
| 37 | + # clear the dev files |
| 38 | + - run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig |
| 39 | + |
| 40 | + # prefix and scope |
| 41 | + - run: sh prefix-code.sh |
| 42 | + |
| 43 | + # copy PHP 7.4 composer + workflows |
| 44 | + - run: cp -r build/target-repository/. . |
| 45 | + |
| 46 | + # clear the dev files |
| 47 | + - run: rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php php-scoper.phar rector-local |
| 48 | + |
| 49 | + # setup git user |
| 50 | + - |
| 51 | + run: | |
| 52 | + git config user.email "action@github.com" |
| 53 | + git config user.name "GitHub Action" |
| 54 | + # publish to the same repository with a new tag |
| 55 | + # see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same-repository/ |
| 56 | + - |
| 57 | + name: "Tag Downgraded Code" |
| 58 | + run: | |
| 59 | + # separate a "git add" to add untracked (new) files too |
| 60 | + git add --all |
| 61 | + git commit -m "release PHP 7.2 downgraded" |
| 62 | +
|
| 63 | + # force push tag, so there is only 1 version |
| 64 | + git tag "${GITHUB_REF#refs/tags/}" --force |
| 65 | + git push origin "${GITHUB_REF#refs/tags/}" --force |
0 commit comments