-
-
Notifications
You must be signed in to change notification settings - Fork 40
94 lines (79 loc) · 2.8 KB
/
downgraded_release.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Downgraded Release
on:
push:
tags:
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches
- '*'
jobs:
downgrade_release:
runs-on: ubuntu-latest
steps:
-
uses: "actions/checkout@v3"
with:
token: ${{ secrets.WORKFLOWS_TOKEN }}
-
id: check_tag
run: |
MESSAGE=$(git tag -l --format='%(contents)' $(git describe --tags $(git rev-list --tags --max-count=1)))
if echo $MESSAGE | grep -q "PHP 7.2 downgraded"; then
echo "NEEDED_DOWNGRADE=0" >> $GITHUB_ENV
else
echo "NEEDED_DOWNGRADE=1" >> $GITHUB_ENV
fi
-
uses: "shivammathur/setup-php@v2"
if: env.NEEDED_DOWNGRADE == '1'
with:
php-version: 8.1
coverage: none
# invoke patches
-
if: env.NEEDED_DOWNGRADE == '1'
run: composer install --ansi --no-interaction
# but no dev packages
-
if: env.NEEDED_DOWNGRADE == '1'
run: composer update --no-dev --ansi --no-interaction
# get rector to "rector-local" directory, to avoid downgrading itself in the /vendor
-
if: env.NEEDED_DOWNGRADE == '1'
run: mkdir rector-local
-
if: env.NEEDED_DOWNGRADE == '1'
run: composer require rector/rector ^0.17 --working-dir rector-local --ansi
# downgrade to PHP 7.2
-
if: env.NEEDED_DOWNGRADE == '1'
run: rector-local/vendor/bin/rector process bin src packages config vendor --config build/rector-downgrade-php-72.php --ansi
# clear the dev files
-
if: env.NEEDED_DOWNGRADE == '1'
run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig
# prefix and scope
-
if: env.NEEDED_DOWNGRADE == '1'
run: sh prefix-code.sh
# copy PHP 7.2 composer + workflows
-
if: env.NEEDED_DOWNGRADE == '1'
run: cp -r build/target-repository/. .
# clear the dev files
-
if: env.NEEDED_DOWNGRADE == '1'
run: rm -rf build prefix-code.sh monorepo-builder.php full-tool-build.sh scoper.php rector.php rector-local packages-tests php-scoper.phar
# setup git user
-
if: env.NEEDED_DOWNGRADE == '1'
run: |
git config user.email "action@github.com"
git config user.name "GitHub Action"
-
name: "Tag Downgraded Code"
if: env.NEEDED_DOWNGRADE == '1'
run: |
# separate a "git add" to add untracked (new) files too
git add --all
git commit -m "release PHP 7.2 downgraded"
git tag -a "${GITHUB_REF#refs/tags/}" -m 'PHP 7.2 downgraded' --force
git push origin "${GITHUB_REF#refs/tags/}" --force