@@ -77,6 +77,134 @@ jobs:
7777
7878 - uses : actions/upload-artifact@v4
7979 with :
80- name : php-matrix. phar
80+ name : phar
8181 path : phar/php-matrix
8282 if-no-files-found : error
83+
84+ build :
85+ needs : phar
86+ strategy :
87+ matrix :
88+ include :
89+ - runs-on : ubuntu-24.04-arm
90+ variant : linux_arm64
91+ spc-variant : linux-aarch64
92+ - runs-on : ubuntu-24.04
93+ variant : linux_amd64
94+ spc-variant : linux-x86_64
95+ - runs-on : macos-15
96+ variant : darwin_arm64
97+ spc-variant : macos-aarch64
98+ - runs-on : macos-15-intel
99+ variant : darwin_amd64
100+ spc-variant : macos-x86_64
101+ runs-on : ${{ matrix.runs-on }}
102+ steps :
103+ - uses : actions/checkout@v5
104+ with :
105+ sparse-checkout : craft.yml
106+ sparse-checkout-cone-mode : false
107+
108+ - name : Install spc
109+ run : |
110+ gh release download --repo crazywhalecc/static-php-cli --pattern "${PATTERN}" --output spc.tar.gz && \
111+ mkdir -p /tmp/spc && \
112+ tar -xvf spc.tar.gz --directory /tmp/spc && \
113+ echo "/tmp/spc" >> "$GITHUB_PATH"
114+ env :
115+ PATTERN : spc-${{ matrix.spc-variant }}.tar.gz
116+ GH_TOKEN : ${{ github.token }}
117+
118+ - uses : actions/download-artifact@v5
119+ with :
120+ name : phar
121+ path : phar
122+
123+ - name : Restore cached micro.sfx
124+ id : restore-micro-sfx
125+ uses : actions/cache/restore@v4
126+ with :
127+ path : buildroot/bin/micro.sfx
128+ key : micro-sfx-${{ runner.os }}-${{ runner.arch }}-${{ needs.phar.outputs.php-version }}-${{ hashFiles('craft.yml') }}
129+
130+ - name : Build micro.sfx
131+ if : steps.restore-micro-sfx.outputs.cache-hit != 'true'
132+ run : spc craft
133+ env :
134+ GITHUB_TOKEN : ${{ github.token }} # Not a typo.
135+
136+ - name : Cache micro.sfx
137+ id : cache-micro-sfx
138+ if : steps.restore-micro-sfx.outputs.cache-hit != 'true'
139+ uses : actions/cache/save@v4
140+ with :
141+ path : buildroot/bin/micro.sfx
142+ key : ${{ steps.restore-micro-sfx.outputs.cache-primary-key }}
143+
144+ - run : mkdir -p out
145+ - run : spc micro:combine phar/php-matrix --output out/php-matrix
146+
147+ - uses : actions/upload-artifact@v4
148+ with :
149+ name : php-matrix_${{ matrix.variant }}
150+ path : out/php-matrix
151+ if-no-files-found : error
152+
153+ e2e :
154+ name : e2e (${{ matrix.runs-on }})
155+ needs : build
156+ strategy :
157+ matrix :
158+ include :
159+ - runs-on : ubuntu-24.04-arm
160+ variant : linux_arm64
161+ - runs-on : ubuntu-24.04
162+ variant : linux_amd64
163+ - runs-on : macos-15
164+ variant : darwin_arm64
165+ - runs-on : macos-15-intel
166+ variant : darwin_amd64
167+ runs-on : ${{ matrix.runs-on }}
168+ env :
169+ GOFLAGS : ' -mod=mod'
170+ steps :
171+ - uses : actions/checkout@v5
172+
173+ - uses : actions/setup-go@v6
174+ with :
175+ go-version-file : ' go.mod'
176+
177+ - run : echo OS="$(go env GOOS)" >> $GITHUB_ENV
178+ - run : echo ARCH="$(go env GOARCH)" >> $GITHUB_ENV
179+
180+ - uses : actions/download-artifact@v5
181+ with :
182+ name : php-matrix_${{ matrix.variant }}
183+ path : out
184+
185+ - name : Grant the binary execute permission
186+ run : chmod +x out/php-matrix
187+
188+ - name : Add the binary into PATH
189+ run : echo "${WORKSPACE}/out" >> "$GITHUB_PATH"
190+ env :
191+ WORKSPACE : ${{ github.workspace }}
192+
193+ - name : Print the binary path
194+ run : go test -count=1 -v ./internal
195+
196+ - run : go test -count=1 ./...
197+
198+ merge :
199+ needs :
200+ - build
201+ - e2e
202+ runs-on : ubuntu-24.04
203+ steps :
204+ - name : Merge binary artifacts
205+ uses : actions/upload-artifact/merge@v4
206+ with :
207+ name : binaries
208+ pattern : php-matrix_*
209+ separate-directories : true
210+ delete-merged : true
0 commit comments