Skip to content

Commit eb953a1

Browse files
authored
Create pack-libs.yml
1 parent 233d9a5 commit eb953a1

File tree

1 file changed

+141
-0
lines changed

1 file changed

+141
-0
lines changed

.github/workflows/pack-libs.yml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: PHP Pack Lib
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types:
7+
- published
8+
pull_request:
9+
branches: [ "main" ]
10+
paths:
11+
- 'src/**'
12+
- 'config/**'
13+
- '.github/workflows/test-pack-lib.yml'
14+
- 'bin/**'
15+
16+
permissions:
17+
contents: read
18+
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
22+
jobs:
23+
build:
24+
name: "Pack Lib Test (${{ matrix.lib }} for ${{ matrix.runner }})"
25+
runs-on: ${{ matrix.runner }}
26+
timeout-minutes: 120
27+
strategy:
28+
matrix:
29+
runner:
30+
- ubuntu-latest
31+
- ubuntu-20.04
32+
- macos-13
33+
- windows-latest
34+
- macos-14
35+
lib:
36+
- zlib
37+
- pkg-config
38+
- bzip2
39+
- gmp
40+
exclude:
41+
- { runner: "windows-latest", lib: "pkg-config" }
42+
- { runner: "windows-latest", lib: "gmp" }
43+
fail-fast: false
44+
steps:
45+
- name: "Process env string"
46+
id: process-env
47+
shell: bash
48+
run: |
49+
case "${{ matrix.runner }}" in
50+
ubuntu-latest)
51+
echo "OS=linux" >> "$GITHUB_OUTPUT"
52+
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT"
53+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
54+
;;
55+
ubuntu-20.04)
56+
echo "OS=linux" >> "$GITHUB_OUTPUT"
57+
echo "ARCH=aarch64" >> "$GITHUB_OUTPUT"
58+
echo CMD="SPC_USE_ARCH=aarch64 bin/spc-alpine-docker" >> "$GITHUB_OUTPUT"
59+
;;
60+
windows-latest)
61+
echo "OS=windows" >> "$GITHUB_OUTPUT"
62+
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT"
63+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
64+
;;
65+
macos-13)
66+
echo "OS=darwin" >> "$GITHUB_OUTPUT"
67+
echo "ARCH=x86_64" >> "$GITHUB_OUTPUT"
68+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
69+
;;
70+
macos-14)
71+
echo "OS=darwin" >> "$GITHUB_OUTPUT"
72+
echo "ARCH=aarch64" >> "$GITHUB_OUTPUT"
73+
echo "CMD=bin/spc" >> "$GITHUB_OUTPUT"
74+
;;
75+
esac
76+
77+
- name: "Checkout remote"
78+
if: github.repository != 'crazywhalecc/static-php-cli'
79+
uses: actions/checkout@v4
80+
with:
81+
repository: crazywhalecc/static-php-cli
82+
83+
- name: "Setup PHP"
84+
if: matrix.runner != 'ubuntu-20.04'
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: 8.2
88+
tools: pecl, composer
89+
extensions: curl, openssl, mbstring
90+
ini-values: memory_limit=-1
91+
92+
- name: "Cache composer packages"
93+
id: composer-cache
94+
uses: actions/cache@v4
95+
with:
96+
path: vendor
97+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
98+
restore-keys: |
99+
${{ runner.os }}-php
100+
101+
# Cache downloaded source
102+
- id: cache-download
103+
uses: actions/cache@v4
104+
with:
105+
path: downloads
106+
key: pack-lib-dependencies
107+
108+
- name: "Install Dependencies"
109+
if: matrix.runner != 'ubuntu-20.04'
110+
run: composer update -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
111+
112+
- run: ${{ steps.process-env.outputs.CMD }} doctor --auto-fix
113+
114+
- run: ${{ steps.process-env.outputs.CMD }} download --for-libs="${{ matrix.lib }}" --debug --retry=5 --shallow-clone
115+
116+
- name: "Download pre-built pkg-config for ${{ matrix.runner }}"
117+
if: matrix.runner != 'windows-latest' && matrix.lib != 'pkg-config'
118+
run: |
119+
${{ steps.process-env.outputs.CMD }} download --for-libs="pkg-config" --debug --retry=5 --shallow-clone --prefer-pre-built
120+
${{ steps.process-env.outputs.CMD }} build:libs pkg-config --debug
121+
122+
- if: matrix.runner != 'windows-latest' || matrix.lib != 'pkg-config'
123+
run: ${{ steps.process-env.outputs.CMD }} dev:pack-lib --debug ${{ matrix.lib }}
124+
125+
- name: "Upload packed lib (${{ matrix.lib }} for ${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }})"
126+
uses: actions/upload-artifact@v4
127+
with:
128+
path: dist/${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}.txz
129+
name: ${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}
130+
131+
- name: "Upload to current release event"
132+
if: github.repository == 'static-php/static-php-cli-hosted' && startsWith(github.ref, 'refs/tags/')
133+
uses: softprops/action-gh-release@v1
134+
with:
135+
files: dist/${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}.txz
136+
137+
- name: "Update latest release of hosted repo"
138+
if: github.repository == 'static-php/static-php-cli-hosted' && github.event_name == 'workflow_dispatch'
139+
run: |
140+
ref="$(gh release view --repo static-php/static-php-cli-hosted --json tagName --jq '.tagName')"
141+
gh release upload "$ref" "dist/${{ matrix.lib }}-${{ steps.process-env.outputs.ARCH }}-${{ steps.process-env.outputs.OS }}.txz" --repo static-php/static-php-cli-hosted --clobber

0 commit comments

Comments
 (0)