From 1cf5ae32f32517a783ca1a774a229b0e2d68d220 Mon Sep 17 00:00:00 2001 From: rahimahisah17 Date: Thu, 3 Sep 2026 19:34:00 +0100 Subject: [PATCH 1/2] Cache Box PHAR in reusable binary workflow --- .github/workflows/reusable-build-binary.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-build-binary.yml b/.github/workflows/reusable-build-binary.yml index d82cc7f..c31937f 100644 --- a/.github/workflows/reusable-build-binary.yml +++ b/.github/workflows/reusable-build-binary.yml @@ -33,8 +33,25 @@ jobs: # Note: do NOT turn on the requirement checker in the box config as it is no longer # compatible with PHP < 7.2. + - name: Get latest Box version + id: box-version + run: | + latest_url=$(curl -Ls -o /dev/null -w '%{url_effective}' https://github.com/box-project/box/releases/latest) + echo "version=${latest_url##*/}" >> "$GITHUB_OUTPUT" + + - name: Cache Box PHAR + id: cache-box + uses: actions/cache@v4 + with: + path: box.phar + key: box-phar-${{ steps.box-version.outputs.version }} + - name: Install Box - run: wget https://github.com/box-project/box/releases/latest/download/box.phar -O box.phar && chmod 0755 box.phar && pwd + if: steps.cache-box.outputs.cache-hit != 'true' + run: wget https://github.com/box-project/box/releases/latest/download/box.phar -O box.phar + + - name: Set Box permissions + run: chmod 0755 box.phar - name: Validate configuration run: php box.phar validate -i box.json From 1483ce1e44ca94da0c89d2b425991788f0f7f955 Mon Sep 17 00:00:00 2001 From: rahimahisah17 Date: Fri, 4 Sep 2026 22:00:13 +0100 Subject: [PATCH 2/2] Address review feedback for Box cache --- .github/workflows/release.yml | 2 ++ .github/workflows/reusable-build-binary.yml | 22 +++++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 386fdca..a1ea86f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,8 @@ jobs: name: Build binary uses: ./.github/workflows/reusable-build-binary.yml + with: + use-cache: false verify: name: Validate binary on PHP ${{ matrix.php }} diff --git a/.github/workflows/reusable-build-binary.yml b/.github/workflows/reusable-build-binary.yml index c31937f..553c457 100644 --- a/.github/workflows/reusable-build-binary.yml +++ b/.github/workflows/reusable-build-binary.yml @@ -2,6 +2,12 @@ name: Build Binary on: workflow_call: + inputs: + use-cache: + description: "Whether to use the Box PHAR cache" + required: false + type: boolean + default: true jobs: bundle: @@ -31,8 +37,6 @@ jobs: # Bust the cache at least once a month - output format: YYYY-MM. custom-cache-suffix: $(date -u "+%Y-%m") - # Note: do NOT turn on the requirement checker in the box config as it is no longer - # compatible with PHP < 7.2. - name: Get latest Box version id: box-version run: | @@ -41,18 +45,28 @@ jobs: - name: Cache Box PHAR id: cache-box - uses: actions/cache@v4 + if: inputs.use-cache + uses: actions/cache/restore@v4 with: path: box.phar key: box-phar-${{ steps.box-version.outputs.version }} - name: Install Box - if: steps.cache-box.outputs.cache-hit != 'true' + if: ${{ !inputs.use-cache || steps.cache-box.outputs.cache-hit != 'true' }} run: wget https://github.com/box-project/box/releases/latest/download/box.phar -O box.phar + - name: Save Box PHAR cache + if: inputs.use-cache && steps.cache-box.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: box.phar + key: box-phar-${{ steps.box-version.outputs.version }} + - name: Set Box permissions run: chmod 0755 box.phar + # Note: do NOT turn on the requirement checker in the box config as it is no longer + # compatible with PHP < 7.2. - name: Validate configuration run: php box.phar validate -i box.json