-
Notifications
You must be signed in to change notification settings - Fork 1
96 lines (77 loc) · 3.81 KB
/
Copy pathdowngraded_release.yaml
File metadata and controls
96 lines (77 loc) · 3.81 KB
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
95
96
name: Downgraded Release
on:
push:
branches:
- main
tags:
- '*'
jobs:
downgrade_release:
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v5"
with:
token: ${{ secrets.WORKFLOWS_TOKEN || github.token }}
-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.4
coverage: none
# invoke patches
- run: composer install --ansi
# but no dev packages
- run: composer update --no-dev --ansi
# get rector to "rector-local" directory, to avoid downgrading itself in the /vendor
- run: mkdir rector-local
- run: composer require rector/rector --working-dir rector-local --ansi
# downgrade to PHP 7.2
- run: rector-local/vendor/bin/rector process bin src vendor --config build/rector-downgrade-php.php --ansi
# clear the dev files
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig composer.lock composer-dependency-analyser.php
# prefix and scope
- run: sh prefix-code.sh
# remove the original .github, to fully override it with the target repository one below
- run: rm -rf .github
# copy PHP 7.2 composer + workflows
- run: cp -r build/target-repository/. .
# clear the build files
- run: rm -rf build prefix-code.sh full-tool-build.sh scoper.php rector.php php-scoper.phar rector-local
# clone the remote repository, so we can commit on top of its history and push without --force
# inspired by https://github.com/easy-coding-standard/ecs-src/blob/main/.github/workflows/buid_release.yaml
-
uses: "actions/checkout@v5"
with:
repository: anywherephp/jack
path: remote-repository
token: ${{ secrets.WORKFLOWS_TOKEN }}
# remove remote files, to avoid piling up dead code in remote repository
# the remote .gitignore must go too, as it ignores the /vendor that is shipped in this scoped build
- run: rm -rf remote-repository/bin remote-repository/src remote-repository/vendor remote-repository/docs remote-repository/.github remote-repository/.gitignore
# copy the downgraded code to the remote repository
- run: rsync -a --exclude .git --exclude remote-repository ./ remote-repository/
# setup git user
-
working-directory: remote-repository
run: |
git config user.email "tomas@getrector.org"
git config user.name "rector-bot"
# publish to remote repository without tag
-
name: "Push Downgraded Code - branch"
working-directory: remote-repository
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
git add --all
git commit -m "Updated Jack to commit ${{ github.event.after }}"
git push --quiet origin main
# publish to remote repository with tag
-
name: "Push Downgraded Code - tag"
working-directory: remote-repository
if: "startsWith(github.ref, 'refs/tags/')"
run: |
git add --all
git commit --allow-empty -m "Jack ${GITHUB_REF#refs/tags/}"
git push --quiet origin main
git tag "${GITHUB_REF#refs/tags/}" -m "${GITHUB_REF#refs/tags/}"
git push --quiet origin "${GITHUB_REF#refs/tags/}"