update #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-php-cli-windows | |
on: | |
push: | |
pull_request: | |
env: | |
BUILD_PHP_VERSION: 8.2.13 | |
jobs: | |
windows-native: | |
if: 1 | |
runs-on: windows-2022 | |
# windows-latest, windows-2022, windows-2019 | |
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#choosing-github-hosted-runners | |
strategy: | |
matrix: | |
php-version: | |
# - "8.2.13" | |
# - "8.1.27" | |
- "8.3.3" | |
steps: | |
- name: Prepare git | |
run: | | |
git config --global core.autocrlf false | |
git config --global core.eol lf | |
env | |
ipconfig | |
uname -a | |
pwd | |
ipconfig /all | |
- uses: actions/checkout@v4 | |
- name: set php version | |
# 参考文档: https://docs.github.com/zh/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell | |
shell: bash | |
run: | | |
echo "BUILD_PHP_VERSION=${{ matrix.php-version }}" >> $GITHUB_ENV | |
- name: Prepare submodule | |
run: | | |
ipconfig /all | |
# git submodule update --init | |
- uses: msys2/setup-msys2@v2 | |
- name: Install curl and download VisualStudioSetup.exe | |
shell: msys2 {0} | |
run: | | |
pacman -Syy --noconfirm curl | |
# curl -Lo VisualStudioSetup.exe 'https://c2rsetup.officeapps.live.com/c2r/downloadVS.aspx?sku=community&channel=Release&version=VS2022' | |
curl -Lo VisualStudioSetup.exe 'https://aka.ms/vs/17/release/vs_community.exe' | |
curl -Lo vs_buildtools.exe 'https://aka.ms/vs/17/release/vs_buildtools.exe' | |
ls -lha | |
pwd | |
- name: install VS2022 | |
shell: cmd | |
run: | | |
dir | |
VisualStudioSetup.exe /? | |
start /wait vs_buildtools.exe --norestart --force --passive --wait > nul | |
echo %errorlevel% | |
start /wait VisualStudioSetup.exe --locale en-US --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.Roslyn.Compiler --add Microsoft.Component.MSBuild --add Microsoft.VisualStudio.Component.CoreBuildTools --add Microsoft.VisualStudio.Workload.MSBuildTools --path install="D:\VS" --path cache="D:\VS\cache" --path shared="D:\VS\shared" --norestart --force --passive --wait > nul | |
echo %errorlevel% | |
- uses: microsoft/setup-msbuild@v2 | |
with: | |
msbuild-architecture: x64 | |
- name: Configure | |
if: 0 | |
run: | | |
bash ./sapi/scripts/cygwin/cygwin-config.sh | |
- name: Build | |
if: 0 | |
run: | | |
bash ./sapi/scripts/cygwin/cygwin-build.sh | |
- name: Show Build Result | |
if: 0 | |
run: | | |
./bin/php.exe -v | |
./bin/php.exe -m | |
./bin/php.exe --ri pdo_pgsql | |
./bin/php.exe --ri swoole | |
./bin/php.exe -r "echo PHP_VERSION;" | |
- name: get app version with bash | |
if: 0 | |
# 参考 https://github.com/marketplace/actions/install-cygwin | |
shell: C:\cygwin\bin\bash.EXE --noprofile --norc -e -o pipefail -o igncr {0} | |
# shell: C:\cygwin\bin\bash.EXE --login --noprofile --norc -e -o pipefail -o igncr {0} | |
run: | | |
./bin/php.exe -v | awk '{print $2}' | |
APP_VERSION=$(./bin/php.exe -v | head -n 1 | awk '{print $2}') | |
echo $APP_VERSION | |
echo "APP_VERSION=${APP_VERSION}" >> $GITHUB_ENV | |
- name: get app version with PowerShell | |
if: 0 | |
run: | | |
./bin/php.exe -v | |
$cmdOutput=./bin/php.exe -v | |
$cmdOutput=$cmdOutput | select -first 1 | |
$cmdOutput -match "(\d{1,2}\.\d{1,2}\.\d{1,2})" | |
$CYGWIN_APP_VERSION=$Matches[1] | |
echo $CYGWIN_APP_VERSION | |
echo "CYGWIN_APP_VERSION=$CYGWIN_APP_VERSION" >> $Env:GITHUB_ENV | |
# 参考 https://github.com/orgs/community/discussions/26641 | |
# echo "APP_VERSION=${APP_VERSION}" >> $Env:GITHUB_ENV | |
# echo "APP_VERSION=$APP_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append | |
# Add-Content -Path $env:GITHUB_ENV -Value "name=$value" | |
# Add-Content -Path $env:GITHUB_ENV -Value "APP_VERSION=$APP_VERSION" | |
- name: Archive | |
if: 0 | |
run: | | |
bash ./sapi/scripts/cygwin/cygwin-archive.sh | |
- name: production artifacts | |
if: 0 | |
uses: actions/upload-artifact@v4 | |
with: | |
name: php-cli-v${{ env.APP_VERSION }}-cygwin-x64 | |
retention-days: 90 | |
path: php-cli-v${{ env.APP_VERSION }}-cygwin-x64.zip | |
- name: gh release | |
uses: softprops/action-gh-release@v2 | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: php-cli-v${{ env.APP_VERSION }}-cygwin-x64.zip |