@@ -2,19 +2,19 @@ name: Downgraded Release
22
33on :
44 push :
5+ branches :
6+ - main
57 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
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"
@@ -32,35 +32,65 @@ jobs:
3232 - run : mkdir rector-local
3333 - run : composer require rector/rector --working-dir rector-local --ansi
3434
35- # downgrade to PHP 7.4
35+ # downgrade to PHP 7.2
3636 - run : rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php.php --ansi
3737
3838 # clear the dev files
39- - run : rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig
39+ - run : rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig composer.lock composer-dependency-analyser.php
4040
4141 # prefix and scope
4242 - run : sh prefix-code.sh
4343
44- # copy PHP 7.4 composer + workflows
44+ # remove the original .github, to fully override it with the target repository one below
45+ - run : rm -rf .github
46+
47+ # copy PHP 7.2 composer + workflows
4548 - run : cp -r build/target-repository/. .
4649
47- # clear the dev files
50+ # clear the build files
4851 - run : rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php php-scoper.phar rector-local
4952
53+ # clone the remote repository, so we can commit on top of its history and push without --force
54+ # inspired by https://github.com/easy-coding-standard/ecs-src/blob/main/.github/workflows/buid_release.yaml
55+ -
56+ uses : " actions/checkout@v5"
57+ with :
58+ repository : anywherephp/jack
59+ path : remote-repository
60+ token : ${{ secrets.WORKFLOWS_TOKEN }}
61+
62+ # remove remote files, to avoid piling up dead code in remote repository
63+ # the remote .gitignore must go too, as it ignores the /vendor that is shipped in this scoped build
64+ - run : rm -rf remote-repository/bin remote-repository/src remote-repository/vendor remote-repository/docs remote-repository/.github remote-repository/.gitignore
65+
66+ # copy the downgraded code to the remote repository
67+ - run : rsync -a --exclude .git --exclude remote-repository ./ remote-repository/
68+
5069 # setup git user
5170 -
71+ working-directory : remote-repository
5272 run : |
53- git config user.email "action@github.com "
54- git config user.name "GitHub Action "
55- # publish to the same repository with a new tag
56- # see https://tomasvotruba.com/blog/how-to-release-php-81-and-72-package-in-the-same- repository/
73+ git config user.email "tomas@getrector.org "
74+ git config user.name "rector-bot "
75+
76+ # publish to remote repository without tag
5777 -
58- name : " Tag Downgraded Code"
78+ name : " Push Downgraded Code - branch"
79+ working-directory : remote-repository
80+ if : " !startsWith(github.ref, 'refs/tags/')"
5981 run : |
60- # separate a "git add" to add untracked (new) files too
6182 git add --all
62- git commit -m "release PHP 7.2 downgraded"
83+ git commit -m "Updated Jack to commit ${{ github.event.after }}"
84+ git push --quiet origin main
6385
64- # force push tag, so there is only 1 version
65- git tag "${GITHUB_REF#refs/tags/}" --force
66- git push origin "${GITHUB_REF#refs/tags/}" --force
86+ # publish to remote repository with tag
87+ -
88+ name : " Push Downgraded Code - tag"
89+ working-directory : remote-repository
90+ if : " startsWith(github.ref, 'refs/tags/')"
91+ run : |
92+ git add --all
93+ git commit --allow-empty -m "Jack ${GITHUB_REF#refs/tags/}"
94+ git push --quiet origin main
95+ git tag "${GITHUB_REF#refs/tags/}" -m "${GITHUB_REF#refs/tags/}"
96+ git push --quiet origin "${GITHUB_REF#refs/tags/}"
0 commit comments