Skip to content

Commit 1bb3a91

Browse files
committed
chore(.github): update workflows/windows.yml
1 parent d31b77d commit 1bb3a91

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

.github/workflows/install.ps1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ if (-not (Test-Path "C:\php\$dname1")) {
1818
}
1919

2020
# PHP releases
21-
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json"
21+
if (-not (Test-Path C:\php\releases.json)) {
22+
echo "Download: https://windows.php.net/downloads/releases/releases.json"
23+
Invoke-WebRequest "https://windows.php.net/downloads/releases/releases.json" -OutFile "C:\php\releases.json"
24+
}
2225
$php_version = (Get-Content -Path "C:\php\releases.json" | ConvertFrom-Json | ForEach-Object {
2326
if ($_."$env:PHP_VER") {
2427
return $_."$env:PHP_VER".version

.github/workflows/windows.yaml

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
name: Windows
22

3-
on: [push]
3+
on:
4+
push:
5+
release:
6+
types: [published]
47

58
env:
69
PHP_EXT: snappy
10+
PHP_EXT_VERSION: ${{ github.event.release.tag_name }}
711
BIN_SDK_VER: 2.3.0
812

913
jobs:
@@ -48,32 +52,81 @@ jobs:
4852
steps:
4953
- name: Checkout repository
5054
uses: actions/checkout@v4
55+
with:
56+
persist-credentials: false
5157

5258
- name: Checkout submodule
5359
run: .\.github\workflows\submodule.ps1
60+
shell: pwsh
5461
if: ${{ matrix.library == '' }}
5562
- name: Install dependency library
5663
run: .\.github\workflows\vcpkg.ps1
64+
shell: pwsh
5765
env:
5866
VCPKG_LIBRARY: snappy
5967
if: ${{ matrix.library }}
6068

69+
- uses: actions/cache@v4
70+
with:
71+
path: |
72+
C:\php\php-*.zip
73+
key: ${{ runner.os }}-php
74+
6175
- name: Install build command
6276
run: .\.github\workflows\install.ps1
77+
shell: pwsh
6378

6479
- name: Build
6580
run: .\.github\workflows\build.ps1
81+
shell: pwsh
6682

6783
- name: Test
6884
run: .\.github\workflows\test.ps1
85+
shell: pwsh
6986
env:
7087
REPORT_EXIT_STATUS: 1
7188
NO_INTERACTION: 1
7289

73-
- name: Store artifact DLL
90+
- if: ${{ github.event_name == 'release' }}
91+
name: Archive DLL
92+
run: |-
93+
Copy-Item .\php_${{ env.PHP_EXT }}.dll .\$env:EXT_NAME.dll
94+
Compress-Archive -Path .\$env:EXT_NAME.dll -Destination .\$env:EXT_NAME.zip
95+
shell: pwsh
96+
env:
97+
EXT_NAME: php_${{ env.PHP_EXT }}-${{ env.PHP_EXT_VERSION }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}-${{ matrix.arch }}
98+
99+
- if: ${{ github.event_name == 'release' }}
100+
name: Store archive DLL
74101
uses: actions/upload-artifact@v4
75102
with:
76-
name: php_${{ env.PHP_EXT }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}-${{ matrix.arch }}
77-
path: .\php_${{ env.PHP_EXT }}.dll
103+
name: ${{ env.PHP_EXT_VERSION }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}-${{ matrix.arch }}
104+
path: .\php_${{ env.PHP_EXT }}-${{ env.PHP_EXT_VERSION }}-${{ matrix.php }}-${{ matrix.ts }}-${{ matrix.vs }}-${{ matrix.arch }}.zip
78105
overwrite: true
79-
if: ${{ matrix.library == '' }}
106+
107+
release:
108+
permissions:
109+
contents: write
110+
needs: ci
111+
112+
runs-on: ubuntu-latest
113+
114+
if: ${{ github.event_name == 'release' }}
115+
116+
steps:
117+
- name: Checkout
118+
uses: actions/checkout@v4
119+
with:
120+
persist-credentials: false
121+
122+
- name: Get artifacts
123+
uses: actions/download-artifact@v4
124+
with:
125+
path: artifacts
126+
merge-multiple: true
127+
128+
- name: Upload artifacts
129+
run: gh release upload ${{ env.PHP_EXT_VERSION }} artifacts/php* --clobber
130+
shell: bash
131+
env:
132+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)