mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-22 20:01:06 +07:00
Add support for PHP 8.0.0-dev #104
This commit is contained in:
parent
14acb26bdc
commit
1cf6a369bb
91
.github/workflows/experimental-workflow.yml
vendored
Normal file
91
.github/workflows/experimental-workflow.yml
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
name: Experimental workflow
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- nightly
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- verbose
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- 'examples/**'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- nightly
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- verbose
|
||||||
|
paths-ignore:
|
||||||
|
- '**.md'
|
||||||
|
- 'examples/**'
|
||||||
|
jobs:
|
||||||
|
run:
|
||||||
|
name: Run
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, ubuntu-16.04, macOS-latest]
|
||||||
|
php-versions: ['8.0']
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Setup Node.js 12.x
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12.x
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
|
||||||
|
- name: Prettier Format Check
|
||||||
|
run: npm run format-check
|
||||||
|
|
||||||
|
- name: ESLint Check
|
||||||
|
run: npm run lint
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: npm test
|
||||||
|
|
||||||
|
- name: Send Coverage
|
||||||
|
continue-on-error: true
|
||||||
|
timeout-minutes: 1
|
||||||
|
run: curl -s https://codecov.io/bash | bash -s -- -t ${{secrets.CODECOV_TOKEN}} -f coverage/clover.xml -n github-actions-codecov-${{ matrix.operating-system }}-php${{ matrix.php-versions }}
|
||||||
|
|
||||||
|
- name: Setup PHP with extensions and custom config
|
||||||
|
run: node dist/index.js
|
||||||
|
env:
|
||||||
|
php-version: ${{ matrix.php-versions }}
|
||||||
|
extension-csv: mbstring, xdebug, pcov #optional
|
||||||
|
ini-values-csv: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
|
||||||
|
|
||||||
|
- name: Testing PHP version
|
||||||
|
run: |
|
||||||
|
php -v
|
||||||
|
php -r "if(strpos(phpversion(), '${{ matrix.php-versions }}') === false) {throw new Exception('Wrong PHP version Installed');}"
|
||||||
|
|
||||||
|
- name: Testing Composer version
|
||||||
|
run: |
|
||||||
|
composer -V
|
||||||
|
php -r "if(strpos(@exec('composer -V'), 'Composer version') === false) {throw new Exception('Composer not found');}"
|
||||||
|
- name: Testing Extensions
|
||||||
|
run: |
|
||||||
|
php -m
|
||||||
|
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
|
||||||
|
# php -r "if(! extension_loaded('Xdebug')) {throw new Exception('Xdebug not found');}"
|
||||||
|
php -r "if(! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
|
||||||
|
- name: Testing ini values
|
||||||
|
run: |
|
||||||
|
php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}"
|
||||||
|
php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}"
|
||||||
|
php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}"
|
||||||
|
- name: Test and Benchmark JIT
|
||||||
|
run: |
|
||||||
|
php -r "if(! extension_loaded('Zend OPcache')) {throw new Exception('Zend OPcache not found');}"
|
||||||
|
php -r "if(ini_get('opcache.jit_buffer_size')!='256M') {throw new Exception('opcache.jit_buffer_size not set');}"
|
||||||
|
php -r "if(ini_get('opcache.jit')!=1235) {throw new Exception('opcache.jit not set');}"
|
||||||
|
php -r "if(ini_get('pcre.jit')!=1) {throw new Exception('pcre.jit not set');}"
|
||||||
|
curl https://raw.githubusercontent.com/php/php-src/master/Zend/bench.php | php
|
31
README.md
31
README.md
@ -45,6 +45,9 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
|
|||||||
|7.2|`Stable`|`Security fixes only`|
|
|7.2|`Stable`|`Security fixes only`|
|
||||||
|7.3|`Stable`|`Active`|
|
|7.3|`Stable`|`Active`|
|
||||||
|7.4|`Stable`|`Active`|
|
|7.4|`Stable`|`Active`|
|
||||||
|
|8.0|`Experimental`|`In development`|
|
||||||
|
|
||||||
|
**Note:** Specifying `8.0` in `php-version` input installs `PHP 8.0.0-dev`. This is an experimental feature on this action available on `ubuntu` and `macOS`. Currently some extensions might not be available for this version.
|
||||||
|
|
||||||
## :cloud: OS/Platform Support
|
## :cloud: OS/Platform Support
|
||||||
|
|
||||||
@ -120,7 +123,7 @@ Inputs supported by this GitHub Action.
|
|||||||
|
|
||||||
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
|
See [action.yml](action.yml "Metadata for this GitHub Action") and usage below for more info.
|
||||||
|
|
||||||
### Basic Usage
|
### Setup a particular PHP version
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
@ -135,18 +138,9 @@ steps:
|
|||||||
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
||||||
coverage: xdebug #optional, setup coverage driver
|
coverage: xdebug #optional, setup coverage driver
|
||||||
pecl: false #optional, setup PECL
|
pecl: false #optional, setup PECL
|
||||||
|
|
||||||
- name: Check PHP Version
|
|
||||||
run: php -v
|
|
||||||
|
|
||||||
- name: Check Composer Version
|
|
||||||
run: composer -V
|
|
||||||
|
|
||||||
- name: Check PHP Extensions
|
|
||||||
run: php -m
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Matrix Testing
|
### Setup multiple PHP versions
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
@ -169,15 +163,6 @@ jobs:
|
|||||||
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
ini-values-csv: post_max_size=256M, short_open_tag=On #optional, setup php.ini configuration
|
||||||
coverage: xdebug #optional, setup coverage driver
|
coverage: xdebug #optional, setup coverage driver
|
||||||
pecl: false #optional, setup PECL
|
pecl: false #optional, setup PECL
|
||||||
|
|
||||||
- name: Check PHP Version
|
|
||||||
run: php -v
|
|
||||||
|
|
||||||
- name: Check Composer Version
|
|
||||||
run: composer -V
|
|
||||||
|
|
||||||
- name: Check PHP Extensions
|
|
||||||
run: php -m
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Cache dependencies
|
### Cache dependencies
|
||||||
@ -246,10 +231,10 @@ If this action helped you.
|
|||||||
|
|
||||||
## :bookmark: This action uses the following works
|
## :bookmark: This action uses the following works
|
||||||
|
|
||||||
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
|
|
||||||
- [Homebrew](https://brew.sh/ "MacOS package manager")
|
|
||||||
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages")
|
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php "Pre-compiled ubuntu packages")
|
||||||
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated "Pre-compiled deprecated PHP for macOS")
|
- [shivammathur/php-builder](https://github.com/shivammathur/php-builder "Pre-compiled nightly PHP builds")
|
||||||
|
- [mlocati/powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager "Package to handle PHP on windows")
|
||||||
|
- [shivammathur/homebrew-php](https://github.com/shivammathur/homebrew-php "Tap for PHP builds for MacOS")
|
||||||
|
|
||||||
## :bookmark_tabs: Further Reading
|
## :bookmark_tabs: Further Reading
|
||||||
|
|
||||||
|
@ -26,23 +26,6 @@ describe('Utils tests', () => {
|
|||||||
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
expect(await utils.getInput('DoesNotExist', false)).toBe('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('checking getVersion', async () => {
|
|
||||||
process.env['php-version'] = '7.3';
|
|
||||||
expect(await utils.getVersion()).toBe('7.3');
|
|
||||||
process.env['php-version'] = '7.4';
|
|
||||||
expect(await utils.getVersion()).toBe('7.4');
|
|
||||||
process.env['php-version'] = '8.0';
|
|
||||||
expect(await utils.getVersion()).toBe('7.4');
|
|
||||||
process.env['php-version'] = '8.0-dev';
|
|
||||||
expect(await utils.getVersion()).toBe('7.4');
|
|
||||||
process.env['php-version'] = '7.4nightly';
|
|
||||||
expect(await utils.getVersion()).toBe('7.4');
|
|
||||||
process.env['php-version'] = '7.4snapshot';
|
|
||||||
expect(await utils.getVersion()).toBe('7.4');
|
|
||||||
process.env['php-version'] = 'nightly';
|
|
||||||
expect(await utils.getVersion()).toBe('7.4');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('checking asyncForEach', async () => {
|
it('checking asyncForEach', async () => {
|
||||||
const array: Array<string> = ['a', 'b', 'c'];
|
const array: Array<string> = ['a', 'b', 'c'];
|
||||||
let concat = '';
|
let concat = '';
|
||||||
|
24
dist/index.js
vendored
24
dist/index.js
vendored
@ -682,26 +682,6 @@ function getInput(name, mandatory) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.getInput = getInput;
|
exports.getInput = getInput;
|
||||||
/**
|
|
||||||
* Function to read the PHP version.
|
|
||||||
*/
|
|
||||||
function getVersion() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const version = yield getInput('php-version', true);
|
|
||||||
switch (version) {
|
|
||||||
case '8.0':
|
|
||||||
case '8.0-dev':
|
|
||||||
case '7.4':
|
|
||||||
case '7.4snapshot':
|
|
||||||
case '7.4nightly':
|
|
||||||
case 'nightly':
|
|
||||||
return '7.4';
|
|
||||||
default:
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.getVersion = getVersion;
|
|
||||||
/**
|
/**
|
||||||
* Async foreach loop
|
* Async foreach loop
|
||||||
*
|
*
|
||||||
@ -1525,7 +1505,7 @@ function run() {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
const os_version = process.platform;
|
const os_version = process.platform;
|
||||||
const version = yield utils.getVersion();
|
const version = yield utils.getInput('php-version', true);
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
let script_path = '';
|
let script_path = '';
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
@ -1541,7 +1521,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
case 'win32':
|
case 'win32':
|
||||||
script_path = yield build('win32.ps1', version, os_version);
|
script_path = yield build('win32.ps1', version, os_version);
|
||||||
yield exec_1.exec('pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname);
|
yield exec_1.exec('pwsh ' + script_path + ' -version ' + version);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.5.8",
|
"version": "1.6.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -2249,12 +2249,14 @@
|
|||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@ -2269,17 +2271,20 @@
|
|||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@ -2396,7 +2401,8 @@
|
|||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@ -2408,6 +2414,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
@ -2422,6 +2429,7 @@
|
|||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
@ -2429,12 +2437,14 @@
|
|||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.3.5",
|
"version": "2.3.5",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.2",
|
"safe-buffer": "^5.1.2",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
@ -2453,6 +2463,7 @@
|
|||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
@ -2533,7 +2544,8 @@
|
|||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"optional": true
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@ -2545,6 +2557,7 @@
|
|||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
@ -2666,6 +2679,7 @@
|
|||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.5.8",
|
"version": "1.6.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup PHP for use with GitHub Actions",
|
"description": "Setup PHP for use with GitHub Actions",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -42,7 +42,7 @@ export async function build(
|
|||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const os_version: string = process.platform;
|
const os_version: string = process.platform;
|
||||||
const version: string = await utils.getVersion();
|
const version: string = await utils.getInput('php-version', true);
|
||||||
// check the os version and run the respective script
|
// check the os version and run the respective script
|
||||||
let script_path = '';
|
let script_path = '';
|
||||||
switch (os_version) {
|
switch (os_version) {
|
||||||
@ -58,9 +58,7 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
case 'win32':
|
case 'win32':
|
||||||
script_path = await build('win32.ps1', version, os_version);
|
script_path = await build('win32.ps1', version, os_version);
|
||||||
await exec(
|
await exec('pwsh ' + script_path + ' -version ' + version);
|
||||||
'pwsh ' + script_path + ' -version ' + version + ' -dir ' + __dirname
|
|
||||||
);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -29,7 +29,8 @@ ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
|
|||||||
sudo chmod 777 "$ini_file"
|
sudo chmod 777 "$ini_file"
|
||||||
mkdir -p "$(pecl config-get ext_dir)"
|
mkdir -p "$(pecl config-get ext_dir)"
|
||||||
composer global require hirak/prestissimo >/dev/null 2>&1
|
composer global require hirak/prestissimo >/dev/null 2>&1
|
||||||
add_log "$tick" "PHP" "Installed PHP $(php -v | head -n 1 | cut -c 5-10)"
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
|
add_log "$tick" "PHP" "Installed PHP $semver"
|
||||||
add_log "$tick" "Composer" "Installed"
|
add_log "$tick" "Composer" "Installed"
|
||||||
|
|
||||||
add_extension() {
|
add_extension() {
|
||||||
@ -46,10 +47,10 @@ add_extension() {
|
|||||||
(
|
(
|
||||||
eval "$install_command" && \
|
eval "$install_command" && \
|
||||||
add_log "$tick" "$extension" "Installed and enabled"
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
) || add_log "$cross" "$extension" "Could not install $extension on PHP$version"
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
else
|
else
|
||||||
if ! php -m | grep -i -q "$extension"; then
|
if ! php -m | grep -i -q "$extension"; then
|
||||||
add_log "$cross" "$extension" "Could not find $extension for PHP$version on PECL"
|
add_log "$cross" "$extension" "Could not find $extension for PHP $semver on PECL"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -17,35 +17,46 @@ add_log() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
existing_version=$(php-config --version | cut -c 1-3)
|
existing_version=$(php-config --version | cut -c 1-3)
|
||||||
version=$1
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
step_log "Setup PHP and Composer"
|
step_log "Setup PHP and Composer"
|
||||||
sudo mkdir -p /var/run
|
sudo mkdir -p /var/run
|
||||||
sudo mkdir -p /run/php
|
sudo mkdir -p /run/php
|
||||||
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
|
||||||
if [ "$existing_version" != "$1" ]; then
|
if [ "$existing_version" != "$1" ]; then
|
||||||
if [ ! -e "/usr/bin/php$1" ]; then
|
if [ ! -e "/usr/bin/php$1" ]; then
|
||||||
if [ "$1" != "7.4" ]; then
|
if [ "$1" = "7.4" ]; then
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
|
||||||
else
|
|
||||||
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
|
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" php"$1"-phpdbg php"$1"-xml curl php"$1"-curl >/dev/null 2>&1
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
|
elif [ "$1" = "8.0" ]; then
|
||||||
|
tar_file=php_"$1"%2Bubuntu"$(lsb_release -r -s)".tar.xz
|
||||||
|
install_dir=~/php/"$1"
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install libicu-dev >/dev/null 2>&1
|
||||||
|
curl -o "$tar_file" -L https://bintray.com/shivammathur/php/download_file?file_path="$tar_file" >/dev/null 2>&1
|
||||||
|
sudo mkdir -m 777 -p ~/php
|
||||||
|
sudo tar xf "$tar_file" -C ~/php >/dev/null 2>&1 && rm -rf "$tar_file"
|
||||||
|
sudo ln -sf -S "$1" "$install_dir"/bin/* /usr/bin/ && sudo ln -sf "$install_dir"/etc/php.ini /etc/php.ini
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ')
|
||||||
|
else
|
||||||
|
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$1" curl php"$1"-curl >/dev/null 2>&1
|
||||||
|
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
|
||||||
fi
|
fi
|
||||||
status="installed"
|
status="installed"
|
||||||
else
|
else
|
||||||
status="switched"
|
status="switched"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for tool in php phar phar.phar php-cgi php-config phpize phpdbg; do
|
for tool in pear pecl php phar phar.phar php-cgi php-config phpize phpdbg; do
|
||||||
if [ -e "/usr/bin/$tool$1" ]; then
|
if [ -e "/usr/bin/$tool$1" ]; then
|
||||||
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
|
sudo update-alternatives --set $tool /usr/bin/"$tool$1" >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$status" != "switched" ]; then
|
if [ "$status" != "switched" ]; then
|
||||||
status="Installed PHP $(php -v | head -n 1 | cut -c 5-10)"
|
status="Installed PHP $semver"
|
||||||
else
|
else
|
||||||
status="Switched to PHP $(php -v | head -n 1 | cut -c 5-10)"
|
status="Switched to PHP $semver"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
status="PHP $(php -v | head -n 1 | cut -c 5-10) Found"
|
status="PHP $semver Found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
|
||||||
@ -88,6 +99,6 @@ add_extension()
|
|||||||
(
|
(
|
||||||
eval "$install_command" && \
|
eval "$install_command" && \
|
||||||
add_log "$tick" "$extension" "Installed and enabled"
|
add_log "$tick" "$extension" "Installed and enabled"
|
||||||
) || add_log "$cross" "$extension" "Could not install $extension on php$version"
|
) || add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
param (
|
param (
|
||||||
[Parameter(Mandatory = $true)][string]$version = "7.3",
|
[Parameter(Mandatory = $true)][string]$version = "7.3"
|
||||||
[Parameter(Mandatory = $true)][string]$dir
|
|
||||||
)
|
)
|
||||||
|
|
||||||
$tick = ([char]8730)
|
$tick = ([char]8730)
|
||||||
@ -16,6 +15,10 @@ Function Add-Log($mark, $subject, $message) {
|
|||||||
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" $code $mark $subject $message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($version -eq '8.0') {
|
||||||
|
$version = '7.4'
|
||||||
|
}
|
||||||
|
|
||||||
Step-Log "Setup PhpManager"
|
Step-Log "Setup PhpManager"
|
||||||
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
||||||
Add-Log $tick "PhpManager" "Installed"
|
Add-Log $tick "PhpManager" "Installed"
|
||||||
@ -85,6 +88,6 @@ Function Add-Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Add-Log $cross $extension "Could not enable"
|
Add-Log $cross $extension "Could not install $extension on PHP $($installed.FullVersion)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
18
src/utils.ts
18
src/utils.ts
@ -22,24 +22,6 @@ export async function getInput(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to read the PHP version.
|
|
||||||
*/
|
|
||||||
export async function getVersion(): Promise<string> {
|
|
||||||
const version: string = await getInput('php-version', true);
|
|
||||||
switch (version) {
|
|
||||||
case '8.0':
|
|
||||||
case '8.0-dev':
|
|
||||||
case '7.4':
|
|
||||||
case '7.4snapshot':
|
|
||||||
case '7.4nightly':
|
|
||||||
case 'nightly':
|
|
||||||
return '7.4';
|
|
||||||
default:
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Async foreach loop
|
* Async foreach loop
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user