From 1ba531c5693795ced3229053282e5529e937efcb Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Wed, 13 Sep 2023 23:39:52 +0800 Subject: [PATCH 1/3] Add new GH action to build binary SPC --- .github/workflows/release-build.yml | 96 +++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/release-build.yml diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml new file mode 100644 index 000000000..59c7fab97 --- /dev/null +++ b/.github/workflows/release-build.yml @@ -0,0 +1,96 @@ +name: Build Release Artifacts + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + build-release-artifacts: + name: "Build Release Artifacts" + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + php-version: + - "8.1" + operating-system: + - "ubuntu-latest" + - "macos-latest" + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: none + tools: composer:v2 + php-version: "${{ matrix.php-version }}" + ini-values: memory_limit=-1 + + - name: "Get Composer Cache Directory" + id: composer-cache + run: | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: "Cache Composer dependencies" + uses: "actions/cache@v3" + with: + path: "${{ steps.composer-cache.outputs.dir }}" + key: "php-${{ matrix.php-version }}-locked-composer-${{ hashFiles('**/composer.lock') }}" + restore-keys: | + php-${{ matrix.php-version }}-locked-composer- + - name: "Install locked dependencies" + run: "composer install --no-interaction --no-progress" + + # Cache downloaded source + - id: cache-download + uses: actions/cache@v3 + with: + path: downloads + key: php-${{ matrix.php-version }}-dependencies + + # If there's no dependencies cache, fetch sources + - if: steps.cache-download.outputs.cache-hit != 'true' + name: "Download sources" + run: bin/spc download --with-php=${{ matrix.php-version }} --all + + - name: "Build phpmicro" + run: | + SPC_USE_SUDO=yes bin/spc doctor --auto-fix + bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro --debug + + - name: "Build PHAR file" + run: "composer build:phar" + + - name: "Generate Executable" + run: "bin/spc micro:combine spc.phar -O spc" + + - name: "Archive Executable" + run: | + OS="" + if [ "${{ matrix.operating-system }}" = "ubuntu-latest" ]; then + OS="linux-x86_64" + elif [ "${{ matrix.operating-system }}" = "macos-latest" ]; then + OS="macos-x86_64" + fi + tar -czf spc-$OS.tar.gz spc + echo "filename=spc-$OS.tar.gz" >> $GITHUB_ENV + echo "OS=$OS" >> $GITHUB_ENV + + - name: "Test Micro file" + run: "./spc dev:extensions" + + - name: upload binaries to release + uses: softprops/action-gh-release@v1 + if: ${{startsWith(github.ref, 'refs/tags/') }} + with: + files: ${{ env.filename }} + + - name: "Upload Artifact" + uses: actions/upload-artifact@v3 + with: + path: spc + name: spc-${{ env.OS }} From 1629dc5f2d9262d695d834a89e19cbaf1c05346e Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Sep 2023 19:01:48 +0800 Subject: [PATCH 2/3] remove debug option --- .github/workflows/release-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 59c7fab97..21b4e2868 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -60,7 +60,7 @@ jobs: - name: "Build phpmicro" run: | SPC_USE_SUDO=yes bin/spc doctor --auto-fix - bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro --debug + bin/spc build pcntl,posix,mbstring,tokenizer,phar --build-micro - name: "Build PHAR file" run: "composer build:phar" From 7840ce63ef9b012ace548a8b871bd6f61d8479a8 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Fri, 15 Sep 2023 19:06:41 +0800 Subject: [PATCH 3/3] remove download cache and minimize download sources --- .github/workflows/release-build.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index 21b4e2868..77c7c7289 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -45,17 +45,8 @@ jobs: - name: "Install locked dependencies" run: "composer install --no-interaction --no-progress" - # Cache downloaded source - - id: cache-download - uses: actions/cache@v3 - with: - path: downloads - key: php-${{ matrix.php-version }}-dependencies - - # If there's no dependencies cache, fetch sources - - if: steps.cache-download.outputs.cache-hit != 'true' - name: "Download sources" - run: bin/spc download --with-php=${{ matrix.php-version }} --all + - name: "Download sources" + run: bin/spc download --with-php=${{ matrix.php-version }} php-src,micro,pkg-config,onig,zlib - name: "Build phpmicro" run: |