From 71c271ded3e5009e4069c74ad73ff1efb2bc928a Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Sat, 7 Sep 2024 01:51:22 +0200 Subject: [PATCH] MacOS x86_64 && Arm64 --- .github/workflows/build-macos-arm-binary.yml | 87 ++++++++++++++++++++ .github/workflows/build-macos-binary.yml | 2 +- .github/workflows/test.yml | 2 +- composer.json | 2 +- 4 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-macos-arm-binary.yml diff --git a/.github/workflows/build-macos-arm-binary.yml b/.github/workflows/build-macos-arm-binary.yml new file mode 100644 index 0000000..5fd4e26 --- /dev/null +++ b/.github/workflows/build-macos-arm-binary.yml @@ -0,0 +1,87 @@ +name: Build binary for macOS arm64 + +on: + release: + types: [ created ] + + workflow_dispatch: + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BINARY_NAME: 'svgtinyps-macos-arm64' + COMPILE_PHP_VERSION: "8.3" + COMPILE_EXTENSIONS: 'phar,dom' + +jobs: + build-macos-binary: + runs-on: macos-14 + permissions: + contents: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Install macOS missing packages and mark os suffix + run: | + brew install automake gzip + echo "SPC_BUILD_OS=macos" >> $GITHUB_ENV + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ env.COMPILE_PHP_VERSION }} + tools: composer:v2 + + - name: Cache build dependencies + uses: actions/cache@v3 + with: + path: build/ + key: build-deps-php-${{ env.COMPILE_PHP_VERSION }}-${{ runner.os }} + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Composer install + run: composer install --prefer-dist --no-progress --optimize-autoloader + +# - id: cache-download +# name: Cached source download +# uses: actions/cache@v3 +# with: +# path: downloads +# key: php-${{ env.COMPILE_PHP_VERSION }}-dependencies +# +# - if: steps.cache-download.outputs.cache-hit != 'true' +# name: Fetch php and extensions sources +# run: ./bin/spc download --with-php=${{ env.COMPILE_PHP_VERSION }} --for-extensions=$COMPILE_EXTENSIONS +# +# - name: Build Micro +# run: ./bin/spc build $COMPILE_EXTENSIONS --build-micro + + - name: Build Binary + run: ./build.sh --name "${{ env.BINARY_NAME }}" + + - if: ${{ github.event_name == 'workflow_dispatch' }} + name: Upload binaries + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BINARY_NAME }} + path: build/bin/${{ env.BINARY_NAME }} + + - if: ${{ github.event_name != 'workflow_dispatch' }} + name: Upload binaries to release + uses: softprops/action-gh-release@v1 + with: + files: build/bin/${{ env.BINARY_NAME }} diff --git a/.github/workflows/build-macos-binary.yml b/.github/workflows/build-macos-binary.yml index 07aeea3..9311bd6 100644 --- a/.github/workflows/build-macos-binary.yml +++ b/.github/workflows/build-macos-binary.yml @@ -14,7 +14,7 @@ env: jobs: build-macos-binary: - runs-on: macos-latest + runs-on: macos-14-large permissions: contents: write diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 916a2df..7ebf334 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] - php: [8.3] + php: [8.2, 8.3] name: Test with php ${{ matrix.php }} on ${{ matrix.os }} diff --git a/composer.json b/composer.json index d7aaaa4..8011837 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "bin/svgtinyps" ], "require": { - "php": "^8.3", + "php": "^8.2|^8.3", "ext-dom": "*", "srwiez/php-svg-ps-converter": "^1.1", "composer-runtime-api": "^2.2"