@@ -3,31 +3,93 @@ name: Build
33on : [push]
44
55jobs :
6- build :
7- runs-on : ${{matrix.os}}
6+ linux :
7+ runs-on : ubuntu-latest
8+ services :
9+ registry :
10+ image : registry:2
11+ ports :
12+ - 5000:5000
813 strategy :
914 matrix :
1015 include :
11- - build : linux
16+ -
17+ target : x86_64-unknown-linux-gnu
18+ platform : linux/amd64
19+ php-version : ' 8.0'
20+ -
1221 os : ubuntu-latest
13- rust : stable
22+ target : aarch64-unknown-linux-gnu
23+ platform : linux/arm64
24+ php-version : ' 8.0'
25+ -
1426 target : x86_64-unknown-linux-gnu
15- file : libv8js.so
16- # - build: linux-aarch64
17- # os: ubuntu-latest
18- # rust: stable
19- # target: aarch64-unknown-linux-gnu
20- # cross: true
21- - build : macos-aarch64
22- os : macos-latest
23- rust : stable
27+ platform : linux/amd64
28+ php-version : ' 8.1'
29+ -
30+ os : ubuntu-latest
31+ target : aarch64-unknown-linux-gnu
32+ platform : linux/arm64
33+ php-version : ' 8.1'
34+ steps :
35+ - name : Checkout
36+ uses : actions/checkout@v1
37+
38+ - name : Setup QEMU
39+ uses : docker/setup-qemu-action@v2
40+
41+ - name : Set up Docker Buildx
42+ id : buildx
43+ uses : docker/setup-buildx-action@v2
44+ with :
45+ driver-opts : network=host
46+
47+ - name : Setup docker
48+ uses : docker/build-push-action@v2
49+ with :
50+ context : .
51+ platforms : ${{ matrix.platform }}
52+ push : true
53+ tags : localhost:5000/phpv8js-build:latest
54+ build-args : |
55+ FROM_PHP=${{ matrix.php-version }}
56+
57+ - name : Build
58+ run : docker run --rm -v $PWD:/code localhost:5000/phpv8js-build:latest bash -c 'rustup target add ${{ matrix.target }} ; cargo build --release --target ${{ matrix.target }}'
59+
60+ - name : Rename file
61+ run : cp target/${{ matrix.target }}/release/libv8js.so php${{ matrix.php-version }}-${{ matrix.target }}-libv8js.so
62+
63+ - uses : actions/upload-artifact@v3
64+ with :
65+ name : php${{ matrix.php-version }}-${{ matrix.target }}
66+ path : php${{ matrix.php-version }}-${{ matrix.target }}-libv8js.so
67+ - name : Release
68+ uses : softprops/action-gh-release@v1
69+ if : startsWith(github.ref, 'refs/tags/')
70+ with :
71+ files : |
72+ php${{ matrix.php-version }}-${{ matrix.target }}-libv8js.so
73+ env :
74+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
75+
76+ macos :
77+ runs-on : macos-latest
78+ strategy :
79+ matrix :
80+ include :
81+ -
2482 target : aarch64-apple-darwin
25- file : libv8js.dylib
26- - build : macos
27- os : macos-latest
28- rust : stable
83+ php-version : ' 8.0'
84+ -
2985 target : x86_64-apple-darwin
30- file : libv8js.dylib
86+ php-version : ' 8.0'
87+ -
88+ target : aarch64-apple-darwin
89+ php-version : ' 8.1'
90+ -
91+ target : x86_64-apple-darwin
92+ php-version : ' 8.1'
3193 steps :
3294 - name : Checkout
3395 uses : actions/checkout@v1
39101 target : ${{ matrix.target }}
40102 default : true
41103 override : true
104+ - name : Setup PHP version
105+ run : brew install php@${{ matrix.php-version }} && brew unlink php && brew link --force php@${{ matrix.php-version }}
42106 - name : Build
43107 uses : actions-rs/cargo@v1
44108 with :
@@ -47,13 +111,17 @@ jobs:
47111 args : --release --target ${{ matrix.target }} --lib
48112
49113 - name : Rename file
50- run : mv target/${{ matrix.target }}/release/${{ matrix.file }} target/${{ matrix.target }}-${{ matrix.file }}
114+ run : mv target/${{ matrix.target }}/release/libv8js.dylib target/php ${{ matrix.php-version }}-${{ matrix.target }}-libv8js.dylib
51115
116+ - uses : actions/upload-artifact@v3
117+ with :
118+ name : php${{ matrix.php-version }}-${{ matrix.target }}
119+ path : target/php${{ matrix.php-version }}-${{ matrix.target }}-libv8js.dylib
52120 - name : Release
53121 uses : softprops/action-gh-release@v1
54122 if : startsWith(github.ref, 'refs/tags/')
55123 with :
56124 files : |
57- target/${{ matrix.target }}-${{ matrix.file }}
125+ target/php ${{ matrix.php-version }}-${{ matrix.target }}-libv8js.dylib
58126 env :
59127 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments