1
1
---
2
2
3
- name : 📦 Build binary
3
+ name : 📦 Build Macos binary
4
4
5
5
on : # yamllint disable-line rule:truthy
6
6
release :
7
7
types :
8
8
- published
9
9
10
10
jobs :
11
- build-unix :
12
- runs-on : ubuntu-latest
13
- name : 📦 Build Unix Executables
14
- strategy :
15
- fail-fast : false
16
- matrix :
17
- platform :
18
- - os : linux
19
- arch : amd64
20
- - os : linux
21
- arch : arm64
22
-
23
- steps :
24
- - name : Checkout code
25
- uses : actions/checkout@v3
26
-
27
- - name : Set up QEMU
28
- uses : docker/setup-qemu-action@v2
29
- with :
30
- platforms : arm64,amd64
31
-
32
- - name : Set up Docker Buildx
33
- uses : docker/setup-buildx-action@v2
34
-
35
- - name : Extract version from tag
36
- id : get_version
37
- run : |
38
- if [[ "$GITHUB_REF_NAME" == refs/pull/* ]]; then
39
- # For pull requests, use "dev" as version
40
- VERSION="dev"
41
- else
42
- # For releases, extract version from tag (remove 'v' prefix if present)
43
- VERSION=${GITHUB_REF_NAME#v}
44
- fi
45
- echo "VERSION=$VERSION" >> $GITHUB_ENV
46
- echo "{\"version\": \"$VERSION\", \"type\":\"bin\"}" > version.json
47
-
48
- - name : Build Docker image for ${{ matrix.platform.os }}-${{ matrix.platform.arch }}
49
- uses : docker/build-push-action@v4
50
- with :
51
- context : .
52
- push : false
53
- load : true
54
- tags : ctx-builder-${{ matrix.platform.os }}-${{ matrix.platform.arch }}:latest
55
- platforms : linux/${{ matrix.platform.arch }}
56
- build-args : |
57
- TARGET_OS=${{ matrix.platform.os }}
58
- TARGET_ARCH=${{ matrix.platform.arch }}
59
- VERSION=${{ env.VERSION }}
60
- cache-from : type=gha,scope=${{ matrix.platform.os }}-${{ matrix.platform.arch }}
61
- cache-to : type=gha,mode=max,scope=${{ matrix.platform.os }}-${{ matrix.platform.arch }}
62
-
63
- - name : Extract executable
64
- run : |
65
- mkdir -p dist
66
- container_id=$(docker create ctx-builder-${{ matrix.platform.os }}-${{ matrix.platform.arch }}:latest)
67
- docker cp $container_id:/.output/ctx ./dist/ctx-${{ env.VERSION }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
68
- docker rm $container_id
69
-
70
- - name : 📤 Upload release assets
71
-
72
- if : startsWith(github.ref, 'refs/tags/')
73
- with :
74
- token : " ${{ secrets.RELEASE_TOKEN }}"
75
- files : |
76
- ./dist/ctx-${{ env.VERSION }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
77
-
78
11
build-macos-arm64 :
79
12
runs-on : macos-14
80
13
name : 📦 Build macOS ARM64
@@ -270,76 +203,3 @@ jobs:
270
203
files : |
271
204
dist/ctx-${{ env.VERSION }}-darwin-amd64
272
205
273
- build-windows :
274
- runs-on : windows-latest
275
- name : 📦 Build Windows (x64)
276
- steps :
277
- - name : Checkout code
278
- uses : actions/checkout@v3
279
-
280
- - name : Set up PHP
281
- uses : shivammathur/setup-php@v2
282
- with :
283
- php-version : ' 8.3'
284
- extensions : mbstring, xml, curl, sockets
285
- coverage : none
286
-
287
- - name : Extract version from tag or set dev version
288
- id : get_version
289
- shell : bash
290
- run : |
291
- if [[ "$GITHUB_REF" == refs/pull/* ]]; then
292
- # For pull requests, use "dev" as version
293
- VERSION="dev"
294
- else
295
- # For releases, extract version from tag (remove 'v' prefix if present)
296
- VERSION=${GITHUB_REF_NAME#v}
297
- fi
298
- echo "VERSION=$VERSION" >> $GITHUB_ENV
299
- echo "{\"version\": \"$VERSION\", \"type\":\"bin\"}" > version.json
300
-
301
- - name : Install Composer dependencies
302
- run : composer install --no-dev --prefer-dist --ignore-platform-reqs
303
-
304
- - name : Create build directories
305
- run : New-Item -Path ".build\phar", ".build\bin" -ItemType Directory -Force
306
-
307
- - name : Download box tool
308
- run : |
309
- Invoke-WebRequest -Uri "https://github.com/box-project/box/releases/download/4.6.6/box.phar" -OutFile ".build/bin/box.phar"
310
-
311
- - name : Download SPC for Windows
312
- run : |
313
- Invoke-WebRequest -Uri "https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe" -OutFile ".build/bin/spc.exe"
314
-
315
- - name : Download required PHP extensions
316
- run : .build/bin/spc.exe download micro --for-extensions=ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter,curl --with-php=8.3 --prefer-pre-built
317
-
318
- # todo: fix this
319
- # - name: Install UPX for compression
320
- # run: |
321
- # .build/bin/spc.exe install-pkg upx
322
-
323
- - name : Verify environment is ready
324
- run : |
325
- .build/bin/spc.exe doctor --auto-fix
326
-
327
- - name : Build the self-executable binary
328
- run : .build/bin/spc.exe build "ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter,curl" --build-micro # --with-upx-pack
329
-
330
- - name : Build PHAR file
331
- run : |
332
- php .build/bin/box.phar compile -v
333
-
334
- - name : Combine micro.sfx with the PHAR
335
- run : |
336
- New-Item -Path "dist" -ItemType Directory -Force
337
- .build\bin\spc.exe micro:combine .build\phar\ctx.phar --output=dist\ctx-${{ env.VERSION }}-windows-amd64.exe
338
-
339
- - name : 📤 Upload release assets
340
-
341
- if : startsWith(github.ref, 'refs/tags/')
342
- with :
343
- token : " ${{ secrets.RELEASE_TOKEN }}"
344
- files : |
345
- ./dist/ctx-${{ env.VERSION }}-windows-amd64.exe
0 commit comments