Add Upsun CLI tool (#1157)

* Add Upsun CLI tool

* Revert unrelated README TOC changes
This commit is contained in:
Mickael Gaillard
2026-11-20 21:06:37 +05:30
committed by GitHub
parent 2001cd3148
commit e8d43d139f
5 changed files with 96 additions and 4 deletions
+3 -1
View File
@@ -243,7 +243,7 @@ This disables all core and third-party shared extensions and thus, can break som
These tools can be set up globally using the `tools` input. It accepts a string in csv-format.
[`backward-compatibility-check`], [`behat`], [`blackfire`], [`blackfire-player`], [`box`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-dependency-analyser`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cpx`], [`cs2pr`], [`deployer`], [`ecs`], [`flex`], [`grpc_php_plugin`], [`infection`], [`laravel-cloud`] or [`cloud-cli`], [`mago`], [`name-collision-detector`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`php-scoper`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pie`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
[`backward-compatibility-check`], [`behat`], [`blackfire`], [`blackfire-player`], [`box`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-dependency-analyser`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cpx`], [`cs2pr`], [`deployer`], [`ecs`], [`flex`], [`grpc_php_plugin`], [`infection`], [`laravel-cloud`] or [`cloud-cli`], [`mago`], [`name-collision-detector`], [`parallel-lint`], [`pecl`], [`phan`], [`phing`], [`phinx`], [`phive`], [`php-config`], [`php-cs-fixer`], [`php-scoper`], [`phpcbf`], [`phpcpd`], [`phpcs`], [`phpdoc`] or [`phpDocumentor`], [`phpize`], [`phplint`], [`phpmd`], [`phpspec`], [`phpstan`], [`phpunit`], [`phpunit-bridge`], [`phpunit-polyfills`], [`pie`], [`pint`], [`prestissimo`], [`protoc`], [`psalm`], [`rector`], [`symfony`] or [`symfony-cli`], [`upsun`] or [`upsun-cli`], [`vapor`] or [`vapor-cli`], [`wp`] or [`wp-cli`]
```yaml
- name: Setup PHP with tools
@@ -1155,6 +1155,8 @@ Many users and organizations support setup-php via [GitHub Sponsors](https://git
[`rector`]: https://getrector.org/
[`symfony`]: https://symfony.com/download
[`symfony-cli`]: https://symfony.com/download
[`upsun`]: https://docs.upsun.com/administration/cli.html
[`upsun-cli`]: https://docs.upsun.com/administration/cli.html
[`vapor`]: https://docs.vapor.build/
[`vapor-cli`]: https://docs.vapor.build/
[`wp`]: https://wp-cli.org/
+6 -3
View File
@@ -669,7 +669,7 @@ describe('Tools tests', () => {
it.each([
[
'blackfire, blackfire-player, box, churn, cloud-cli, cpx, cs2pr, flex, grpc_php_plugin, mago, name-collision-detector, parallel-lint, php-cs-fixer, php-scoper, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, vapor, wp, pie',
'blackfire, blackfire-player, box, churn, cloud-cli, cpx, cs2pr, flex, grpc_php_plugin, mago, name-collision-detector, parallel-lint, php-cs-fixer, php-scoper, phpDocumentor, phplint, phpstan, phpunit, pecl, phing, phinx, phinx:1.2.3, phive, phpunit-bridge, phpunit-polyfills, pint, php-config, phpize, protoc, symfony, upsun, vapor, wp, pie',
[
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'add_blackfire',
@@ -702,6 +702,7 @@ describe('Tools tests', () => {
'add_devtools phpize',
'add_protoc latest',
'add_symfony latest',
'add_upsun latest',
'add_composer_tool vapor-cli vapor-cli laravel/ scoped',
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"',
'add_tool https://github.com/php/pie/releases/latest/download/pie.phar pie "-V"'
@@ -716,7 +717,7 @@ describe('Tools tests', () => {
it.each([
[
'backward-compatibility-check, behat, blackfire, blackfire-player, churn, composer-dependency-analyser, composer-normalize, composer-require-checker, composer-unused, cpx:2.0.0, cs2pr:1.2.3, ecs, flex, grpc_php_plugin:1.2.3, infection, laravel-cloud, mago:0.26.1, name-collision-detector, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, rector, symfony-cli, vapor-cli, wp-cli, pie',
'backward-compatibility-check, behat, blackfire, blackfire-player, churn, composer-dependency-analyser, composer-normalize, composer-require-checker, composer-unused, cpx:2.0.0, cs2pr:1.2.3, ecs, flex, grpc_php_plugin:1.2.3, infection, laravel-cloud, mago:0.26.1, name-collision-detector, phan, phan:1.2.3, phing:1.2.3, phinx, phive:1.2.3, php-config, phpcbf, phpcpd, phpcs, phpdoc, phpize, phpmd, phpspec, phpunit-bridge:5.6, phpunit-polyfills:1.0.1, protoc:v1.2.3, psalm, rector, symfony-cli, upsun-cli:5.16.0, vapor-cli, wp-cli, pie',
[
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'add_composer_tool behat behat behat/ scoped',
@@ -755,6 +756,7 @@ describe('Tools tests', () => {
'add_composer_tool rector rector rector/ scoped',
'add_composer_tool backward-compatibility-check backward-compatibility-check roave/ scoped',
'add_symfony latest',
'add_upsun 5.16.0',
'add_composer_tool vapor-cli vapor-cli laravel/ scoped',
'add_tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"',
'add_composer_tool easy-coding-standard easy-coding-standard symplify/ scoped',
@@ -770,7 +772,7 @@ describe('Tools tests', () => {
it.each([
[
'blackfire, blackfire-player:1.2.3, cs2pr, churn, deployer, does_not_exist, flex, mago, name-collision-detector, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, wp, pie',
'blackfire, blackfire-player:1.2.3, cs2pr, churn, deployer, does_not_exist, flex, mago, name-collision-detector, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, upsun-cli, wp, pie',
[
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/composer-7.4-stable.phar,https://artifacts.setup-php.com/composer/composer-7.4-stable.phar,https://dl.cloudsmith.io/public/shivammathur/composer-cache/raw/files/composer-7.4-stable.phar,https://getcomposer.org/composer-stable.phar composer',
'Add-Blackfire',
@@ -789,6 +791,7 @@ describe('Tools tests', () => {
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd "--version"',
'Add-ComposerTool phpunit-bridge phpunit-bridge symfony/ global',
'Add-Symfony',
'Add-Upsun latest',
'Add-Tool https://github.com/wp-cli/builds/blob/gh-pages/phar/wp-cli.phar?raw=true wp-cli "--version"',
'Add-Tool https://github.com/php/pie/releases/latest/download/pie.phar pie "-V"'
]
+8
View File
@@ -288,6 +288,14 @@
"version_prefix": "v",
"version_parameter": "-V"
},
"upsun-cli": {
"alias": "upsun",
"type": "custom-package",
"repository": "upsun/cli",
"domain": "https://github.com",
"version_prefix": "v",
"version_parameter": "--version"
},
"blackfire-player": {
"type": "custom-function",
"domain": "https://get.blackfire.io",
+30
View File
@@ -0,0 +1,30 @@
Function Add-Upsun() {
param(
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Upsun CLI version to be installed')]
[string] $upsun_tag
)
$upsun_tag = $upsun_tag.replace('v', '')
if($upsun_tag -ne 'latest' -and $upsun_tag -notmatch '^\d+(\.\d+)*$') {
Add-Log $cross "upsun-cli" "Invalid upsun-cli version: $upsun_tag"
} elseif(-not([Environment]::Is64BitOperatingSystem)) {
Add-Log $cross "upsun-cli" "upsun-cli is only available for 64-bit Windows"
} else {
$upsun_releases = "https://github.com/upsun/cli/releases"
if ($upsun_tag -eq 'latest') {
$upsun_tag = (Get-File -Url $upsun_releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1].replace('v', '')
}
$url = "$upsun_releases/download/v$upsun_tag/upsun_${upsun_tag}_windows_amd64.zip"
Get-File -Url $url -OutFile $bin_dir\upsun.zip > $null 2>&1
Expand-Archive -Path $bin_dir\upsun.zip -DestinationPath $bin_dir\upsun -Force > $null 2>&1
if (Test-Path $bin_dir\upsun\upsun.exe) {
Move-Item -Path $bin_dir\upsun\upsun.exe -Destination $bin_dir\upsun.exe -Force
Copy-Item -Path $bin_dir\upsun.exe -Destination $bin_dir\upsun-cli.exe > $null 2>&1
Add-ToProfile $current_profile 'upsun' "New-Alias upsun $bin_dir\upsun.exe"
Add-ToProfile $current_profile 'upsun_cli' "New-Alias upsun-cli $bin_dir\upsun-cli.exe"
$tool_version = Get-ToolVersion upsun "--version"
Add-Log $tick "upsun-cli" "Added upsun-cli $tool_version"
} else {
Add-Log $cross "upsun-cli" "Could not setup upsun-cli"
}
}
}
+49
View File
@@ -0,0 +1,49 @@
get_upsun_tag() {
local upsun_tag=$1
if [ "$upsun_tag" = "latest" ]; then
get -s -n "" https://github.com/upsun/cli/releases/latest 2<&1 | grep -m 1 -Eo "tag/v[0-9]+(\.[0-9]+)*" | head -n 1 | cut -d '/' -f 2
else
echo "v$upsun_tag"
fi
}
add_upsun_helper() {
local upsun_tag=$1
local install_dir=/usr/local/bin
local os
local arch
os="$(uname -s | tr '[:upper:]' '[:lower:]')"
arch="$(uname -m)"
case "$arch" in
aarch64*|armv8*|arm64) arch="arm64" ;;
x86_64|amd64) arch="amd64" ;;
esac
if [ "$os" = "darwin" ]; then
arch="all"
install_dir=${brew_prefix:?}/bin
fi
get -q -n /tmp/upsun.tar.gz "https://github.com/upsun/cli/releases/download/$upsun_tag/upsun_${upsun_tag#v}_${os}_${arch}.tar.gz"
mkdir -p /tmp/upsun
tar -xzf /tmp/upsun.tar.gz -C /tmp/upsun
sudo mv /tmp/upsun/upsun "$install_dir"/upsun
sudo chmod a+x "$install_dir"/upsun
rm -rf /tmp/upsun /tmp/upsun.tar.gz
}
add_upsun() {
local upsun_tag="${1/v/}"
if ! [[ "$upsun_tag" =~ ^[0-9]+(\.[0-9]+)*$ || "$upsun_tag" == 'latest' ]]; then
add_log "${cross:?}" "upsun-cli" "Version '$upsun_tag' is not valid for upsun-cli"
else
upsun_tag="$(get_upsun_tag "$upsun_tag")"
add_upsun_helper "$upsun_tag" >/dev/null 2>&1
upsun_path="$(command -v upsun)"
if [[ -n "$upsun_path" ]]; then
sudo ln -s "$upsun_path" "${tool_path_dir:?}"/upsun-cli
tool_version=$(get_tool_version "upsun" "--version")
add_log "${tick:?}" "upsun-cli" "Added upsun-cli $tool_version"
else
add_log "${cross:?}" "upsun-cli" "Could not setup upsun-cli"
fi
fi
}