mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-07-06 15:13:18 +07:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
201e8c8d98 | |||
35b0788556 | |||
2484a27666 | |||
42de8649eb | |||
f6674883c6 | |||
738fa3dfee | |||
9616296853 |
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
@ -8,7 +8,7 @@ jobs:
|
|||||||
max-parallel: 6
|
max-parallel: 6
|
||||||
matrix:
|
matrix:
|
||||||
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
|
||||||
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']
|
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@master
|
uses: actions/checkout@master
|
||||||
@ -27,4 +27,4 @@ jobs:
|
|||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extension-csv: "mbstring, curl, mysqli, json, xml, xdebug, pcov, phpdbg"
|
extension-csv: "mbstring, curl, mysqli, json, xml, xdebug, pcov, phpdbg"
|
||||||
- name: Testing
|
- name: Testing
|
||||||
run: php -m
|
run: php -v && composer -V && php -m
|
||||||
|
58
README.md
58
README.md
@ -1,34 +1,45 @@
|
|||||||
# setup-php
|
# Setup PHP in GitHub Actions
|
||||||
|
|
||||||
<p align="left">
|
<p align="left">
|
||||||
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
|
||||||
|
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
This action sets up a php environment along with composer and required PHP extensions on multiple platforms for use in github actions.
|
[GitHub Action](https://github.com/features/actions) to install PHP with required extensions and composer. This action can be added as a step in your action workflow and it will setup the PHP environment you need to test your application. Refer to [Usage](#usage) section to see how to use this.
|
||||||
|
|
||||||
# PHP Version Support
|
## PHP Versions Support
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
- 7.1
|
- 7.1
|
||||||
- 7.2
|
- 7.2
|
||||||
- 7.3
|
- 7.3
|
||||||
|
- 7.4 `7.4.0beta4` on `ubuntu`, and `7.4.0RC1` on `windows` and `macOS`
|
||||||
|
|
||||||
# Operating Systems Support
|
**Note:** PHP 7.4 is currently in development, do not use in production.
|
||||||
- Linux (ubuntu-latest)
|
|
||||||
- Windows (windows-latest)
|
|
||||||
- MacOS (macOS-latest)
|
|
||||||
|
|
||||||
# PHP Extension Support
|
## OS Support
|
||||||
- On linux extensions which have the package in apt are installed.
|
|
||||||
- On Windows and MacOS pecl extensions are installed.
|
|Virtual environment|matrix.operating-system|
|
||||||
|
|--- |--- |
|
||||||
|
|Windows Server 2019|`windows-latest` or `windows-2019`|
|
||||||
|
|Windows Server 2016 R2|`windows-2016`|
|
||||||
|
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|
||||||
|
|Ubuntu 16.04|`ubuntu-16.04`|
|
||||||
|
|macOS X Mojave 10.14|`macOS-latest` or `macOS-10.14`|
|
||||||
|
|
||||||
|
|
||||||
|
## PHP Extension Support
|
||||||
|
- On `ubuntu` extensions which have the package in apt are installed.
|
||||||
|
- On `windows` and `macOS` PECL extensions are installed.
|
||||||
- Extensions which are installed along with PHP if specified are enabled.
|
- Extensions which are installed along with PHP if specified are enabled.
|
||||||
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped.
|
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interruped.
|
||||||
|
|
||||||
# Usage
|
## Usage
|
||||||
|
|
||||||
See [action.yml](action.yml)
|
See [action.yml](action.yml) for inputs this action supports.
|
||||||
|
|
||||||
|
### Basic
|
||||||
|
|
||||||
Basic:
|
|
||||||
```yaml
|
```yaml
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -46,7 +57,8 @@ steps:
|
|||||||
run: php -m
|
run: php -m
|
||||||
```
|
```
|
||||||
|
|
||||||
Matrix Testing:
|
### Matrix Testing
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
@ -74,10 +86,24 @@ jobs:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# License
|
## License
|
||||||
|
|
||||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||||
|
|
||||||
# Contributions
|
## Contributions
|
||||||
|
|
||||||
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
Contributions are welcome! See [Contributor's Guide](docs/contributors.md)
|
||||||
|
|
||||||
|
## This action uses the following works
|
||||||
|
|
||||||
|
- [powershell-phpmanager](https://github.com/mlocati/powershell-phpmanager)
|
||||||
|
- [Homebrew](https://brew.sh/)
|
||||||
|
- [ppa:ondrej/php](https://launchpad.net/~ondrej/+archive/ubuntu/php)
|
||||||
|
- [exolnet/homebrew-deprecated](https://github.com/eXolnet/homebrew-deprecated)
|
||||||
|
- [phpbrew](https://github.com/phpbrew/phpbrew)
|
||||||
|
|
||||||
|
## Further Reading
|
||||||
|
|
||||||
|
- [About GitHub Actions](https://github.com/features/actions)
|
||||||
|
- [GitHub Actions Syntax](https://help.github.com/en/articles/workflow-syntax-for-github-actions)
|
||||||
|
- [Other Awesome Actions](https://github.com/sdras/awesome-actions)
|
||||||
|
@ -24,6 +24,7 @@ const fs = __importStar(require("fs"));
|
|||||||
/*
|
/*
|
||||||
Read the scripts
|
Read the scripts
|
||||||
*/
|
*/
|
||||||
|
let os_version = process.platform;
|
||||||
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
||||||
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
||||||
let windows = fs.readFileSync(path.join(__dirname, '../src/windows.ps1'), 'utf8');
|
let windows = fs.readFileSync(path.join(__dirname, '../src/windows.ps1'), 'utf8');
|
||||||
@ -38,7 +39,7 @@ function asyncForEach(array, callback) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Enable functions which are installed but not enabled
|
Enable extensions which are installed but not enabled
|
||||||
*/
|
*/
|
||||||
function enableExtension(extension) {
|
function enableExtension(extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@ -52,10 +53,11 @@ function enableExtension(extension) {
|
|||||||
} catch [Exception] {
|
} catch [Exception] {
|
||||||
echo $_
|
echo $_
|
||||||
}\n`;
|
}\n`;
|
||||||
let shell_code = `ext_dir=$(php -i | grep "extension_dir" | sed -e "s|.*=>\s*||")
|
let shell_code = `ext_dir=$(php-config --extension-dir)
|
||||||
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
||||||
if [ "$enabled" == 'no' ] && [ test -f "$ext_dir/${extension}.so" ]; then
|
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*:\s*||"'
|
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
||||||
|
echo "${extension} enabled"
|
||||||
fi\n`;
|
fi\n`;
|
||||||
linux += shell_code;
|
linux += shell_code;
|
||||||
darwin += shell_code;
|
darwin += shell_code;
|
||||||
@ -79,7 +81,10 @@ function addExtension(extension_csv, version) {
|
|||||||
darwin += '\n';
|
darwin += '\n';
|
||||||
yield asyncForEach(extensions, function (extension) {
|
yield asyncForEach(extensions, function (extension) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
enableExtension(extension);
|
enableExtension(extension);
|
||||||
|
// else add script to attempt to install the extension
|
||||||
|
if (os_version == 'linux') {
|
||||||
linux +=
|
linux +=
|
||||||
'sudo apt install -y php' +
|
'sudo apt install -y php' +
|
||||||
version +
|
version +
|
||||||
@ -90,15 +95,24 @@ function addExtension(extension_csv, version) {
|
|||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
'"\n';
|
'"\n';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// check if pecl extension exists
|
||||||
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 2
|
maxRetries: 2
|
||||||
});
|
});
|
||||||
const response = yield http.get('https://pecl.php.net/package/' + extension);
|
const response = yield http.get('https://pecl.php.net/package/' + extension);
|
||||||
if (response.message.statusCode == 200) {
|
if (response.message.statusCode == 200) {
|
||||||
|
let extension_version = 'stable';
|
||||||
|
if (version == '7.4') {
|
||||||
|
extension_version = 'alpha';
|
||||||
|
}
|
||||||
windows +=
|
windows +=
|
||||||
'try { Install-PhpExtension ' +
|
'try { Install-PhpExtension ' +
|
||||||
extension +
|
extension +
|
||||||
|
' -MinimumStability ' +
|
||||||
|
extension_version +
|
||||||
' } catch [Exception] { echo $_; echo "Could not install extension: "' +
|
' } catch [Exception] { echo $_; echo "Could not install extension: "' +
|
||||||
extension +
|
extension +
|
||||||
' }\n';
|
' }\n';
|
||||||
@ -112,6 +126,7 @@ function addExtension(extension_csv, version) {
|
|||||||
else {
|
else {
|
||||||
console.log('Cannot find pecl extension: ' + extension);
|
console.log('Cannot find pecl extension: ' + extension);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
linux += 'sudo apt autoremove -y';
|
linux += 'sudo apt autoremove -y';
|
||||||
@ -146,11 +161,15 @@ Run the script
|
|||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
|
// taking inputs
|
||||||
let version = process.env['php-version'];
|
let version = process.env['php-version'];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('php-version', { required: true });
|
version = core.getInput('php-version', { required: true });
|
||||||
}
|
}
|
||||||
console.log('Input: ' + version);
|
console.log('Input: ' + version);
|
||||||
|
if (version == '7.4') {
|
||||||
|
darwin = fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||||
|
}
|
||||||
let extension_csv = process.env['extension-csv'];
|
let extension_csv = process.env['extension-csv'];
|
||||||
if (!extension_csv) {
|
if (!extension_csv) {
|
||||||
extension_csv = core.getInput('extension-csv');
|
extension_csv = core.getInput('extension-csv');
|
||||||
@ -159,7 +178,7 @@ function run() {
|
|||||||
console.log('Input: ' + extension_csv);
|
console.log('Input: ' + extension_csv);
|
||||||
yield addExtension(extension_csv, version);
|
yield addExtension(extension_csv, version);
|
||||||
}
|
}
|
||||||
let os_version = process.platform;
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
yield createScript('darwin.sh', version);
|
yield createScript('darwin.sh', version);
|
||||||
yield exec_1.exec('sudo chmod a+x ' + version + 'darwin.sh');
|
yield exec_1.exec('sudo chmod a+x ' + version + 'darwin.sh');
|
||||||
|
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.0.0",
|
"version": "1.2.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setup-php",
|
"name": "setup-php",
|
||||||
"version": "1.0.0",
|
"version": "1.2.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "Setup php action",
|
"description": "Setup php action",
|
||||||
"main": "lib/setup-php.js",
|
"main": "lib/setup-php.js",
|
||||||
|
48
src/7.4.sh
Normal file
48
src/7.4.sh
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
brew fetch autoconf& brew fetch automake& brew fetch pcre& brew fetch libtool& brew fetch libpng& brew fetch webp& brew fetch jpeg& brew fetch freetype& brew fetch libxml2& brew fetch pkg-config& brew fetch krb5& brew fetch icu4c& brew fetch re2c& brew fetch bison& brew fetch libzip& brew fetch mcrypt& brew fetch zlib& brew fetch bzip2& brew fetch enchant
|
||||||
|
brew install autoconf automake pcre libtool libpng webp jpeg freetype libxml2 pkg-config krb5 icu4c re2c bison libzip mcrypt zlib bzip2 enchant >> /dev/null
|
||||||
|
brew link --force gettext
|
||||||
|
brew link --force bison
|
||||||
|
brew link --force openssl
|
||||||
|
brew link --force libxml2
|
||||||
|
brew link --force bzip2
|
||||||
|
echo 'export PATH="/usr/local/opt/bzip2/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/krb5/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/krb5/sbin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/bzip2/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/bison/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
echo 'export PATH="/Users/runner/.phpbrew/php/php-7.4.0RC1/bin:$PATH"' >> ~/.bash_profile
|
||||||
|
source ~/.bash_profile >> /dev/null
|
||||||
|
export LIBXML_LIBS="-L/usr/local/opt/libxml2/lib"
|
||||||
|
export LIBXML_CFLAGS="-I/usr/local/opt/libxml2/include"
|
||||||
|
export ENCHANT_LIBS="-L/usr/local/opt/enchant/lib"
|
||||||
|
export ENCHANT_CFLAGS="-I/usr/local/opt/enchant/include"
|
||||||
|
export FFI_LIBS="-L/usr/local/opt/libffi/lib"
|
||||||
|
export FFI_CFLAGS="-I/usr/local/opt/libffi/include"
|
||||||
|
export ICU_LIBS="-L/usr/local/opt/icu4c/lib"
|
||||||
|
export ICU_CFLAGS="-I/usr/local/opt/icu4c/include"
|
||||||
|
export KERBEROS_LIBS="-L/usr/local/opt/krb5/lib"
|
||||||
|
export KERBEROS_CFLAGS="-I/usr/local/opt/krb5/include"
|
||||||
|
export OPENSSL_LIBS="-L/usr/local/opt/openssl/lib"
|
||||||
|
export OPENSSL_CFLAGS="-I/usr/local/opt/openssl/include"
|
||||||
|
export READLINE_LIBS="-L/usr/local/opt/readline/lib"
|
||||||
|
export READLINE_CFLAGS="-I/usr/local/opt/readline/include"
|
||||||
|
export BZIP2_LIBS="-L/usr/local/opt/bzip2/lib"
|
||||||
|
export BZIP2_CFLAGS="-I/usr/local/opt/bzip2/include"
|
||||||
|
export PKG_CONFIG_PATH="/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/obzip2pt/libffi/lib/pkgconfig:/usr/local/opt/openssl@1.1/lib/pkgconfig:/usr/local/opt/readline/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/krb5/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig"
|
||||||
|
cd ~
|
||||||
|
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
|
||||||
|
chmod +x ./phpbrew
|
||||||
|
sudo mv phpbrew /usr/local/bin/phpbrew
|
||||||
|
sudo mkdir -p /opt/phpbrew
|
||||||
|
phpbrew init --root=/opt/phpbrew
|
||||||
|
echo "[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc" >> ~/.bashrc
|
||||||
|
source ~/.bashrc
|
||||||
|
phpbrew install -j 10 7.4.0RC1 +default +bz2="$(brew --prefix bzip2)" +zlib="$(brew --prefix zlib)" -openssl -- --with-libxml
|
||||||
|
phpbrew switch php-7.4.0RC1 >> /dev/null
|
||||||
|
sudo mkdir -p /usr/local/bin
|
||||||
|
sudo ln -sf /Users/runner/.phpbrew/php/php-7.4.0RC1/bin/php /usr/local/bin/php
|
||||||
|
brew install composer
|
@ -1,8 +1,6 @@
|
|||||||
echo $1
|
echo $1
|
||||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
|
||||||
brew unlink php
|
brew unlink php
|
||||||
brew tap exolnet/homebrew-deprecated
|
brew tap exolnet/homebrew-deprecated
|
||||||
brew tap homebrew/homebrew-php
|
|
||||||
brew install php@$1
|
brew install php@$1
|
||||||
brew link --force --overwrite php@$1
|
brew link --force --overwrite php@$1
|
||||||
curl -sS https://getcomposer.org/installer | php
|
curl -sS https://getcomposer.org/installer | php
|
||||||
|
@ -7,6 +7,7 @@ import * as fs from 'fs';
|
|||||||
/*
|
/*
|
||||||
Read the scripts
|
Read the scripts
|
||||||
*/
|
*/
|
||||||
|
let os_version = process.platform;
|
||||||
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
let darwin = fs.readFileSync(path.join(__dirname, '../src/darwin.sh'), 'utf8');
|
||||||
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
let linux = fs.readFileSync(path.join(__dirname, '../src/linux.sh'), 'utf8');
|
||||||
let windows = fs.readFileSync(
|
let windows = fs.readFileSync(
|
||||||
@ -24,7 +25,7 @@ async function asyncForEach(array: any, callback: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Enable functions which are installed but not enabled
|
Enable extensions which are installed but not enabled
|
||||||
*/
|
*/
|
||||||
async function enableExtension(extension: string) {
|
async function enableExtension(extension: string) {
|
||||||
windows += `try {
|
windows += `try {
|
||||||
@ -38,10 +39,11 @@ async function enableExtension(extension: string) {
|
|||||||
echo $_
|
echo $_
|
||||||
}\n`;
|
}\n`;
|
||||||
|
|
||||||
let shell_code = `ext_dir=$(php -i | grep "extension_dir" | sed -e "s|.*=>\s*||")
|
let shell_code = `ext_dir=$(php-config --extension-dir)
|
||||||
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
enabled=$(php -r "if (in_array('${extension}', get_loaded_extensions())) {echo 'yes';} else {echo 'no';}")
|
||||||
if [ "$enabled" == 'no' ] && [ test -f "$ext_dir/${extension}.so" ]; then
|
if [ "$enabled" = "no" ] && [ -e "$ext_dir/${extension}.so" ]; then
|
||||||
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*:\s*||"'
|
echo "extension=${extension}.so" >> 'php -i | grep "Loaded Configuration" | sed -e "s|.*=>\s*||"'
|
||||||
|
echo "${extension} enabled"
|
||||||
fi\n`;
|
fi\n`;
|
||||||
linux += shell_code;
|
linux += shell_code;
|
||||||
darwin += shell_code;
|
darwin += shell_code;
|
||||||
@ -63,7 +65,11 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
windows += '\n';
|
windows += '\n';
|
||||||
darwin += '\n';
|
darwin += '\n';
|
||||||
await asyncForEach(extensions, async function(extension: string) {
|
await asyncForEach(extensions, async function(extension: string) {
|
||||||
|
// add script to enable extension is already installed along with php
|
||||||
enableExtension(extension);
|
enableExtension(extension);
|
||||||
|
|
||||||
|
// else add script to attempt to install the extension
|
||||||
|
if (os_version == 'linux') {
|
||||||
linux +=
|
linux +=
|
||||||
'sudo apt install -y php' +
|
'sudo apt install -y php' +
|
||||||
version +
|
version +
|
||||||
@ -74,6 +80,8 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
'-' +
|
'-' +
|
||||||
extension +
|
extension +
|
||||||
'"\n';
|
'"\n';
|
||||||
|
} else {
|
||||||
|
// check if pecl extension exists
|
||||||
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
const http = new httpm.HttpClient('shivammathur/php-setup', [], {
|
||||||
allowRetries: true,
|
allowRetries: true,
|
||||||
maxRetries: 2
|
maxRetries: 2
|
||||||
@ -82,9 +90,15 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
'https://pecl.php.net/package/' + extension
|
'https://pecl.php.net/package/' + extension
|
||||||
);
|
);
|
||||||
if (response.message.statusCode == 200) {
|
if (response.message.statusCode == 200) {
|
||||||
|
let extension_version = 'stable';
|
||||||
|
if (version == '7.4') {
|
||||||
|
extension_version = 'alpha';
|
||||||
|
}
|
||||||
windows +=
|
windows +=
|
||||||
'try { Install-PhpExtension ' +
|
'try { Install-PhpExtension ' +
|
||||||
extension +
|
extension +
|
||||||
|
' -MinimumStability ' +
|
||||||
|
extension_version +
|
||||||
' } catch [Exception] { echo $_; echo "Could not install extension: "' +
|
' } catch [Exception] { echo $_; echo "Could not install extension: "' +
|
||||||
extension +
|
extension +
|
||||||
' }\n';
|
' }\n';
|
||||||
@ -97,6 +111,7 @@ async function addExtension(extension_csv: string, version: string) {
|
|||||||
} else {
|
} else {
|
||||||
console.log('Cannot find pecl extension: ' + extension);
|
console.log('Cannot find pecl extension: ' + extension);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
linux += 'sudo apt autoremove -y';
|
linux += 'sudo apt autoremove -y';
|
||||||
}
|
}
|
||||||
@ -117,7 +132,6 @@ async function createScript(filename: string, version: string) {
|
|||||||
if (error) {
|
if (error) {
|
||||||
return console.log(error);
|
return console.log(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('The file was saved!');
|
console.log('The file was saved!');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -127,12 +141,17 @@ Run the script
|
|||||||
*/
|
*/
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
|
// taking inputs
|
||||||
let version = process.env['php-version'];
|
let version = process.env['php-version'];
|
||||||
if (!version) {
|
if (!version) {
|
||||||
version = core.getInput('php-version', {required: true});
|
version = core.getInput('php-version', {required: true});
|
||||||
}
|
}
|
||||||
console.log('Input: ' + version);
|
console.log('Input: ' + version);
|
||||||
|
|
||||||
|
if (version == '7.4') {
|
||||||
|
darwin = fs.readFileSync(path.join(__dirname, '../src/7.4.sh'), 'utf8');
|
||||||
|
}
|
||||||
|
|
||||||
let extension_csv = process.env['extension-csv'];
|
let extension_csv = process.env['extension-csv'];
|
||||||
if (!extension_csv) {
|
if (!extension_csv) {
|
||||||
extension_csv = core.getInput('extension-csv');
|
extension_csv = core.getInput('extension-csv');
|
||||||
@ -142,7 +161,7 @@ async function run() {
|
|||||||
await addExtension(extension_csv, version);
|
await addExtension(extension_csv, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
let os_version = process.platform;
|
// check the os version and run the respective script
|
||||||
if (os_version == 'darwin') {
|
if (os_version == 'darwin') {
|
||||||
await createScript('darwin.sh', version);
|
await createScript('darwin.sh', version);
|
||||||
await exec('sudo chmod a+x ' + version + 'darwin.sh');
|
await exec('sudo chmod a+x ' + version + 'darwin.sh');
|
||||||
|
@ -2,6 +2,10 @@ param (
|
|||||||
[Parameter(Mandatory=$true)][string]$version = "7.3"
|
[Parameter(Mandatory=$true)][string]$version = "7.3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if($version -eq '7.4') {
|
||||||
|
$version = '7.4RC1'
|
||||||
|
}
|
||||||
|
|
||||||
echo "Installing NuGet"
|
echo "Installing NuGet"
|
||||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
||||||
if($version -lt '7.0') {
|
if($version -lt '7.0') {
|
||||||
@ -16,17 +20,20 @@ echo "Installing PhpManager"
|
|||||||
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
Install-Module -Name PhpManager -Force -Scope CurrentUser
|
||||||
echo "Installing PHP"
|
echo "Installing PHP"
|
||||||
Uninstall-Php C:\tools\php
|
Uninstall-Php C:\tools\php
|
||||||
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC
|
Install-Php -Version $version -Architecture x86 -ThreadSafe $true -Path C:\tools\php$version -TimeZone UTC -InitialPhpIni Production
|
||||||
echo "Switch PHP"
|
echo "Switch PHP"
|
||||||
(Get-PhpSwitcher).targets
|
(Get-PhpSwitcher).targets
|
||||||
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
|
Initialize-PhpSwitcher -Alias C:\tools\php -Scope CurrentUser -Force
|
||||||
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
|
Add-PhpToSwitcher -Name $version -Path C:\tools\php$version -Force
|
||||||
Switch-Php $version -Force
|
Switch-Php $version -Force
|
||||||
echo "Housekeeping in PHP.ini, enabling openssl"
|
echo "Housekeeping in PHP.ini, enabling openssl"
|
||||||
Move-item -Path C:\tools\php$version\php.ini-production -Destination C:\tools\php$version\php.ini -Force
|
|
||||||
Add-Content C:\tools\php$version\php.ini "date.timezone = 'UTC'"
|
Add-Content C:\tools\php$version\php.ini "date.timezone = 'UTC'"
|
||||||
Set-PhpIniKey extension_dir C:\tools\php$version\ext
|
Set-PhpIniKey extension_dir C:\tools\php$version\ext
|
||||||
Enable-PhpExtension openssl
|
if($version -lt '7.4') {
|
||||||
|
Enable-PhpExtension openssl
|
||||||
|
} else {
|
||||||
|
Add-Content C:\tools\php$version\php.ini "extension=php_openssl.dll"
|
||||||
|
}
|
||||||
echo "Installing Composer"
|
echo "Installing Composer"
|
||||||
Install-Composer -Scope System -Path C:\tools\php
|
Install-Composer -Scope System -Path C:\tools\php
|
||||||
php -v
|
php -v
|
||||||
|
Reference in New Issue
Block a user