-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (79 loc) · 2.93 KB
/
build-windows-binary.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Build binary for windows x86_64
on:
release:
types: [ created ]
workflow_dispatch:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BINARY_NAME: 'svgtinyps-windows-x86_64.exe'
COMPILE_PHP_VERSION: "8.3"
jobs:
build-windows-binary:
runs-on: windows-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Cache build dependencies
uses: actions/cache@v4
with:
path: build/
key: build-deps-php${{ env.COMPILE_PHP_VERSION }}-${{ runner.os }}-${{ runner.arch }}
- name: Get composer cache directory
id: composer-cache
run: |
$dir = composer config cache-files-dir
echo "dir=$dir" >> $env:GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**\\composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Composer install
run: composer install --prefer-dist --no-progress --optimize-autoloader
- name: Build .phar
run: composer box compile
- name: Checkout static-php-cli
working-directory: build
shell: pwsh
run: |
if (Test-Path "static-php-cli") {
Set-Location "static-php-cli"
git pull origin main
} else {
git clone --depth 1 https://github.com/crazywhalecc/static-php-cli.git
}
- name: Composer update
working-directory: build/static-php-cli/
run: composer update --no-dev --classmap-authoritative
- name: SPC doctor
working-directory: build/static-php-cli/
run: ./bin/spc doctor
- name: SPC Download
working-directory: build/static-php-cli/
run: ./bin/spc download --with-php="${{ env.COMPILE_PHP_VERSION }}" --for-extensions="dom,phar,zlib" --prefer-pre-built
- name: SPC Switch PHP version
working-directory: build/static-php-cli/
run: ./bin/spc switch-php-version "${{ env.COMPILE_PHP_VERSION }}"
- name: SPC Build
working-directory: build/static-php-cli/
run: ./bin/spc build --build-micro "dom,phar,zlib"
- name: PHP Micro combine
working-directory: build/static-php-cli/
run: ./bin/spc micro:combine "../bin/svgtinyps.phar" --output="../bin/${{ env.BINARY_NAME }}"
- if: ${{ github.event_name == 'workflow_dispatch' }}
name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}
path: build/bin/${{ env.BINARY_NAME }}
- if: ${{ github.event_name != 'workflow_dispatch' }}
name: Upload binaries to release
uses: softprops/action-gh-release@v2
with:
files: build/bin/${{ env.BINARY_NAME }}