Compare commits

..

2 Commits

Author SHA1 Message Date
9bf1c9ed81 testing [skip ci] 2025-06-13 02:13:55 +05:30
6a661ad9b0 testing [skip ci] 2025-06-13 02:13:53 +05:30
17 changed files with 3893 additions and 1554 deletions

View File

@ -2,7 +2,7 @@ name: Node workflow
on:
pull_request:
branches:
- main
- master
- develop
- verbose
paths-ignore:
@ -10,7 +10,7 @@ on:
- 'examples/**'
push:
branches:
- main
- master
- develop
- verbose
paths-ignore:

View File

@ -3,7 +3,7 @@ on:
workflow_dispatch:
pull_request:
branches:
- main
- master
- develop
- verbose
paths-ignore:
@ -11,7 +11,7 @@ on:
- 'examples/**'
push:
branches:
- main
- master
- develop
- verbose
paths-ignore:

2
.gitignore vendored
View File

@ -3,7 +3,7 @@ node_modules/
__tests__/runner/*
lib/
# Rest of the file pulled from https://github.com/github/gitignore/blob/main/Node.gitignore
# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log

View File

@ -229,7 +229,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`], [`cs2pr`], [`deployer`], [`ecs`], [`flex`], [`grpc_php_plugin`], [`infection`], [`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`]
[`behat`], [`blackfire`], [`blackfire-player`], [`box`], [`castor`], [`churn`], [`codeception`], [`composer`], [`composer-dependency-analyser`], [`composer-normalize`], [`composer-prefetcher`], [`composer-require-checker`], [`composer-unused`], [`cs2pr`], [`deployer`], [`ecs`], [`flex`], [`grpc_php_plugin`], [`infection`], [`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`]
```yaml
- name: Setup PHP with tools
@ -258,6 +258,19 @@ These tools can be set up globally using the `tools` input. It accepts a string
When you specify just the major version or the version in `major.minor` format, the latest patch version matching the input will be setup.
With the exception of major versions of `composer`, if you specify only the `major` version or the version in `major.minor` format for a tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a [`GitHub` OAuth token](https://github.com/shivammathur/setup-php#composer-github-oauth "Composer GitHub OAuth").
You can do that by setting `GITHUB_TOKEN` environment variable. The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version.
```yaml
- name: Setup PHP with tools
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: php-cs-fixer:3.64, phpunit:11.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
- The latest stable version of `composer` is set up by default. You can set up the required `composer` version by specifying the major version `v1` or `v2`, or the version in `major.minor` or `semver` format. Additionally, for composer `snapshot` and `preview` can also be specified to set up the respective releases.
```yaml
@ -265,7 +278,7 @@ These tools can be set up globally using the `tools` input. It accepts a string
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer:v1
tools: composer:v2
```
- If you do not use composer in your workflow, you can specify `tools: none` to skip it.
@ -417,7 +430,7 @@ Disable coverage for these reasons:
- The `php-version-file` input if it exists
- A `composer.lock` file and the `platform-overrides.php` value
- A `composer.json` file and the `config.platform.php` value
- If the `composer.lock` or `composer.json` file is in a subdirectory in your repository, please specify the subdirectory path in `COMPOSER_PROJECT_DIR` env.
- If the `composer.lock` or `composer.json` file is in a sub-directory in your repository, please specify the subdirectory path in `COMPOSER_PROJECT_DIR` env.
#### `php-version-file` (optional)
@ -425,7 +438,7 @@ Disable coverage for these reasons:
- Accepts a `string`. For example `'.phpenv-version'`.
- See [PHP support](#tada-php-support) for the supported PHP versions.
- By default, `.php-version` file is used.
- The file needs to either have the PHP version as its content or follows the asdf `.tool-versions` format.
- The file either have the PHP version as its content, or follow the asdf `.tool-versions` format.
- If not specified and the default `.php-version` file is not found, the latest stable PHP version is set up.
#### `extensions` (optional)
@ -460,12 +473,6 @@ Disable coverage for these reasons:
- Accepts a `string` in csv-format. For example: `phpunit, phpcs`
- See [tools support](#wrench-tools-support) for tools supported.
#### `github-token` (optional)
- Specify the GitHub token to use for authentication.
- Accepts a `string`.
- By default, `GITHUB_TOKEN` secret provided by GitHub Actions is used.
### Outputs
#### `php-version`
@ -554,6 +561,8 @@ jobs:
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Nightly Build Setup
@ -795,16 +804,17 @@ restore-keys: ${{ runner.os }}-composer-${{ matrix.prefer }}-
### GitHub Composer Authentication
By default, setup-php uses the `GITHUB_TOKEN` secret that is generated for each workflow run. In case you want to use a Personal Access Token (PAT) instead, you can set the `github-token` input.
If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in `major.minor` format, you can hit the rate limit. To avoid this you can specify an `OAuth` token by setting `GITHUB_TOKEN` environment variable. You can use [`GITHUB_TOKEN`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token "GITHUB_TOKEN documentation") secret for this purpose.
The `COMPOSER_TOKEN` and `GITHUB_TOKEN` environment variables have been deprecated in favor of the `github-token` input and will be removed in the next major version.
The `COMPOSER_TOKEN` environment variable has been deprecated in favor of `GITHUB_TOKEN` and will be removed in the next major version.
```yaml
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
github-token: ${{ secrets.YOUR_PAT_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### Private Packagist Authentication
@ -1005,26 +1015,19 @@ Many users and organisations support setup-php via [GitHub Sponsors](https://git
These companies generously provide setup-php their products and services to aid in the development of this project.
<p>
<a target="_blank" href="https://www.jetbrains.com/?from=setup-php">
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="140" height="80">
<a href="https://www.jetbrains.com/?from=setup-php">
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="212" height="120">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a target="_blank" href="https://www.cloudflare.com/lp/project-alexandria/#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/cloudflare.svg" alt="Cloudflare" width="240" height="80">
<a href="https://www.macstadium.com/opensource/members#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/macstadium.png" alt="Mac Stadium" width="296" height="120">
</a>
<a target="_blank" href="https://www.cloudflare.com/lp/project-alexandria/#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/cloudflare-white.svg" alt="Cloudflare" width="240" height="80">
<a href="https://www.macstadium.com/opensource/members#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/macstadium-white.png" alt="Mac Stadium" width="296" height="120">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a target="_blank" href="https://www.macstadium.com/company/opensource#gh-light-mode-only">
<img src="https://setup-php.com/sponsors/macstadium.png" alt="Mac Stadium" width="200" height="80">
</a>
<a target="_blank" href="https://www.macstadium.com/company/opensource#gh-dark-mode-only">
<img src="https://setup-php.com/sponsors/macstadium-white.png" alt="Mac Stadium" width="200" height="80">
</a>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a target="_blank" href="#">
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="94" height="80">
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="140" height="120">
</a>
</p>
@ -1053,7 +1056,6 @@ These companies generously provide setup-php their products and services to aid
<!-- Links to tools -->
[`backward-compatibility-check`]: https://github.com/Roave/BackwardCompatibilityCheck
[`behat`]: https://docs.behat.org/en/latest/
[`blackfire`]: https://blackfire.io/docs/php/index
[`blackfire-player`]: https://blackfire.io/docs/builds-cookbooks/player
@ -1073,8 +1075,6 @@ These companies generously provide setup-php their products and services to aid
[`flex`]: https://flex.symfony.com/
[`grpc_php_plugin`]: https://grpc.io/
[`infection`]: https://infection.github.io/
[`mago`]: https://github.com/carthage-software/mago
[`name-collision-detector`]: https://github.com/shipmonk/name-collision-detector
[`parallel-lint`]: https://github.com/php-parallel-lint/PHP-Parallel-Lint
[`pecl`]: https://pecl.php.net/
[`phan`]: https://github.com/phan/phan/wiki

View File

@ -393,7 +393,7 @@ describe('Tools tests', () => {
it.each([
[
'blackfire, blackfire-player, box, churn, 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, cs2pr, flex, grpc_php_plugin, 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',
[
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/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',
@ -403,8 +403,6 @@ describe('Tools tests', () => {
'add_tool https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/latest/download/cs2pr cs2pr "-V"',
'add_composer_tool flex flex symfony/ global',
'add_grpc_php_plugin latest',
'add_mago',
'add_composer_tool name-collision-detector name-collision-detector shipmonk/ scoped',
'add_tool https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/latest/download/parallel-lint.phar parallel-lint "--version"',
'add_tool https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.2.1/php-cs-fixer.phar php-cs-fixer "-V"',
'add_tool https://github.com/humbug/php-scoper/releases/latest/download/php-scoper.phar php-scoper "--version"',
@ -438,7 +436,7 @@ describe('Tools tests', () => {
it.each([
[
'backward-compatibility-check, behat, blackfire, blackfire-player, churn, composer-dependency-analyser, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, ecs, flex, grpc_php_plugin:1.2.3, infection, 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',
'behat, blackfire, blackfire-player, churn, composer-dependency-analyser, composer-normalize, composer-require-checker, composer-unused, cs2pr:1.2.3, ecs, flex, grpc_php_plugin:1.2.3, infection, 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',
[
'add_tool https://github.com/shivammathur/composer-cache/releases/latest/download/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',
@ -453,8 +451,6 @@ describe('Tools tests', () => {
'add_composer_tool flex flex symfony/ global',
'add_grpc_php_plugin 1.2.3',
'add_tool https://github.com/infection/infection/releases/latest/download/infection.phar infection "-V"',
'add_mago 0.26.1',
'add_composer_tool name-collision-detector name-collision-detector shipmonk/ scoped',
'add_tool https://github.com/phan/phan/releases/latest/download/phan.phar phan "-v"',
'add_tool https://github.com/phan/phan/releases/download/1.2.3/phan.phar phan "-v"',
'add_tool https://www.phing.info/get/phing-1.2.3.phar,https://github.com/phingofficial/phing/releases/download/1.2.3/phing-1.2.3.phar phing "-v"',
@ -473,7 +469,6 @@ describe('Tools tests', () => {
'add_protoc 1.2.3',
'add_tool https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm "-v"',
'add_composer_tool rector rector rector/ scoped',
'add_composer_tool backward-compatibility-check backward-compatibility-check roave/ scoped',
'add_symfony 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"',
@ -490,7 +485,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, phinx, phive:0.13.2, php-config, phpize, phpmd, simple-phpunit, symfony, wp, pie',
[
'Add-Tool https://github.com/shivammathur/composer-cache/releases/latest/download/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',
@ -500,8 +495,6 @@ describe('Tools tests', () => {
'Add-Tool https://deployer.org/deployer.phar deployer "-V"',
'Tool does_not_exist is not supported',
'Add-ComposerTool flex flex symfony/ global',
'Add-Mago',
'Add-ComposerTool name-collision-detector name-collision-detector shipmonk/ scoped',
'Add-ComposerTool phinx phinx robmorgan/ scoped',
'Add-Tool https://github.com/phar-io/phive/releases/download/0.15.3/phive-0.15.3.phar phive "status"',
'php-config is not a windows tool',

View File

@ -27,9 +27,6 @@ inputs:
tools:
description: 'Setup popular tools globally.'
required: false
github-token:
description: 'GitHub token to use for authentication.'
default: ${{ github.token }}
outputs:
php-version:
description: 'PHP version in semver format'

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

5210
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,30 +40,27 @@
"compare-versions": "^6.1.1"
},
"devDependencies": {
"@eslint/compat": "^1.3.1",
"@eslint/js": "9.30.1",
"@types/jest": "^30.0.0",
"@types/node": "^24.0.11",
"@typescript-eslint/eslint-plugin": "^8.36.0",
"@typescript-eslint/parser": "^8.36.0",
"@eslint/compat": "^1.3.0",
"@eslint/js": "9.28.0",
"@types/jest": "^29.5.14",
"@types/node": "^24.0.1",
"@typescript-eslint/eslint-plugin": "^8.34.0",
"@typescript-eslint/parser": "^8.34.0",
"@vercel/ncc": "^0.38.3",
"eslint": "9.30.1",
"eslint": "9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-prettier": "^5.5.1",
"globals": "^16.3.0",
"jest": "^30.0.4",
"jest-circus": "^30.0.4",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.13.3",
"eslint-plugin-prettier": "^5.4.1",
"globals": "^16.2.0",
"jest": "^30.0.0",
"jest-circus": "^30.0.0",
"nock": "^14.0.5",
"prettier": "^3.6.2",
"prettier": "^3.5.3",
"simple-git-hooks": "^2.13.0",
"ts-jest": "^29.4.0",
"typescript": "^5.8.3"
},
"overrides": {
"test-exclude": "^7.0.1"
},
"bugs": {
"url": "https://github.com/shivammathur/setup-php/issues"
},

View File

@ -1,9 +1,4 @@
{
"backward-compatibility-check": {
"type": "composer",
"repository": "roave/backward-compatibility-check",
"scope": "scoped"
},
"box": {
"type": "phar",
"repository": "box-project/box",
@ -50,12 +45,6 @@
"version_prefix": "",
"version_parameter": "-V"
},
"easy-coding-standard": {
"type": "composer",
"alias": "ecs",
"repository": "symplify/easy-coding-standard",
"scope": "scoped"
},
"infection": {
"type": "phar",
"repository": "infection/infection",
@ -64,11 +53,6 @@
"version_prefix": "",
"version_parameter": "-V"
},
"name-collision-detector": {
"type": "composer",
"repository": "shipmonk/name-collision-detector",
"scope": "scoped"
},
"phan": {
"type": "phar",
"repository": "phan/phan",
@ -249,12 +233,6 @@
"domain": "https://github.com",
"version_prefix": "v"
},
"mago": {
"type": "custom-package",
"repository": "carthage-software/mago",
"domain": "https://github.com",
"version_prefix": ""
},
"protoc": {
"type": "custom-package",
"repository": "protocolbuffers/protobuf",
@ -353,5 +331,11 @@
"extension": ".phar",
"version_parameter": "--version",
"version_prefix": "v"
},
"easy-coding-standard": {
"type": "composer",
"alias": "ecs",
"repository": "symplify/easy-coding-standard",
"scope": "scoped"
}
}

View File

@ -18,6 +18,7 @@ export async function getScript(os: string): Promise<string> {
const filename = os + (await utils.scriptExtension(os));
const script_path = path.join(__dirname, '../src/scripts', filename);
const run_path = script_path.replace(os, 'run');
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
const extension_csv: string = await utils.getInput('extensions', false);
const ini_values_csv: string = await utils.getInput('ini-values', false);
const coverage_driver: string = await utils.getInput('coverage', false);
@ -47,14 +48,6 @@ export async function getScript(os: string): Promise<string> {
return run_path;
}
/**
* Function to set environment variables based on inputs.
*/
export async function setEnv(): Promise<void> {
process.env['fail_fast'] = await utils.getInput('fail-fast', false);
process.env['GITHUB_TOKEN'] ??= await utils.getInput('github-token', false);
}
/**
* Run the script
*/
@ -62,7 +55,6 @@ export async function run(): Promise<void> {
const os: string = process.platform;
const tool = await utils.scriptTool(os);
const run_path = await getScript(os);
await setEnv();
await exec(tool + run_path);
}

