@@ -2,62 +2,84 @@ name: Downgraded Release
22
33on :
44 push :
5+ branches :
6+ - main
57 tags :
6- # avoid infinite looping, skip tags that ends with ".72"
7- # see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches
88 - ' *'
99
1010jobs :
1111 downgrade_release :
1212 runs-on : ubuntu-latest
1313
1414 steps :
15- - uses : " actions/checkout@v3 "
15+ - uses : " actions/checkout@v5 "
1616 with :
17- token : ${{ secrets.WORKFLOWS_TOKEN }}
17+ token : ${{ secrets.WORKFLOWS_TOKEN || github.token }}
1818
1919 -
2020 uses : " shivammathur/setup-php@v2"
2121 with :
22- php-version : 8.2
22+ php-version : 8.4
2323 coverage : none
2424
25- # invoke patches
2625 - run : composer install --ansi
2726
28- # but no dev packages
29- - run : composer update --no-dev --ansi
30-
31- # get rector to "rector-local" directory, to avoid downgrading itself in the /vendor
32- - run : mkdir rector-local
33- - run : composer require rector/rector:^1.1 --working-dir rector-local --ansi
27+ # downgrade /src to PHP 7.4
28+ - run : vendor/bin/rector process src --config build/rector-downgrade-php-74.php --ansi
29+ - run : vendor/bin/ecs check src --fix --ansi
3430
35- # downgrade to PHP 7.4
36- - run : rector-local/ vendor/bin/rector process src --config build/ rector-downgrade-php-74 .php --ansi
31+ # clear the dev files, the vendor is not shipped as this is a phpstan extension
32+ - run : rm -rf vendor tests ecs.php phpstan.neon phpunit.xml rector.php composer.lock .gitignore .editorconfig full-tool-build.sh
3733
38- # clear the dev files
39- - run : rm -rf tests rector-local ecs.php phpstan.neon phpunit.xml .editorconfig
34+ # remove the original .github, to fully override it with the target repository one below
35+ - run : rm -rf .github
4036
41- # copy PHP 7.2 composer + workflows
37+ # copy PHP 7.4 composer + workflows
4238 - run : cp -r build/target-repository/. .
4339
44- # clear the dev files
45- - run : rm -rf build full-tool-build.sh rector.php phpstan-for-tests.neon tests
40+ # clear the build files
41+ - run : rm -rf build
42+
43+ # clone the remote repository, so we can commit on top of its history and push without --force
44+ # inspired by https://github.com/easy-coding-standard/ecs-src/blob/main/.github/workflows/buid_release.yaml
45+ -
46+ uses : " actions/checkout@v5"
47+ with :
48+ repository : anywherephp/type-perfect
49+ path : remote-repository
50+ token : ${{ secrets.WORKFLOWS_TOKEN }}
51+
52+ # remove remote files, to avoid piling up dead code in remote repository
53+ - run : rm -rf remote-repository/src remote-repository/config remote-repository/.github
54+
55+ # copy the downgraded code to the remote repository
56+ - run : rsync -a --exclude .git --exclude remote-repository ./ remote-repository/
4657
4758 # setup git user
4859 -
60+ working-directory : remote-repository
4961 run : |
50- git config user.email "action@github.com "
51- git config user.name "GitHub Action "
52- # publish to the same repository with a new tag
53- # see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same- repository/
62+ git config user.email "tomas@getrector.org "
63+ git config user.name "rector-bot "
64+
65+ # publish to remote repository without tag
5466 -
55- name : " Tag Downgraded Code"
67+ name : " Push Downgraded Code - branch"
68+ working-directory : remote-repository
69+ if : " !startsWith(github.ref, 'refs/tags/')"
5670 run : |
57- # separate a "git add" to add untracked (new) files too
5871 git add --all
59- git commit -m "release PHP 7.4 downgraded"
72+ git commit -m "Updated TypePerfect to commit ${{ github.event.after }}"
73+ git push --quiet origin main
6074
61- # force push tag, so there is only 1 version
62- git tag "${GITHUB_REF#refs/tags/}" --force
63- git push origin "${GITHUB_REF#refs/tags/}" --force
75+ # publish to remote repository with tag
76+ -
77+ name : " Push Downgraded Code - tag"
78+ working-directory : remote-repository
79+ if : " startsWith(github.ref, 'refs/tags/')"
80+ run : |
81+ git add --all
82+ git commit --allow-empty -m "TypePerfect ${GITHUB_REF#refs/tags/}"
83+ git push --quiet origin main
84+ git tag "${GITHUB_REF#refs/tags/}" -m "${GITHUB_REF#refs/tags/}"
85+ git push --quiet origin "${GITHUB_REF#refs/tags/}"
0 commit comments