|
1 | | -name: Build SPC Binary |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: [ "main" ] |
6 | | - pull_request: |
7 | | - branches: [ "main" ] |
8 | | - paths: |
9 | | - - '.github/workflows/release-build.yml' |
10 | | - release: |
11 | | - types: |
12 | | - - published |
13 | | - workflow_dispatch: |
14 | | - |
15 | | -env: |
16 | | - PHP_VERSION: 8.4 |
17 | | - MICRO_VERSION: 8.4.11 |
18 | | - |
19 | | -jobs: |
20 | | - build-release-artifacts: |
21 | | - name: "Build SPC Binary for ${{ matrix.operating-system.name }}" |
22 | | - runs-on: ${{ matrix.operating-system.os }} |
23 | | - strategy: |
24 | | - matrix: |
25 | | - operating-system: |
26 | | - - name: "linux-x86_64" |
27 | | - os: "ubuntu-latest" |
28 | | - filename: "spc-linux-x86_64.tar.gz" |
29 | | - - name: "macos-x86_64" |
30 | | - os: "macos-15-intel" |
31 | | - filename: "spc-macos-x86_64.tar.gz" |
32 | | - - name: "linux-aarch64" |
33 | | - os: "ubuntu-latest" |
34 | | - filename: "spc-linux-aarch64.tar.gz" |
35 | | - - name: "macos-aarch64" |
36 | | - os: "macos-14" |
37 | | - filename: "spc-macos-aarch64.tar.gz" |
38 | | - - name: "windows-x64" |
39 | | - os: "ubuntu-latest" |
40 | | - filename: "spc-windows-x64.exe" |
41 | | - steps: |
42 | | - - name: "Checkout" |
43 | | - uses: "actions/checkout@v4" |
44 | | - |
45 | | - - if: inputs.debug == true |
46 | | - run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV |
47 | | - |
48 | | - - name: "Install PHP for official runners" |
49 | | - uses: shivammathur/setup-php@v2 |
50 | | - with: |
51 | | - coverage: none |
52 | | - tools: composer:v2 |
53 | | - php-version: "${{ env.PHP_VERSION }}" |
54 | | - ini-values: memory_limit=-1 |
55 | | - extensions: curl, openssl, mbstring |
56 | | - |
57 | | - - name: "Get Composer Cache Directory" |
58 | | - id: composer-cache |
59 | | - run: | |
60 | | - echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
61 | | -
|
62 | | - - name: "Cache Composer dependencies" |
63 | | - uses: "actions/cache@v4" |
64 | | - with: |
65 | | - path: "${{ steps.composer-cache.outputs.dir }}" |
66 | | - key: "php-${{ env.PHP_VERSION }}-locked-composer-${{ hashFiles('**/composer.lock') }}" |
67 | | - restore-keys: | |
68 | | - php-${{ env.PHP_VERSION }}-locked-composer |
69 | | -
|
70 | | - - name: "Install Locked Dependencies" |
71 | | - run: "composer install --no-interaction --no-progress" |
72 | | - |
73 | | - - name: "Build PHAR File" |
74 | | - run: "composer build:phar" |
75 | | - |
76 | | - - name: "Download Minimal Combination" |
77 | | - run: | |
78 | | - if [ "${{ matrix.operating-system.name }}" = "windows-x64" ]; then |
79 | | - curl -fsSL https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ env.MICRO_VERSION }}-micro-win.zip -o tmp.zip |
80 | | - unzip tmp.zip |
81 | | - else |
82 | | - curl -fsSL https://dl.static-php.dev/static-php-cli/minimal/php-${{ env.MICRO_VERSION }}-micro-${{ matrix.operating-system.name }}.tar.gz -o tmp.tgz |
83 | | - tar -zxvf tmp.tgz |
84 | | - fi |
85 | | -
|
86 | | - - name: "Generate Executable" |
87 | | - run: | |
88 | | - bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G" |
89 | | - if [ "${{ matrix.operating-system.name }}" = "windows-x64" ]; then |
90 | | - mv spc spc.exe |
91 | | - else |
92 | | - chmod +x spc |
93 | | - fi |
94 | | - if [ "${{ matrix.operating-system.name }}" = "macos-aarch64" ] || [ "${{ matrix.operating-system.name }}" = "macos-x86_64" ]; then |
95 | | - sudo xattr -cr ./spc |
96 | | - fi |
97 | | -
|
98 | | - - name: "Archive Executable and Validate Binary" |
99 | | - run: | |
100 | | - if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then |
101 | | - tar -czf ${{ matrix.operating-system.filename }} spc |
102 | | - # validate spc binary |
103 | | - if [ "${{ matrix.operating-system.name }}" == "linux-x86_64" ]; then |
104 | | - ./spc dev:extensions |
105 | | - fi |
106 | | - fi |
107 | | -
|
108 | | - - name: "Copy file" |
109 | | - run: | |
110 | | - if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then |
111 | | - mkdir dist/ && cp ${{ matrix.operating-system.filename }} dist/ && cp spc dist/spc-${{ matrix.operating-system.name }} |
112 | | - else |
113 | | - mkdir dist/ && cp spc.exe dist/${{ matrix.operating-system.filename }} |
114 | | - echo "SUFFIX=.exe" >> $GITHUB_ENV |
115 | | - fi |
116 | | -
|
117 | | - - name: "Upload Binaries to Release" |
118 | | - uses: softprops/action-gh-release@v1 |
119 | | - if: ${{startsWith(github.ref, 'refs/tags/') }} |
120 | | - with: |
121 | | - files: dist/${{ matrix.operating-system.filename }} |
122 | | - |
123 | | - - name: "Deploy to self-hosted OSS" |
124 | | - # only run this step if the repository is static-php-cli and the branch is main |
125 | | - if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main' |
126 | | - uses: static-php/upload-s3-action@v1.0.0 |
127 | | - with: |
128 | | - aws_key_id: ${{ secrets.AWS_KEY_ID }} |
129 | | - aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
130 | | - aws_bucket: ${{ secrets.AWS_BUCKET }} |
131 | | - source_dir: "dist/" |
132 | | - destination_dir: static-php-cli/spc-bin/nightly/ |
133 | | - endpoint: ${{ secrets.AWS_ENDPOINT }} |
134 | | - |
135 | | - - name: "Upload Artifact" |
136 | | - uses: actions/upload-artifact@v4 |
137 | | - with: |
138 | | - path: spc${{ env.SUFFIX }} |
139 | | - name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }} |
140 | | - test-spc: |
141 | | - name: "Test SPC Binary for ${{ matrix.operating-system.name }}" |
142 | | - runs-on: ${{ matrix.operating-system.os }} |
143 | | - needs: [build-release-artifacts] |
144 | | - strategy: |
145 | | - matrix: |
146 | | - operating-system: |
147 | | - - name: "linux-x86_64" |
148 | | - os: "ubuntu-latest" |
149 | | - - name: "macos-x86_64" |
150 | | - os: "macos-15-intel" |
151 | | - - name: "linux-aarch64" |
152 | | - os: "ubuntu-24.04-arm" |
153 | | - - name: "macos-aarch64" |
154 | | - os: "macos-15" |
155 | | - - name: "windows-x64" |
156 | | - os: "windows-latest" |
157 | | - steps: |
158 | | - - name: "Checkout" |
159 | | - uses: actions/checkout@v4 |
160 | | - |
161 | | - - name: "Download Artifact" |
162 | | - uses: actions/download-artifact@v4 |
163 | | - env: |
164 | | - SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }} |
165 | | - with: |
166 | | - name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }} |
167 | | - |
168 | | - - name: "Chmod" |
169 | | - if: matrix.operating-system.name != 'windows-x64' |
170 | | - run: chmod +x spc |
171 | | - |
172 | | - - name: "Run SPC Tests" |
173 | | - env: |
174 | | - SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }} |
175 | | - run: ./spc${{ env.SUFFIX }} dev:extensions |
| 1 | +name: Build SPC Binary |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main", "v3" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main", "v3" ] |
| 8 | + paths: |
| 9 | + - '.github/workflows/release-build.yml' |
| 10 | + release: |
| 11 | + types: |
| 12 | + - published |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +env: |
| 16 | + PHP_VERSION: 8.4 |
| 17 | + MICRO_VERSION: 8.4.11 |
| 18 | + |
| 19 | +jobs: |
| 20 | + build-release-artifacts: |
| 21 | + name: "Build SPC Binary for ${{ matrix.operating-system.name }}" |
| 22 | + runs-on: ${{ matrix.operating-system.os }} |
| 23 | + strategy: |
| 24 | + matrix: |
| 25 | + operating-system: |
| 26 | + - name: "linux-x86_64" |
| 27 | + os: "ubuntu-latest" |
| 28 | + filename: "spc-linux-x86_64.tar.gz" |
| 29 | + - name: "macos-x86_64" |
| 30 | + os: "macos-15-intel" |
| 31 | + filename: "spc-macos-x86_64.tar.gz" |
| 32 | + - name: "linux-aarch64" |
| 33 | + os: "ubuntu-latest" |
| 34 | + filename: "spc-linux-aarch64.tar.gz" |
| 35 | + - name: "macos-aarch64" |
| 36 | + os: "macos-14" |
| 37 | + filename: "spc-macos-aarch64.tar.gz" |
| 38 | + - name: "windows-x64" |
| 39 | + os: "ubuntu-latest" |
| 40 | + filename: "spc-windows-x64.exe" |
| 41 | + steps: |
| 42 | + - name: "Checkout" |
| 43 | + uses: "actions/checkout@v4" |
| 44 | + |
| 45 | + - if: inputs.debug == true |
| 46 | + run: echo "SPC_BUILD_DEBUG=--debug" >> $GITHUB_ENV |
| 47 | + |
| 48 | + - name: "Install PHP for official runners" |
| 49 | + uses: shivammathur/setup-php@v2 |
| 50 | + with: |
| 51 | + coverage: none |
| 52 | + tools: composer:v2 |
| 53 | + php-version: "${{ env.PHP_VERSION }}" |
| 54 | + ini-values: memory_limit=-1 |
| 55 | + extensions: curl, openssl, mbstring |
| 56 | + |
| 57 | + - name: "Get Composer Cache Directory" |
| 58 | + id: composer-cache |
| 59 | + run: | |
| 60 | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + - name: "Cache Composer dependencies" |
| 63 | + uses: "actions/cache@v4" |
| 64 | + with: |
| 65 | + path: "${{ steps.composer-cache.outputs.dir }}" |
| 66 | + key: "php-${{ env.PHP_VERSION }}-locked-composer-${{ hashFiles('**/composer.lock') }}" |
| 67 | + restore-keys: | |
| 68 | + php-${{ env.PHP_VERSION }}-locked-composer |
| 69 | +
|
| 70 | + - name: "Install Locked Dependencies" |
| 71 | + run: "composer install --no-interaction --no-progress" |
| 72 | + |
| 73 | + - name: "Build PHAR File" |
| 74 | + run: "composer build:phar" |
| 75 | + |
| 76 | + - name: "Download Minimal Combination" |
| 77 | + run: | |
| 78 | + if [ "${{ matrix.operating-system.name }}" = "windows-x64" ]; then |
| 79 | + curl -fsSL https://dl.static-php.dev/static-php-cli/windows/spc-min/php-${{ env.MICRO_VERSION }}-micro-win.zip -o tmp.zip |
| 80 | + unzip tmp.zip |
| 81 | + else |
| 82 | + curl -fsSL https://dl.static-php.dev/static-php-cli/minimal/php-${{ env.MICRO_VERSION }}-micro-${{ matrix.operating-system.name }}.tar.gz -o tmp.tgz |
| 83 | + tar -zxvf tmp.tgz |
| 84 | + fi |
| 85 | +
|
| 86 | + - name: "Generate Executable" |
| 87 | + run: | |
| 88 | + bin/spc micro:combine spc.phar -M micro.sfx -O spc -I "memory_limit=2G" |
| 89 | + if [ "${{ matrix.operating-system.name }}" = "windows-x64" ]; then |
| 90 | + mv spc spc.exe |
| 91 | + else |
| 92 | + chmod +x spc |
| 93 | + fi |
| 94 | + if [ "${{ matrix.operating-system.name }}" = "macos-aarch64" ] || [ "${{ matrix.operating-system.name }}" = "macos-x86_64" ]; then |
| 95 | + sudo xattr -cr ./spc |
| 96 | + fi |
| 97 | +
|
| 98 | + - name: "Archive Executable and Validate Binary" |
| 99 | + run: | |
| 100 | + if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then |
| 101 | + tar -czf ${{ matrix.operating-system.filename }} spc |
| 102 | + # validate spc binary |
| 103 | + if [ "${{ matrix.operating-system.name }}" == "linux-x86_64" ]; then |
| 104 | + ./spc dev:extensions |
| 105 | + fi |
| 106 | + fi |
| 107 | +
|
| 108 | + - name: "Copy file" |
| 109 | + run: | |
| 110 | + if [ "${{ matrix.operating-system.name }}" != "windows-x64" ]; then |
| 111 | + mkdir dist/ && cp ${{ matrix.operating-system.filename }} dist/ && cp spc dist/spc-${{ matrix.operating-system.name }} |
| 112 | + else |
| 113 | + mkdir dist/ && cp spc.exe dist/${{ matrix.operating-system.filename }} |
| 114 | + echo "SUFFIX=.exe" >> $GITHUB_ENV |
| 115 | + fi |
| 116 | +
|
| 117 | + - name: "Upload Binaries to Release" |
| 118 | + uses: softprops/action-gh-release@v1 |
| 119 | + if: ${{startsWith(github.ref, 'refs/tags/') }} |
| 120 | + with: |
| 121 | + files: dist/${{ matrix.operating-system.filename }} |
| 122 | + |
| 123 | + - name: "Deploy to self-hosted OSS" |
| 124 | + # only run this step if the repository is static-php-cli and the branch is main |
| 125 | + if: github.repository == 'crazywhalecc/static-php-cli' && github.ref == 'refs/heads/main' |
| 126 | + uses: static-php/upload-s3-action@v1.0.0 |
| 127 | + with: |
| 128 | + aws_key_id: ${{ secrets.AWS_KEY_ID }} |
| 129 | + aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 130 | + aws_bucket: ${{ secrets.AWS_BUCKET }} |
| 131 | + source_dir: "dist/" |
| 132 | + destination_dir: static-php-cli/spc-bin/nightly/ |
| 133 | + endpoint: ${{ secrets.AWS_ENDPOINT }} |
| 134 | + |
| 135 | + - name: "Upload Artifact" |
| 136 | + uses: actions/upload-artifact@v4 |
| 137 | + with: |
| 138 | + path: spc${{ env.SUFFIX }} |
| 139 | + name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }} |
| 140 | + test-spc: |
| 141 | + name: "Test SPC Binary for ${{ matrix.operating-system.name }}" |
| 142 | + runs-on: ${{ matrix.operating-system.os }} |
| 143 | + needs: [build-release-artifacts] |
| 144 | + strategy: |
| 145 | + matrix: |
| 146 | + operating-system: |
| 147 | + - name: "linux-x86_64" |
| 148 | + os: "ubuntu-latest" |
| 149 | + - name: "macos-x86_64" |
| 150 | + os: "macos-15-intel" |
| 151 | + - name: "linux-aarch64" |
| 152 | + os: "ubuntu-24.04-arm" |
| 153 | + - name: "macos-aarch64" |
| 154 | + os: "macos-15" |
| 155 | + - name: "windows-x64" |
| 156 | + os: "windows-latest" |
| 157 | + steps: |
| 158 | + - name: "Checkout" |
| 159 | + uses: actions/checkout@v4 |
| 160 | + |
| 161 | + - name: "Download Artifact" |
| 162 | + uses: actions/download-artifact@v4 |
| 163 | + env: |
| 164 | + SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }} |
| 165 | + with: |
| 166 | + name: spc-${{ matrix.operating-system.name }}${{ env.SUFFIX }} |
| 167 | + |
| 168 | + - name: "Chmod" |
| 169 | + if: matrix.operating-system.name != 'windows-x64' |
| 170 | + run: chmod +x spc |
| 171 | + |
| 172 | + - name: "Run SPC Tests" |
| 173 | + env: |
| 174 | + SUFFIX: ${{ matrix.operating-system.name == 'windows-x64' && '.exe' || '' }} |
| 175 | + run: ./spc${{ env.SUFFIX }} dev:extensions |
0 commit comments