Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add allowd-pulugins to composer.json #53

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 57 additions & 59 deletions .github/workflows/downgraded_release.yaml
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
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
- '*'
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 }}

-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.1
coverage: none

# invoke patches
- run: composer config --no-plugins allow-plugins.cweagans/composer-patches true
- run: composer config --no-plugins allow-plugins.phpstan/extension-installer true
- run: composer install --ansi --no-interaction

# but no dev packages
- run: composer update --no-dev --ansi --no-interaction

# 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 packages config vendor --config build/rector-downgrade-php-72.php --ansi

# clear the dev files
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig

# prefix and scope
- run: sh prefix-code.sh

# copy PHP 7.2 composer + workflows
- run: cp -r build/target-repository/. .

# clear the dev files
- 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
-
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"

-
name: "Tag Downgraded Code"
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
downgrade_release:
runs-on: ubuntu-latest

steps:
- uses: "actions/checkout@v3"
with:
token: ${{ secrets.WORKFLOWS_TOKEN }}

-
uses: "shivammathur/setup-php@v2"
with:
php-version: 8.1
coverage: none

# invoke patches
- run: composer install --ansi --no-interaction

# but no dev packages
- run: composer update --no-dev --ansi --no-interaction

# 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 packages config vendor --config build/rector-downgrade-php-72.php --ansi

# clear the dev files
- run: rm -rf tests ecs.php phpstan.neon phpunit.xml .gitignore .editorconfig

# prefix and scope
- run: sh prefix-code.sh

# copy PHP 7.2 composer + workflows
- run: cp -r build/target-repository/. .

# clear the dev files
- 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
-
run: |
git config user.email "[email protected]"
git config user.name "GitHub Action"

-
name: "Tag Downgraded Code"
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
6 changes: 6 additions & 0 deletions build/target-repository/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
"files": [
"bootstrap.php"
]
},
"config": {
"allow-plugins": {
"cweagans/composer-patches": true,
"phpstan/extension-installer": true
}
}
}
14 changes: 7 additions & 7 deletions packages/Release/ReleaseWorker/TagVersionReleaseWorker.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
public function shouldConfirm(): array
{
return [
'whenTrue' => fn(): bool => self::getCurrentBranch() !== self::getDefaultBranch(),
'whenTrue' => fn(): bool => self::getDefaultBranch() !== null && self::getCurrentBranch() !== self::getDefaultBranch(),
'message'=> sprintf('Do you want to release it on the [ %s ] branch?',self::getCurrentBranch())
];
}
Expand All @@ -54,17 +54,17 @@ public function getDescription(Version $version): string
return sprintf('Add local tag "%s"', $version->getOriginalString());
}

private function getCurrentBranch(): string
private function getCurrentBranch(): ?string
{
exec('git rev-parse --abbrev-ref HEAD',$outputs);
exec('git rev-parse --abbrev-ref HEAD',$outputs,$result_code);

return $outputs[0];
return $result_code === 0 ? $outputs[0] : null;
}

private function getDefaultBranch(): string
private function getDefaultBranch(): ?string
{
exec("git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'",$outputs);
exec("git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'",$outputs,$result_code);

return $outputs[0];
return $result_code === 0 ? $outputs[0] : null;
}
}