Skip to content

Commit a29fce6

Browse files
authored
Merge pull request #25: Add binary building workflow
2 parents 94153bc + 4e93a53 commit a29fce6

File tree

4 files changed

+418
-0
lines changed

4 files changed

+418
-0
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
composer.lock export-ignore
1010
composer-require-* export-ignore
1111
Makefile export-ignore
12+
Dockerfile export-ignore
1213
infection.* export-ignore
1314
tests export-ignore
1415
docs export-ignore
Lines changed: 361 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,361 @@
1+
---
2+
3+
name: 📦 Build binary
4+
5+
on: # yamllint disable-line rule:truthy
6+
release:
7+
types:
8+
- published
9+
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: dload-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 dload-builder-${{ matrix.platform.os }}-${{ matrix.platform.arch }}:latest)
67+
docker cp $container_id:/.output/dload ./dist/dload
68+
docker rm $container_id
69+
70+
- name: Zip output
71+
uses: ksm2/archive-action@v1
72+
with:
73+
root-directory: dist
74+
format: "tar.gz"
75+
name: dload-${{ env.VERSION }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}
76+
77+
- name: 📤 Upload release assets
78+
uses: softprops/action-gh-release@v2
79+
if: startsWith(github.ref, 'refs/tags/')
80+
with:
81+
token: "${{ secrets.DLOAD_RELEASE_TOKEN }}"
82+
files: |
83+
./dload-${{ env.VERSION }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz
84+
85+
build-macos-arm64:
86+
runs-on: macos-14
87+
name: 📦 Build macOS ARM64
88+
steps:
89+
- name: Checkout code
90+
uses: actions/checkout@v4
91+
with:
92+
fetch-depth: 0
93+
94+
- name: Set up PHP
95+
uses: shivammathur/setup-php@v2
96+
with:
97+
php-version: '8.3'
98+
extensions: mbstring, xml, sockets
99+
coverage: none
100+
101+
- name: Extract version from tag or set dev version
102+
id: get_version
103+
shell: bash
104+
run: |
105+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && -n "${{ github.event.inputs.version }}" ]]; then
106+
VERSION="${{ github.event.inputs.version }}"
107+
elif [[ "$GITHUB_REF" == refs/pull/* || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
108+
# For pull requests or manual triggers without version, use "dev" as version
109+
VERSION="dev"
110+
else
111+
# For releases, extract version from tag (remove 'v' prefix if present)
112+
VERSION=${GITHUB_REF_NAME#v}
113+
fi
114+
echo "VERSION=$VERSION" >> $GITHUB_ENV
115+
echo "{\"version\": \"$VERSION\", \"type\":\"bin\"}" > version.json
116+
117+
- name: Install Composer dependencies
118+
run: composer install --no-dev --prefer-dist --ignore-platform-reqs
119+
120+
- name: Create build directories
121+
run: mkdir -p .build/phar .build/bin dist
122+
123+
- name: Download box tool
124+
run: |
125+
curl -fsSL -o .build/bin/box.phar https://github.com/box-project/box/releases/download/4.6.6/box.phar
126+
chmod +x .build/bin/box.phar
127+
128+
- name: Download SPC for macOS ARM64
129+
run: |
130+
curl -fsSL -o .build/bin/spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-aarch64
131+
chmod +x .build/bin/spc
132+
133+
- name: Download required PHP extensions
134+
run: |
135+
export SPC_SKIP_BREW_INSTALL=1
136+
.build/bin/spc download micro --for-extensions=ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter --with-php=8.3 --prefer-pre-built
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.DLOAD_RELEASE_TOKEN }}
139+
140+
- name: Verify environment is ready
141+
run: |
142+
export SPC_SKIP_BREW_INSTALL=1
143+
.build/bin/spc doctor --auto-fix
144+
145+
- name: Build PHAR file
146+
run: |
147+
php .build/bin/box.phar compile -v
148+
149+
- name: Build the self-executable binary
150+
run: |
151+
# Skip Homebrew installation (we don't need it)
152+
export SPC_SKIP_BREW_INSTALL=1
153+
.build/bin/spc build "ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter" --build-micro
154+
155+
- name: Combine micro.sfx with the PHAR
156+
run: |
157+
.build/bin/spc micro:combine .build/phar/ctx.phar --output=dist/dload
158+
159+
- name: Test binary
160+
run: |
161+
chmod +x dist/dload
162+
dist/dload --help
163+
164+
- name: Zip output
165+
uses: ksm2/archive-action@v1
166+
with:
167+
root-directory: dist
168+
format: "tar.gz"
169+
name: dload-${{ env.VERSION }}-darwin-arm64
170+
171+
- name: 📤 Upload release assets
172+
uses: softprops/action-gh-release@v2
173+
if: startsWith(github.ref, 'refs/tags/')
174+
with:
175+
token: "${{ secrets.DLOAD_RELEASE_TOKEN }}"
176+
files: |
177+
./dload-${{ env.VERSION }}-darwin-arm64.tar.gz
178+
179+
build-macos-amd64:
180+
runs-on: macos-latest
181+
name: 📦 Build macOS (x64)
182+
steps:
183+
- name: Checkout code
184+
uses: actions/checkout@v4
185+
with:
186+
fetch-depth: 0
187+
188+
- name: Set up PHP
189+
uses: shivammathur/setup-php@v2
190+
with:
191+
php-version: '8.3'
192+
extensions: mbstring, xml, sockets
193+
coverage: none
194+
195+
- name: Extract version from tag or set dev version
196+
id: get_version
197+
shell: bash
198+
run: |
199+
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" && -n "${{ github.event.inputs.version }}" ]]; then
200+
VERSION="${{ github.event.inputs.version }}"
201+
elif [[ "$GITHUB_REF" == refs/pull/* || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then
202+
# For pull requests or manual triggers without version, use "dev" as version
203+
VERSION="dev"
204+
else
205+
# For releases, extract version from tag (remove 'v' prefix if present)
206+
VERSION=${GITHUB_REF_NAME#v}
207+
fi
208+
echo "VERSION=$VERSION" >> $GITHUB_ENV
209+
echo "{\"version\": \"$VERSION\", \"type\":\"bin\"}" > version.json
210+
211+
- name: Install Composer dependencies
212+
run: composer install --no-dev --prefer-dist --ignore-platform-reqs
213+
214+
- name: Create build directories
215+
run: mkdir -p .build/phar .build/bin dist
216+
217+
- name: Download SPC for macOS AMD64
218+
run: |
219+
curl -fsSL -o .build/bin/spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-macos-x86_64
220+
chmod +x .build/bin/spc
221+
222+
- name: Download box tool
223+
run: |
224+
curl -fsSL -o .build/bin/box.phar https://github.com/box-project/box/releases/download/4.6.6/box.phar
225+
chmod +x .build/bin/box.phar
226+
227+
- name: Install Intel Homebrew for AMD64
228+
run: |
229+
# Check if we need to install Intel Homebrew
230+
if [[ ! -d "/usr/local/Homebrew" ]]; then
231+
echo "Installing Intel (x86_64) version of Homebrew"
232+
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
233+
fi
234+
235+
- name: Download required PHP extensions
236+
run: |
237+
# For AMD64, ensure we're using the Intel Homebrew
238+
export PATH="/usr/local/bin:$PATH"
239+
.build/bin/spc download micro --for-extensions=ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter --with-php=8.3 --prefer-pre-built
240+
env:
241+
GITHUB_TOKEN: ${{ secrets.DLOAD_RELEASE_TOKEN }}
242+
243+
- name: Verify environment is ready
244+
run: |
245+
export PATH="/usr/local/bin:$PATH"
246+
.build/bin/spc doctor --auto-fix
247+
248+
- name: Build PHAR file
249+
run: |
250+
php .build/bin/box.phar compile -v
251+
252+
- name: Build the self-executable binary
253+
run: |
254+
export PATH="/usr/local/bin:$PATH"
255+
.build/bin/spc build "ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter" --build-micro
256+
257+
- name: Combine micro.sfx with the PHAR
258+
run: |
259+
export PATH="/usr/local/bin:$PATH"
260+
.build/bin/spc micro:combine .build/phar/ctx.phar --output=dist/dload
261+
262+
- name: Test binary
263+
run: |
264+
chmod +x dist/dload
265+
dist/dload --help
266+
267+
- name: Zip output
268+
uses: ksm2/archive-action@v1
269+
with:
270+
root-directory: dist
271+
format: "tar.gz"
272+
name: dload-${{ env.VERSION }}-darwin-amd64
273+
274+
- name: 📤 Upload release assets
275+
uses: softprops/action-gh-release@v2
276+
if: startsWith(github.ref, 'refs/tags/')
277+
with:
278+
token: "${{ secrets.DLOAD_RELEASE_TOKEN }}"
279+
files: |
280+
./dload-${{ env.VERSION }}-darwin-amd64.tar.gz
281+
282+
build-windows:
283+
runs-on: windows-latest
284+
name: 📦 Build Windows (x64)
285+
steps:
286+
- name: Checkout code
287+
uses: actions/checkout@v3
288+
289+
- name: Set up PHP
290+
uses: shivammathur/setup-php@v2
291+
with:
292+
php-version: '8.3'
293+
extensions: mbstring, xml, sockets
294+
coverage: none
295+
296+
- name: Extract version from tag or set dev version
297+
id: get_version
298+
shell: bash
299+
run: |
300+
if [[ "$GITHUB_REF" == refs/pull/* ]]; then
301+
# For pull requests, use "dev" as version
302+
VERSION="dev"
303+
else
304+
# For releases, extract version from tag (remove 'v' prefix if present)
305+
VERSION=${GITHUB_REF_NAME#v}
306+
fi
307+
echo "VERSION=$VERSION" >> $GITHUB_ENV
308+
echo "{\"version\": \"$VERSION\", \"type\":\"bin\"}" > version.json
309+
310+
- name: Install Composer dependencies
311+
run: composer install --no-dev --prefer-dist --ignore-platform-reqs
312+
313+
- name: Create build directories
314+
run: New-Item -Path ".build\phar", ".build\bin" -ItemType Directory -Force
315+
316+
- name: Download box tool
317+
run: |
318+
Invoke-WebRequest -Uri "https://github.com/box-project/box/releases/download/4.6.6/box.phar" -OutFile ".build/bin/box.phar"
319+
320+
- name: Download SPC for Windows
321+
run: |
322+
Invoke-WebRequest -Uri "https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-windows-x64.exe" -OutFile ".build/bin/spc.exe"
323+
324+
- name: Download required PHP extensions
325+
run: .build/bin/spc.exe download micro --for-extensions=ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter --with-php=8.3 --prefer-pre-built
326+
327+
# todo: fix this
328+
# - name: Install UPX for compression
329+
# run: |
330+
# .build/bin/spc.exe install-pkg upx
331+
332+
- name: Verify environment is ready
333+
run: |
334+
.build/bin/spc.exe doctor --auto-fix
335+
336+
- name: Build the self-executable binary
337+
run: .build/bin/spc.exe build "ctype,dom,filter,libxml,mbstring,phar,simplexml,sockets,tokenizer,xml,xmlwriter" --build-micro # --with-upx-pack
338+
339+
- name: Build PHAR file
340+
run: |
341+
php .build/bin/box.phar compile -v --allow-composer-check-failure
342+
343+
- name: Combine micro.sfx with the PHAR
344+
run: |
345+
New-Item -Path "dist" -ItemType Directory -Force
346+
.build\bin\spc.exe micro:combine .build\phar\dload.phar --output=dist\dload.exe
347+
348+
- name: Zip output
349+
uses: ksm2/archive-action@v1
350+
with:
351+
root-directory: dist
352+
format: "tar.gz"
353+
name: dload-${{ env.VERSION }}-windows-amd64
354+
355+
- name: 📤 Upload release assets
356+
uses: softprops/action-gh-release@v2
357+
if: startsWith(github.ref, 'refs/tags/')
358+
with:
359+
token: "${{ secrets.DLOAD_RELEASE_TOKEN }}"
360+
files: |
361+
./dload-${{ env.VERSION }}-windows-amd64.tar.gz

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## 1.0.0-RC3 (2025-04-13)
4+
5+
## What's Changed
6+
* Added software versions checker by @roxblnfk in https://github.com/php-internal/dload/pull/23
7+
Added `dload show` command
8+
Added a new software `trap`
9+
10+
## 1.0.0-RC2 (2025-04-12)
11+
12+
## What's Changed
13+
- Support loading not archived binaries
14+
- Binary config separated into embedded entity
15+
- Mon-binary files can be loaded without arch/os checks
16+
- Added param `extract-path` to download action
17+
18+
## 1.0.0-RC1 (2025-04-07)
19+
20+
## What's Changed
21+
* Fix PHAR building by @roxblnfk in https://github.com/php-internal/dload/pull/16
22+
* Make lazy loading of releases pages; maintenance by @roxblnfk in https://github.com/php-internal/dload/pull/18
23+
* Check binaries before downloading by @roxblnfk in https://github.com/php-internal/dload/pull/19
24+
325
## 1.0.0-alpha (2024-07-20)
426

527
## What's Changed

0 commit comments

Comments
 (0)