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