mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-21 22:33:27 +07:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
73963f5001 | |||
f4fb0af4d5 | |||
eb73c01f76 | |||
3d8c10397e | |||
db8db3c7c7 | |||
31bfabaf56 | |||
21eeae309a | |||
48e0de2ea6 | |||
88841d1465 | |||
a4e22b60bb | |||
4f6ab99328 | |||
a870b0a9be | |||
67271131b1 | |||
a6ce3f5633 | |||
1a5ac4aa9a | |||
765279d5ef | |||
d71d15b3b3 | |||
ad24e86677 | |||
73dfd2f824 |
2
.github/workflows/node.yml
vendored
2
.github/workflows/node.yml
vendored
@ -54,7 +54,7 @@ jobs:
|
|||||||
run: npm audit
|
run: npm audit
|
||||||
|
|
||||||
- name: Send Coverage
|
- name: Send Coverage
|
||||||
uses: codecov/codecov-action@v3
|
uses: codecov/codecov-action@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.CODECOV_TOKEN }}
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
files: coverage/lcov.info
|
files: coverage/lcov.info
|
||||||
|
2
.github/workflows/php.yml
vendored
2
.github/workflows/php.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
|||||||
key: ${{ env.key }}
|
key: ${{ env.key }}
|
||||||
|
|
||||||
- name: Cache extensions
|
- name: Cache extensions
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.cache-env.outputs.dir }}
|
path: ${{ steps.cache-env.outputs.dir }}
|
||||||
key: ${{ steps.cache-env.outputs.key }}
|
key: ${{ steps.cache-env.outputs.key }}
|
||||||
|
43
README.md
43
README.md
@ -71,11 +71,12 @@ Both `GitHub-hosted` and `self-hosted` runners are supported by `setup-php` on t
|
|||||||
| Virtual environment | YAML workflow label | Pre-installed PHP |
|
| Virtual environment | YAML workflow label | Pre-installed PHP |
|
||||||
|---------------------|------------------------------------|------------------------|
|
|---------------------|------------------------------------|------------------------|
|
||||||
| Ubuntu 22.04 | `ubuntu-latest` or `ubuntu-22.04` | `PHP 8.1` |
|
| Ubuntu 22.04 | `ubuntu-latest` or `ubuntu-22.04` | `PHP 8.1` |
|
||||||
| Ubuntu 20.04 | `ubuntu-20.04` | `PHP 7.4` to `PHP 8.2` |
|
| Ubuntu 20.04 | `ubuntu-20.04` | `PHP 7.4` to `PHP 8.3` |
|
||||||
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.2` |
|
| Windows Server 2022 | `windows-latest` or `windows-2022` | `PHP 8.3` |
|
||||||
| Windows Server 2019 | `windows-2019` | `PHP 8.2` |
|
| Windows Server 2019 | `windows-2019` | `PHP 8.3` |
|
||||||
| macOS Ventura 13.x | `macos-13` | `PHP 8.2` |
|
| macOS Sonoma 14.x | `macos-14` | - |
|
||||||
| macOS Monterey 12.x | `macos-latest` or `macos-12` | `PHP 8.2` |
|
| macOS Ventura 13.x | `macos-13` | `PHP 8.3` |
|
||||||
|
| macOS Monterey 12.x | `macos-latest` or `macos-12` | `PHP 8.3` |
|
||||||
|
|
||||||
### Self-Hosted Runners
|
### Self-Hosted Runners
|
||||||
|
|
||||||
@ -307,6 +308,16 @@ These tools can be set up globally using the `tools` input. It accepts a string
|
|||||||
- If you do not want to use all your dev-dependencies in workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
|
- If you do not want to use all your dev-dependencies in workflow, you can run composer with `--no-dev` and install required tools using `tools` input to speed up your workflow.
|
||||||
- By default, `COMPOSER_NO_INTERACTION` is set to `1` and `COMPOSER_PROCESS_TIMEOUT` is set to `0`. In effect, this means that Composer commands in your scripts do not need to specify `--no-interaction`.
|
- By default, `COMPOSER_NO_INTERACTION` is set to `1` and `COMPOSER_PROCESS_TIMEOUT` is set to `0`. In effect, this means that Composer commands in your scripts do not need to specify `--no-interaction`.
|
||||||
- Also, `COMPOSER_NO_AUDIT` is set to `1`. So if you want to audit your dependencies for security vulnerabilities, it is recommended to add a `composer audit` step before you install them.
|
- Also, `COMPOSER_NO_AUDIT` is set to `1`. So if you want to audit your dependencies for security vulnerabilities, it is recommended to add a `composer audit` step before you install them.
|
||||||
|
- If you want to set a different `COMPOSER_PROCESS_TIMEOUT`, you can set it in your workflow file using the `env` keyword.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Setup PHP with composer and custom process timeout
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.3'
|
||||||
|
env:
|
||||||
|
COMPOSER_PROCESS_TIMEOUT: 300
|
||||||
|
```
|
||||||
|
|
||||||
## :signal_strength: Coverage Support
|
## :signal_strength: Coverage Support
|
||||||
|
|
||||||
@ -559,6 +570,11 @@ steps:
|
|||||||
- Production release builds of PHP without debugging symbols are set up by default.
|
- Production release builds of PHP without debugging symbols are set up by default.
|
||||||
- You can use the `debug` environment variable to set up a build with debugging symbols for PHP 5.6 and above.
|
- You can use the `debug` environment variable to set up a build with debugging symbols for PHP 5.6 and above.
|
||||||
|
|
||||||
|
**Notes**
|
||||||
|
- On Linux, the debug symbols are added as [debug info files](https://sourceware.org/gdb/current/onlinedocs/gdb.html/Separate-Debug-Files.html) in the `/usr/lib/debug/.build-id` directory. These files match the `build-id` in the ELF section of the PHP binaries and debugging tools like `gdb` are able to resolve the symbols from these files.
|
||||||
|
- On Windows, the debug symbols are added as `pdb` files in the PHP installation directory.
|
||||||
|
- On macOS, the debug symbols are compiled into the binaries.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- name: Setup PHP with debugging symbols
|
- name: Setup PHP with debugging symbols
|
||||||
@ -742,7 +758,7 @@ If your project uses composer, you can persist the composer's internal cache dir
|
|||||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Cache dependencies
|
- name: Cache dependencies
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.composer-cache.outputs.dir }}
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
@ -979,25 +995,18 @@ These companies generously provide setup-php their products and services to aid
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a href="https://www.jetbrains.com/?from=setup-php">
|
<a href="https://www.jetbrains.com/?from=setup-php">
|
||||||
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="106" height="60">
|
<img src="https://setup-php.com/sponsors/jetbrains.svg" alt="JetBrains" width="212" height="120">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="https://www.macstadium.com/opensource/members#gh-light-mode-only">
|
<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="148" height="60">
|
<img src="https://setup-php.com/sponsors/macstadium.png" alt="Mac Stadium" width="296" height="120">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://www.macstadium.com/opensource/members#gh-dark-mode-only">
|
<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="148" height="60">
|
<img src="https://setup-php.com/sponsors/macstadium-white.png" alt="Mac Stadium" width="296" height="120">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
|
<a href="https://tidelift.com/subscription/pkg/npm-setup-php">
|
||||||
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="70" height="60">
|
<img src="https://setup-php.com/sponsors/tidelift.png" alt="Tidelift" width="140" height="120">
|
||||||
</a>
|
|
||||||
|
|
||||||
<a href="https://www.scaleway.com/en/about-us/open-source-program#gh-light-mode-only">
|
|
||||||
<img src="https://setup-php.com/sponsors/scaleway.png" alt="Scaleway" width="174" height="60">
|
|
||||||
</a>
|
|
||||||
<a href="https://www.scaleway.com/en/about-us/open-source-program#gh-dark-mode-only">
|
|
||||||
<img src="https://setup-php.com/sponsors/scaleway-white.png" alt="Scaleway" width="174" height="60">
|
|
||||||
</a>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ describe('Tools tests', () => {
|
|||||||
${'beta_token'} | ${'1.2.3-beta1'}
|
${'beta_token'} | ${'1.2.3-beta1'}
|
||||||
${''} | ${'1.2.3'}
|
${''} | ${'1.2.3'}
|
||||||
`('checking getSemverVersion: $token', async ({token, version}) => {
|
`('checking getSemverVersion: $token', async ({token, version}) => {
|
||||||
process.env['COMPOSER_TOKEN'] = token;
|
process.env['GITHUB_TOKEN'] = token;
|
||||||
expect(
|
expect(
|
||||||
await tools.getSemverVersion(getData({tool: 'tool', version: '1.2'}))
|
await tools.getSemverVersion(getData({tool: 'tool', version: '1.2'}))
|
||||||
).toBe(version);
|
).toBe(version);
|
||||||
@ -574,7 +574,7 @@ describe('Tools tests', () => {
|
|||||||
${'phpunit:1.2'} | ${'invalid_token'} | ${'add_log "$cross" "phpunit" "Invalid token"'}
|
${'phpunit:1.2'} | ${'invalid_token'} | ${'add_log "$cross" "phpunit" "Invalid token"'}
|
||||||
${'phpunit:0.1'} | ${'no_data'} | ${'add_log "$cross" "phpunit" "No version found with prefix 0.1."'}
|
${'phpunit:0.1'} | ${'no_data'} | ${'add_log "$cross" "phpunit" "No version found with prefix 0.1."'}
|
||||||
`('checking error: $tools_csv', async ({tools_csv, token, script}) => {
|
`('checking error: $tools_csv', async ({tools_csv, token, script}) => {
|
||||||
process.env['COMPOSER_TOKEN'] = token;
|
process.env['GITHUB_TOKEN'] = token;
|
||||||
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
|
expect(await tools.addTools(tools_csv, '7.4', 'linux')).toContain(script);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
5723
dist/index.js
vendored
5723
dist/index.js
vendored
File diff suppressed because one or more lines are too long
578
package-lock.json
generated
578
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "2.29.0",
|
"version": "2.30.1",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup PHP for use with GitHub Actions",
|
"description": "Setup PHP for use with GitHub Actions",
|
||||||
"main": "lib/install.js",
|
"main": "lib/install.js",
|
||||||
@ -19,7 +19,7 @@
|
|||||||
"lint": "eslint **/src/*.ts **/__tests__/*.ts --cache --fix",
|
"lint": "eslint **/src/*.ts **/__tests__/*.ts --cache --fix",
|
||||||
"format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f __tests__/ ",
|
"format": "prettier --write **/src/*.ts **/__tests__/*.ts && git add -f __tests__/ ",
|
||||||
"format-check": "prettier --check **/src/*.ts **/__tests__/*.ts",
|
"format-check": "prettier --check **/src/*.ts **/__tests__/*.ts",
|
||||||
"release": "ncc build -o dist && git add -f dist/",
|
"release": "ncc build -m -o dist && git add -f dist/",
|
||||||
"test": "jest"
|
"test": "jest"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -40,23 +40,23 @@
|
|||||||
"compare-versions": "^6.1.0"
|
"compare-versions": "^6.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.11",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^20.11.0",
|
"@types/node": "^20.11.30",
|
||||||
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
"@typescript-eslint/eslint-plugin": "^7.3.1",
|
||||||
"@typescript-eslint/parser": "^6.18.1",
|
"@typescript-eslint/parser": "^7.3.1",
|
||||||
"@vercel/ncc": "^0.38.1",
|
"@vercel/ncc": "^0.38.1",
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"eslint-plugin-import": "^2.29.1",
|
||||||
"eslint-plugin-jest": "^27.6.3",
|
"eslint-plugin-jest": "^27.9.0",
|
||||||
"eslint-plugin-prettier": "^5.1.3",
|
"eslint-plugin-prettier": "^5.1.3",
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^29.7.0",
|
||||||
"nock": "^13.5.0",
|
"nock": "^13.5.4",
|
||||||
"prettier": "^3.2.2",
|
"prettier": "^3.2.5",
|
||||||
"simple-git-hooks": "^2.9.0",
|
"simple-git-hooks": "^2.11.0",
|
||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.2",
|
||||||
"typescript": "^5.3.3"
|
"typescript": "^5.4.3"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/shivammathur/setup-php/issues"
|
"url": "https://github.com/shivammathur/setup-php/issues"
|
||||||
|
@ -113,17 +113,6 @@ add_pecl() {
|
|||||||
add_log "${tick:?}" "PECL" "Found PECL $pear_version"
|
add_log "${tick:?}" "PECL" "Found PECL $pear_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to link all libraries of a formula.
|
|
||||||
link_libraries() {
|
|
||||||
formula=$1
|
|
||||||
formula_prefix="$(brew --prefix "$formula")"
|
|
||||||
sudo mkdir -p "$formula_prefix"/lib
|
|
||||||
for lib in "$formula_prefix"/lib/*.dylib; do
|
|
||||||
lib_name=$(basename "$lib")
|
|
||||||
sudo cp -a "$lib" "$brew_prefix/lib/$lib_name" 2>/dev/null || true
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Link opcache extension to extensions directory.
|
# Link opcache extension to extensions directory.
|
||||||
link_opcache() {
|
link_opcache() {
|
||||||
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini
|
opcache_ini="$brew_prefix"/etc/php/"$version"/conf.d/ext-opcache.ini
|
||||||
@ -142,45 +131,15 @@ patch_brew() {
|
|||||||
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
trap "sudo sed -Ei '' 's/$code.*/$code, overwrite: overwrite?\)/' $formula_installer" exit
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to update the dependencies.
|
|
||||||
update_dependencies_helper() {
|
|
||||||
dependency=$1
|
|
||||||
[[ "${dependency:0:3}" = "lib" ]] && prefix=lib || prefix="${dependency:0:1}"
|
|
||||||
get -q -n "$core_repo/Formula/$prefix/$dependency.rb" "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/$prefix/$dependency.rb"
|
|
||||||
link_libraries "$dependency"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to update dependencies.
|
# Function to update dependencies.
|
||||||
update_dependencies() {
|
update_dependencies() {
|
||||||
patch_brew
|
patch_brew
|
||||||
if ! [ -e /tmp/update_dependencies ]; then
|
if ! [ -e /tmp/update_dependencies ]; then
|
||||||
if [ "${runner:?}" != "self-hosted" ] && [ "${ImageOS:-}" != "" ] && [ "${ImageVersion:-}" != "" ]; then
|
git_retry -C "$core_repo" fetch origin master && git -C "$core_repo" reset --hard origin/master
|
||||||
deps_file="$tap_dir/$php_tap/.github/deps/${ImageOS:?}_${ImageVersion:?}"
|
|
||||||
if [ -e "$deps_file" ]; then
|
|
||||||
while read -r dependency; do
|
|
||||||
update_dependencies_helper "$dependency" &
|
|
||||||
to_wait+=($!)
|
|
||||||
done <"$deps_file"
|
|
||||||
fi
|
|
||||||
wait "${to_wait[@]}"
|
|
||||||
else
|
|
||||||
git -C "$core_repo" fetch origin master && git -C "$core_repo" reset --hard origin/master
|
|
||||||
fi
|
|
||||||
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
echo '' | sudo tee /tmp/update_dependencies >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to fix dependencies on install PHP version.
|
|
||||||
fix_dependencies() {
|
|
||||||
broken_deps_paths=$(php -v 2>&1 | grep -Eo '/opt/[a-zA-Z0-9@\.]+')
|
|
||||||
if [ "x$broken_deps_paths" != "x" ]; then
|
|
||||||
update_dependencies
|
|
||||||
IFS=" " read -r -a formulae <<< "$(echo "$broken_deps_paths" | tr '\n' ' ' | sed 's|/opt/||g' 2>&1)$php_formula"
|
|
||||||
brew reinstall "${formulae[@]}"
|
|
||||||
brew link --force --overwrite "$php_formula" || true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Function to get PHP version if it is already installed using Homebrew.
|
# Function to get PHP version if it is already installed using Homebrew.
|
||||||
get_brewed_php() {
|
get_brewed_php() {
|
||||||
cellar="$brew_prefix"/Cellar
|
cellar="$brew_prefix"/Cellar
|
||||||
@ -262,8 +221,8 @@ setup_php() {
|
|||||||
add_php "upgrade" "$existing_version" >/dev/null 2>&1
|
add_php "upgrade" "$existing_version" >/dev/null 2>&1
|
||||||
status="Updated to"
|
status="Updated to"
|
||||||
else
|
else
|
||||||
status="Found"
|
add_php "upgrade" "$existing_version" >/dev/null 2>&1
|
||||||
fix_dependencies >/dev/null 2>&1
|
status="Updated to"
|
||||||
fi
|
fi
|
||||||
php_config="$(command -v php-config)"
|
php_config="$(command -v php-config)"
|
||||||
ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)"
|
ext_dir="$(grep 'extension_dir=' "$php_config" | cut -d "'" -f 2)"
|
||||||
@ -305,6 +264,7 @@ export HOMEBREW_NO_INSTALL_FROM_API=1
|
|||||||
# shellcheck source=.
|
# shellcheck source=.
|
||||||
. "${scripts:?}"/unix.sh
|
. "${scripts:?}"/unix.sh
|
||||||
. "${scripts:?}"/tools/brew.sh
|
. "${scripts:?}"/tools/brew.sh
|
||||||
|
. "${scripts:?}"/tools/retry.sh
|
||||||
. "${scripts:?}"/tools/add_tools.sh
|
. "${scripts:?}"/tools/add_tools.sh
|
||||||
. "${scripts:?}"/extensions/source.sh
|
. "${scripts:?}"/extensions/source.sh
|
||||||
. "${scripts:?}"/extensions/add_extensions.sh
|
. "${scripts:?}"/extensions/add_extensions.sh
|
||||||
|
@ -39,9 +39,13 @@ add_oci_helper() {
|
|||||||
status='Installed and enabled'
|
status='Installed and enabled'
|
||||||
read -r "${ext}_LINUX_LIBS" <<< "libaio-dev"
|
read -r "${ext}_LINUX_LIBS" <<< "libaio-dev"
|
||||||
read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) --with-${ext/_/-}=instantclient,$oracle_client"
|
read -r "${ext}_CONFIGURE_OPTS" <<< "--with-php-config=$(command -v php-config) --with-${ext/_/-}=instantclient,$oracle_client"
|
||||||
read -r "${ext}_PATH" <<< "ext/$ext"
|
|
||||||
patch_phpize
|
patch_phpize
|
||||||
|
if [[ $(printf "%s\n%s" "${version:?}" "8.3" | sort -V | head -n1) != "$version" ]]; then
|
||||||
|
add_extension_from_source "$ext" https://github.com php pecl-database-"$ext" main extension get
|
||||||
|
else
|
||||||
|
read -r "${ext}_PATH" <<< "ext/$ext"
|
||||||
add_extension_from_source "$ext" https://github.com php php-src "$(php_src_tag)" extension get
|
add_extension_from_source "$ext" https://github.com php php-src "$(php_src_tag)" extension get
|
||||||
|
fi
|
||||||
restore_phpize
|
restore_phpize
|
||||||
else
|
else
|
||||||
enable_extension "$ext" extension
|
enable_extension "$ext" extension
|
||||||
|
@ -8,19 +8,36 @@ Function Get-PhalconReleaseAssetUrl() {
|
|||||||
)
|
)
|
||||||
$domain = 'https://api.github.com/repos'
|
$domain = 'https://api.github.com/repos'
|
||||||
$releases = 'phalcon/cphalcon/releases'
|
$releases = 'phalcon/cphalcon/releases'
|
||||||
|
$match = $null
|
||||||
if($extension_version -match '[3-4]') {
|
if($extension_version -match '[3-4]') {
|
||||||
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
|
||||||
try {
|
try {
|
||||||
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
|
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
|
||||||
} catch {
|
} catch { }
|
||||||
|
if($null -eq $match) {
|
||||||
|
try {
|
||||||
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
|
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon_${arch}_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)"
|
||||||
|
} catch { }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
|
$nts = if (!$installed.ThreadSafe) { "-nts" } else { "-ts" }
|
||||||
|
try {
|
||||||
|
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(php_phalcon-php${version}${nts}-windows.*-x64.zip)"
|
||||||
|
} catch { }
|
||||||
|
if($null -eq $match) {
|
||||||
|
try {
|
||||||
|
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(php_phalcon-php${version}${nts}-windows.*-x64.zip)"
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
if($null -eq $match) {
|
||||||
try {
|
try {
|
||||||
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
|
$match = (Invoke-RestMethod -Uri "$domain/$releases/tags/v$Semver").assets | Select-String -Pattern "browser_download_url=.*(phalcon-php${version}${nts}-windows.*-x64.zip)"
|
||||||
} catch {
|
} catch { }
|
||||||
|
}
|
||||||
|
if($null -eq $match) {
|
||||||
|
try {
|
||||||
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
|
$match = (Get-File -Url "$github/$releases/expanded_assets/v$Semver").Links.href | Select-String -Pattern "(phalcon-php${version}${nts}-windows.*-x64.zip)"
|
||||||
|
} catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($NULL -ne $match) {
|
if($NULL -ne $match) {
|
||||||
@ -54,6 +71,8 @@ Function Get-PhalconSemver() {
|
|||||||
return '3.4.5'
|
return '3.4.5'
|
||||||
} elseif (($extension_version -eq '4') -and ($version -eq '7.2')) {
|
} elseif (($extension_version -eq '4') -and ($version -eq '7.2')) {
|
||||||
return '4.1.0'
|
return '4.1.0'
|
||||||
|
} elseif (($extension_version -eq '5') -and ($version -eq '7.4')) {
|
||||||
|
return '5.4.0'
|
||||||
}
|
}
|
||||||
return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
|
return Get-PeclPackageVersion phalcon $extension_version stable stable | Select-Object -First 1
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ Function Get-SqlsrvReleaseVersion() {
|
|||||||
return '5.9.0'
|
return '5.9.0'
|
||||||
} elseif ($version -eq '7.4') {
|
} elseif ($version -eq '7.4') {
|
||||||
return '5.10.1'
|
return '5.10.1'
|
||||||
|
} elseif ($version -eq '8.0') {
|
||||||
|
return '5.11.1'
|
||||||
} else {
|
} else {
|
||||||
return 'latest'
|
return 'latest'
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ get_sqlsrv_version() {
|
|||||||
echo '5.9.0'
|
echo '5.9.0'
|
||||||
elif [[ "${version:?}" =~ 7.4 ]]; then
|
elif [[ "${version:?}" =~ 7.4 ]]; then
|
||||||
echo '5.10.1'
|
echo '5.10.1'
|
||||||
|
elif [[ "${version:?}" =~ 8.0 ]]; then
|
||||||
|
echo '5.11.1'
|
||||||
else
|
else
|
||||||
# Return an empty string so that pecl will install the latest version.
|
# Return an empty string so that pecl will install the latest version.
|
||||||
echo ''
|
echo ''
|
||||||
|
@ -23,7 +23,7 @@ Function Edit-ComposerConfig() {
|
|||||||
if (-not(Test-Path $composer_json)) {
|
if (-not(Test-Path $composer_json)) {
|
||||||
Set-Content -Path $composer_json -Value "{}"
|
Set-Content -Path $composer_json -Value "{}"
|
||||||
}
|
}
|
||||||
Add-EnvPATH $src\configs\composer.env
|
Set-ComposerEnv
|
||||||
Add-Path $composer_bin
|
Add-Path $composer_bin
|
||||||
Set-ComposerAuth
|
Set-ComposerAuth
|
||||||
}
|
}
|
||||||
@ -52,6 +52,14 @@ Function Set-ComposerAuth() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to set composer environment variables.
|
||||||
|
Function Set-ComposerEnv() {
|
||||||
|
if ($env:COMPOSER_PROCESS_TIMEOUT) {
|
||||||
|
(Get-Content $src\configs\composer.env -Raw) -replace '(?m)^COMPOSER_PROCESS_TIMEOUT=.*$', "COMPOSER_PROCESS_TIMEOUT=$env:COMPOSER_PROCESS_TIMEOUT" | Set-Content $src\configs\composer.env
|
||||||
|
}
|
||||||
|
Add-EnvPATH $src\configs\composer.env
|
||||||
|
}
|
||||||
|
|
||||||
# Function to extract tool version.
|
# Function to extract tool version.
|
||||||
Function Get-ToolVersion() {
|
Function Get-ToolVersion() {
|
||||||
Param (
|
Param (
|
||||||
|
@ -42,7 +42,7 @@ configure_composer() {
|
|||||||
echo '{}' | tee "$composer_json" >/dev/null
|
echo '{}' | tee "$composer_json" >/dev/null
|
||||||
chmod 644 "$composer_json"
|
chmod 644 "$composer_json"
|
||||||
fi
|
fi
|
||||||
add_env_path "${src:?}"/configs/composer.env
|
set_composer_env
|
||||||
add_path "$composer_bin"
|
add_path "$composer_bin"
|
||||||
set_composer_auth
|
set_composer_auth
|
||||||
}
|
}
|
||||||
@ -68,6 +68,16 @@ set_composer_auth() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to set composer environment variables.
|
||||||
|
set_composer_env() {
|
||||||
|
composer_env="${src:?}"/configs/composer.env
|
||||||
|
if [ -n "$COMPOSER_PROCESS_TIMEOUT" ]; then
|
||||||
|
sed_arg="s/COMPOSER_PROCESS_TIMEOUT.*/COMPOSER_PROCESS_TIMEOUT=$COMPOSER_PROCESS_TIMEOUT/"
|
||||||
|
sed -i "$sed_arg" "$composer_env" 2>/dev/null || sed -i '' "$sed_arg" "$composer_env"
|
||||||
|
fi
|
||||||
|
add_env_path "$composer_env"
|
||||||
|
}
|
||||||
|
|
||||||
# Helper function to configure tools.
|
# Helper function to configure tools.
|
||||||
add_tools_helper() {
|
add_tools_helper() {
|
||||||
tool=$1
|
tool=$1
|
||||||
|
20
src/scripts/tools/retry.sh
Normal file
20
src/scripts/tools/retry.sh
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
function retry {
|
||||||
|
local try=0
|
||||||
|
|
||||||
|
until "$@"; do
|
||||||
|
exit_code="$?"
|
||||||
|
try=$((try + 1))
|
||||||
|
|
||||||
|
if [ $try -lt 10 ]; then
|
||||||
|
sleep "$((2 ** try))"
|
||||||
|
else
|
||||||
|
return $exit_code
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
function git_retry {
|
||||||
|
retry git "$@"
|
||||||
|
}
|
@ -133,14 +133,14 @@ Function Get-File {
|
|||||||
param (
|
param (
|
||||||
[string]$Url,
|
[string]$Url,
|
||||||
[string]$FallbackUrl,
|
[string]$FallbackUrl,
|
||||||
[string]$OutFile,
|
[string]$OutFile = '',
|
||||||
[int]$Retries = 3,
|
[int]$Retries = 3,
|
||||||
[int]$TimeoutSec = 0
|
[int]$TimeoutSec = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
for ($i = 0; $i -lt $Retries; $i++) {
|
for ($i = 0; $i -lt $Retries; $i++) {
|
||||||
try {
|
try {
|
||||||
if($null -ne $OutFile) {
|
if($OutFile -ne '') {
|
||||||
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
|
Invoke-WebRequest -Uri $Url -OutFile $OutFile -TimeoutSec $TimeoutSec
|
||||||
} else {
|
} else {
|
||||||
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
|
Invoke-WebRequest -Uri $Url -TimeoutSec $TimeoutSec
|
||||||
@ -150,7 +150,7 @@ Function Get-File {
|
|||||||
if ($i -eq ($Retries - 1)) {
|
if ($i -eq ($Retries - 1)) {
|
||||||
if($FallbackUrl) {
|
if($FallbackUrl) {
|
||||||
try {
|
try {
|
||||||
if($null -ne $OutFile) {
|
if($OutFile -ne '') {
|
||||||
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
|
Invoke-WebRequest -Uri $FallbackUrl -OutFile $OutFile -TimeoutSec $TimeoutSec
|
||||||
} else {
|
} else {
|
||||||
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
|
Invoke-WebRequest -Uri $FallbackUrl -TimeoutSec $TimeoutSec
|
||||||
|
@ -22,11 +22,9 @@ interface IRef {
|
|||||||
export async function getSemverVersion(data: RS): Promise<string> {
|
export async function getSemverVersion(data: RS): Promise<string> {
|
||||||
const search: string = data['version_prefix'] + data['version'];
|
const search: string = data['version_prefix'] + data['version'];
|
||||||
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
|
const url = `https://api.github.com/repos/${data['repository']}/git/matching-refs/tags%2F${search}.`;
|
||||||
let github_token: string = await utils.readEnv('GITHUB_TOKEN');
|
const github_token: string =
|
||||||
const composer_token: string = await utils.readEnv('COMPOSER_TOKEN');
|
(await utils.readEnv('GITHUB_TOKEN')) ||
|
||||||
if (composer_token && !github_token) {
|
(await utils.readEnv('COMPOSER_TOKEN'));
|
||||||
github_token = composer_token;
|
|
||||||
}
|
|
||||||
const response: RS = await fetch.fetch(url, github_token);
|
const response: RS = await fetch.fetch(url, github_token);
|
||||||
if (response.error || response.data === '[]') {
|
if (response.error || response.data === '[]') {
|
||||||
data['error'] = response.error ?? `No version found with prefix ${search}.`;
|
data['error'] = response.error ?? `No version found with prefix ${search}.`;
|
||||||
|
Reference in New Issue
Block a user