From 65a99b3c3d157dd339d82dbd01897018581a312c Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Tue, 13 Apr 2021 16:17:47 +0530 Subject: [PATCH] Add a master release --- .github/workflows/php80.yml | 33 +++---------------- .github/workflows/phpmaster.yml | 37 ++++----------------- .gitignore | 1 - scripts/Get-Php.ps1 | 58 +++++++++++++++++++++++++++++++++ scripts/Get-PhpNightly.ps1 | 57 ++++++++++++++++++++++++++++++++ 5 files changed, 125 insertions(+), 61 deletions(-) delete mode 100644 .gitignore create mode 100644 scripts/Get-Php.ps1 create mode 100644 scripts/Get-PhpNightly.ps1 diff --git a/.github/workflows/php80.yml b/.github/workflows/php80.yml index 4f3b88a..25cfe9b 100644 --- a/.github/workflows/php80.yml +++ b/.github/workflows/php80.yml @@ -106,47 +106,22 @@ jobs: - uses: actions/download-artifact@v2 with: path: builds - - name: Upload to bintray - env: - BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} - BINTRAY_USER: shivammathur - BINTRAY_REPO: php - GITHUB_REPOSITORY: ${{ github.repository }} + - name: Stage files run: | - VERSION='8.0' - curl \ - --user "$BINTRAY_USER":"$BINTRAY_KEY" \ - --header "Content-Type: application/json" \ - --data " \ - {\"name\": \"$VERSION-windows\", \ - \"vcs_url\": \"$GITHUB_REPOSITORY\", \ - \"licenses\": [\"MIT\"], \ - \"public_download_numbers\": true, \ - \"public_stats\": true \ - }" \ - https://api.bintray.com/packages/"$BINTRAY_USER"/"$BINTRAY_REPO" || true mkdir uploads for file in ./builds/*/*; do mv $file ./uploads/ done - cd uploads || exit - rm -rf *-src-*.zip || true - for file in ./*; do - curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -X DELETE https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/"$file" || true - curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -T "$file" https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/"$VERSION"-windows/$VERSION/"$file" || true - done - curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -X POST https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/"$VERSION"-windows/"$VERSION"/publish || true + rm -rf uploads/*-src-*.zip || true - name: Update release run: | set -x - curl -sLO http://dl.bintray.com/shivammathur/php/Get-PhpNightly.ps1 - curl -sLO http://dl.bintray.com/shivammathur/php/Get-Php.ps1 assets=() for asset in ./uploads/*; do assets+=("$asset") done - assets+=("./Get-PhpNightly.ps1") - assets+=("./Get-Php.ps1") + assets+=("./scripts/Get-PhpNightly.ps1") + assets+=("./scripts/Get-Php.ps1") gh release delete "php8.0" -y || true gh release create "php8.0" "${assets[@]}" -t "php8.0" -n "php8.0" env: diff --git a/.github/workflows/phpmaster.yml b/.github/workflows/phpmaster.yml index 693eb64..f0310ff 100644 --- a/.github/workflows/phpmaster.yml +++ b/.github/workflows/phpmaster.yml @@ -115,50 +115,25 @@ jobs: - uses: actions/download-artifact@v2 with: path: builds - - name: Upload to bintray - env: - BINTRAY_KEY: ${{ secrets.BINTRAY_KEY }} - BINTRAY_USER: shivammathur - BINTRAY_REPO: php - GITHUB_REPOSITORY: ${{ github.repository }} + - name: Stage files run: | - VERSION='master' - curl \ - --user "$BINTRAY_USER":"$BINTRAY_KEY" \ - --header "Content-Type: application/json" \ - --data " \ - {\"name\": \"$VERSION-windows\", \ - \"vcs_url\": \"$GITHUB_REPOSITORY\", \ - \"licenses\": [\"MIT\"], \ - \"public_download_numbers\": true, \ - \"public_stats\": true \ - }" \ - https://api.bintray.com/packages/"$BINTRAY_USER"/"$BINTRAY_REPO" || true mkdir uploads for file in ./builds/*/*; do mv $file ./uploads/ done - ( - cd uploads || exit - rm -rf *-src-*.zip || true - for file in ./*; do - curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -X DELETE https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/"$file" || true - curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -T "$file" https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/"$VERSION"-windows/$VERSION/"$file" || true - done - curl --user "$BINTRAY_USER":"$BINTRAY_KEY" -X POST https://api.bintray.com/content/"$BINTRAY_USER"/"$BINTRAY_REPO"/"$VERSION"-windows/"$VERSION"/publish || true - ) + rm -rf uploads/*-src-*.zip || true - name: Update release run: | set -x - curl -sLO http://dl.bintray.com/shivammathur/php/Get-PhpNightly.ps1 - curl -sLO http://dl.bintray.com/shivammathur/php/Get-Php.ps1 assets=() for asset in ./uploads/*; do assets+=("$asset") done - assets+=("./Get-PhpNightly.ps1") - assets+=("./Get-Php.ps1") + assets+=("./scripts/Get-PhpNightly.ps1") + assets+=("./scripts/Get-Php.ps1") gh release delete "php8.1" -y || true gh release create "php8.1" "${assets[@]}" -t "php8.1" -n "php8.1" + gh release delete "master" -y || true + gh release create "master" "${assets[@]}" -t "master" -n "master" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 7106b9d..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -Get-PhpNightly.ps1 \ No newline at end of file diff --git a/scripts/Get-Php.ps1 b/scripts/Get-Php.ps1 new file mode 100644 index 0000000..50b0ce1 --- /dev/null +++ b/scripts/Get-Php.ps1 @@ -0,0 +1,58 @@ +<# +.Synopsis +Installs PHP nightly. +.Description +Download and installs a nightly version of PHP. +.Parameter Architecture +The architecture of the PHP to be installed (x86 for 32-bit, x64 for 64-bit). +.Parameter ThreadSafe +A boolean value to indicate if the Thread-Safe version should be installed or not. +You usually install the ThreadSafe version if you plan to use PHP with Apache, or the NonThreadSafe version if you'll use PHP in CGI mode. +.Parameter Path +The path of the directory where PHP will be installed. +.Parameter Version +The PHP version + #> +param ( + [Parameter(Mandatory = $true, Position = 1, HelpMessage = 'Architecture of the PHP to be installed (x86 for 32-bit, x64 for 64-bit)')] + [ValidateSet('x86', 'x64')] + [string] $Architecture, + [Parameter(Mandatory = $true, Position = 2, HelpMessage = 'Install a Thread-Safe version?')] + [bool] $ThreadSafe, + [Parameter(Mandatory = $true, Position = 3, HelpMessage = 'The path of the directory where PHP will be installed')] + [ValidateLength(1, [int]::MaxValue)] + [string] $Path, + [Parameter(Mandatory = $false, Position = 4, HelpMessage = 'The PHP version')] + [ValidateLength(1, [int]::MaxValue)] + [string] $Version = '8.0' +) +if(-not(Test-Path $Path)) { + New-Item -Type 'directory' $Path +} +$ts = '-nts' +if($ThreadSafe) { + $ts = '' +} +$branch = 'master' +if($Version -eq '8.0') { + $branch = 'PHP-8.0' +} +$semver = Invoke-RestMethod https://raw.githubusercontent.com/php/php-src/$branch/main/php_version.h | Where-Object { $_ -match 'PHP_VERSION "(.*)"' } | Foreach-Object {$Matches[1]} +Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-builder-windows/releases/download/php$Version/php-$semver$ts-Win32-vs16-$Architecture.zip" -OutFile $Path\master.zip +Expand-Archive -Path $Path\master.zip -DestinationPath $Path -Force +Copy-Item $Path\php.ini-production -Destination $Path\php.ini +Move-Item -Path $Path\ext\php_oci8_12c.dll -Destination $Path\ext\php_oci8.dll -Force +$ts = 'nts' +if($ThreadSafe) { + $ts = 'ts' +} +"xdebug", "pcov" | ForEach-Object { Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-extensions-windows/releases/latest/download/php$Version`_$ts`_$Architecture`_$_.dll" -OutFile $Path"\ext\php`_$_.dll" } +$ini_content = @" +extension_dir=$Path\ext +default_charset=UTF-8 +zend_extension=php_opcache.dll +opcache.enable=1 +opcache.jit_buffer_size=256M +opcache.jit=1235 +"@ +Add-Content -Path $Path\php.ini -Value $ini_content diff --git a/scripts/Get-PhpNightly.ps1 b/scripts/Get-PhpNightly.ps1 new file mode 100644 index 0000000..1706d29 --- /dev/null +++ b/scripts/Get-PhpNightly.ps1 @@ -0,0 +1,57 @@ +<# +.Synopsis +Installs PHP nightly. +.Description +Download and installs a nightly version of PHP. +.Parameter Architecture +The architecture of the PHP to be installed (x86 for 32-bit, x64 for 64-bit). +.Parameter ThreadSafe +A boolean value to indicate if the Thread-Safe version should be installed or not. +You usually install the ThreadSafe version if you plan to use PHP with Apache, or the NonThreadSafe version if you'll use PHP in CGI mode. +.Parameter Path +The path of the directory where PHP will be installed. +.Parameter Version +The PHP version + #> +param ( + [Parameter(Mandatory = $true, Position = 1, HelpMessage = 'Architecture of the PHP to be installed (x86 for 32-bit, x64 for 64-bit)')] + [ValidateSet('x86', 'x64')] + [string] $Architecture, + [Parameter(Mandatory = $true, Position = 2, HelpMessage = 'Install a Thread-Safe version?')] + [bool] $ThreadSafe, + [Parameter(Mandatory = $true, Position = 3, HelpMessage = 'The path of the directory where PHP will be installed')] + [ValidateLength(1, [int]::MaxValue)] + [string] $Path, + [Parameter(Mandatory = $false, Position = 4, HelpMessage = 'The PHP version')] + [ValidateLength(1, [int]::MaxValue)] + [string] $Version = '8.1' +) +if(-not(Test-Path $Path)) { + New-Item -Type 'directory' $Path +} +$ts = '-nts' +if($ThreadSafe) { + $ts = '' +} +if($Version -eq '8.0') { + Install-Php -Version $Version -Architecture $Architecture -ThreadSafe $ThreadSafe -InstallVC -Path $Path -TimeZone UTC -InitialPhpIni Production -Force +} else { + Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-builder-windows/releases/download/php$Version/php-$Version.0-dev$ts-Win32-vs16-$Architecture.zip" -OutFile $Path\master.zip + Expand-Archive -Path $Path\master.zip -DestinationPath $Path -Force + Copy-Item $Path\php.ini-production -Destination $Path\php.ini +} +Move-Item -Path $Path\ext\php_oci8_12c.dll -Destination $Path\ext\php_oci8.dll -Force +$ts = 'nts' +if($ThreadSafe) { + $ts = 'ts' +} +"xdebug", "pcov" | ForEach-Object { Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-extensions-windows/releases/latest/download/php$Version`_$ts`_$Architecture`_$_.dll" -OutFile $Path"\ext\php`_$_.dll" } +$ini_content = @" +extension_dir=$Path\ext +default_charset=UTF-8 +zend_extension=php_opcache.dll +opcache.enable=1 +opcache.jit_buffer_size=256M +opcache.jit=1235 +"@ +Add-Content -Path $Path\php.ini -Value $ini_content