View File

@ -216,7 +216,7 @@ add_pecl_extension() {
add_log "${tick:?}" "$extension" "Enabled"
else
[ -n "$pecl_version" ] && pecl_version="-$pecl_version"
pecl_install "$extension$pecl_version" || ( [ "${fail_fast:?}" = "false" ] && add_extension "$extension" "$(get_extension_prefix "$extension")" )
pecl_install "$extension$pecl_version" || add_extension "$extension" "$(get_extension_prefix "$extension")"
extension_version="$(php -r "echo phpversion('$extension');")"
[ -n "$extension_version" ] && extension_version="-$extension_version"
add_extension_log "$extension$extension_version" "Installed and enabled"

View File

@ -1,5 +1,6 @@
# Helper function to add gearman extension.
add_gearman_helper() {
add_ppa ondrej/pkg-gearman
install_packages libgearman-dev
enable_extension gearman extension
if ! check_extension gearman; then

View File

@ -308,6 +308,7 @@ link_apt_fast
. "${scripts:?}"/tools/add_tools.sh
. "${scripts:?}"/extensions/source.sh
. "${scripts:?}"/extensions/add_extensions.sh
set -x
read_env
self_hosted_setup
setup_php

View File

@ -1,36 +0,0 @@
Function Get-MagoTag() {
$releases = 'https://github.com/carthage-software/mago/releases'
if("$mago_tag" -eq "latest") {
$mago_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
} else {
try {
[net.httpWebRequest] $request = [net.webRequest]::create("$releases/tag/$mago_tag")
$request.Method = "HEAD"
[net.httpWebResponse] $response = $request.getResponse()
$response.Close()
$mago_tag = "$mago_tag"
} catch {
$mago_tag = (Get-File -Url $releases/latest).BaseResponse.RequestMessage.RequestUri.Segments[-1]
}
}
return $mago_tag
}
Function Add-Mago() {
param(
[Parameter(Mandatory = $true, Position = 0, HelpMessage = 'The mago version to be installed')]
[ValidatePattern('^latest$|^\d+\.\d+\.\d+$')]
[string] $mago_tag
)
$mago_tag = Get-MagoTag
$arch_name = 'x86_64'
if(-not([Environment]::Is64BitOperatingSystem)) {
$arch_name = 'i686'
}
$url = "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch_name-pc-windows-msvc.zip"
Get-File -Url $url -OutFile $bin_dir\mago.zip
Expand-Archive -Path $bin_dir\mago.zip -DestinationPath $bin_dir\mago -Force
Move-Item -Path $bin_dir\mago\mago-$mago_tag-$arch_name-pc-windows-msvc\mago.exe -Destination $bin_dir\mago.exe -Force
Add-ToProfile $current_profile 'mago' "New-Alias mago $bin_dir\mago.exe"
Add-Log $tick "mago" "Added mago $mago_tag"
}

View File

@ -1,29 +0,0 @@
get_mago_tag() {
if [ "$mago_tag" = "latest" ]; then
mago_tag=$(get -s -n "" https://github.com/carthage-software/mago/releases/latest 2<&1 | grep -m 1 -Eo "tag/([0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
else
status_code=$(get -v -n /tmp/mago.tmp "https://github.com/carthage-software/mago/releases/tag/$mago_tag")
if [ "$status_code" = "200" ]; then
mago_tag="$mago_tag"
else
mago_tag=$(get -s -n "" https://github.com/carthage-software/mago/releases/latest 2<&1 | grep -m 1 -Eo "tag/([0-9]+(\.[0-9]+)?(\.[0-9]+)?)" | head -n 1 | cut -d '/' -f 2)
fi
fi
}
add_mago() {
mago_tag=$1
get_mago_tag
(
platform='unknown-linux-gnu'
[ "$(uname -s)" = "Darwin" ] && platform='apple-darwin'
arch="$(uname -m)"
[[ "$arch" = 'arm64' || "$arch" = 'aarch64' ]] && arch='aarch64'
[[ "$arch" = 'x86_64' || "$arch" = 'amd64' ]] && arch='x86_64'
get -q -n /tmp/mago.tar.gz "https://github.com/carthage-software/mago/releases/download/$mago_tag/mago-$mago_tag-$arch-$platform.tar.gz"
sudo tar -xzf /tmp/mago.tar.gz -C /tmp/
sudo mv /tmp/mago-$mago_tag-$arch-$platform/mago /usr/local/bin/mago
sudo chmod +x /usr/local/bin/mago
)
add_log "${tick:?}" "mago" "Added mago $mago_tag"
}

View File

@ -164,7 +164,7 @@ remove_list() {
# Function to check if ubuntu ppa is up
is_ubuntu_ppa_up() {
ppa=${1:-ondrej/php}
curl -s --connect-timeout 10 --max-time 10 --head --fail "$lpc_ppa/$ppa/ubuntu/dists/$VERSION_CODENAME/Release" > /dev/null
curl -s --connect-timeout 5 --max-time 5 --head --fail "$lpc_ppa/$ppa/ubuntu/dists/$VERSION_CODENAME/Release" > /dev/null
}
# Function to add the PPA mirror.
@ -172,8 +172,8 @@ add_ppa_sp_mirror() {
ppa=$1
ppa_name="$(basename "$ppa")"
remove_list "$ppa" || true
[ "${debug:?}" = "debug" ] && add_list sp/"$ppa_name" "$ppa_sp/$ppa/ubuntu" "$ppa_sp/$ppa/ubuntu/key.gpg" "$VERSION_CODENAME" "main/debug"
add_list sp/"$ppa_name" "$ppa_sp/$ppa/ubuntu" "$ppa_sp/$ppa/ubuntu/key.gpg"
[ "${debug:?}" = "debug" ] && add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg" "$VERSION_CODENAME" "main/debug"
add_list sp/"$ppa_name" "$sp/$ppa/ubuntu" "$sp/$ppa/ubuntu/key.gpg"
}
# Function to add a PPA.
@ -182,7 +182,7 @@ add_ppa() {
ppa=${1:-ondrej/php}
if [[ "$ID" = "ubuntu" || "$ID_LIKE" =~ ubuntu ]] && [[ "$ppa" =~ "ondrej/" ]]; then
if is_ubuntu_ppa_up "$ppa" ; then
[ "${runner:?}" = "self-hosted" ] && find "$list_dir" -type f -name 'sp*' -exec grep -qF "${sp/https:\/\/}" {} \; -delete
[ "${runner:?}" = "self-hosted" ] && find "$list_dir" -type f -name 'sp*' -exec grep -qF "$sp" {} \; -delete
[ "${debug:?}" = "debug" ] && add_list "$ppa" "$lpc_ppa/$ppa/ubuntu" "$lpc_ppa/$ppa/ubuntu" "$VERSION_CODENAME" "main/debug"
add_list "$ppa"
else
@ -225,7 +225,6 @@ lpc_ppa='https://ppa.launchpadcontent.net'
key_dir='/usr/share/keyrings'
dist_info_dir='/usr/share/distro-info'
sury='https://packages.sury.org'
ppa_sp='https://ppa.setup-php.com'
sp='https://setup-php.com'
sks=(
'https://keyserver.ubuntu.com'