From 2988d93d2ee0cdf8ec071b5ea89fd7070560a67c Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Mon, 31 Mar 2025 00:42:15 -0700 Subject: [PATCH 1/2] Now this is also helpful --- .github/workflows/build.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43e52e7..701444c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,6 +32,11 @@ on: required: false type: string default: "" + cache: + description: Cache build directory + required: false + type: boolean + default: false outputs: version: @@ -80,6 +85,23 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4.2.2 + - if: ${{ inputs.cache == true || inputs.cache == 'true' }} + id: data-dir + shell: bash + run: | + data_dir=$(dirname ${{ matrix.file }})/.esphome + echo "data_dir=$data_dir" >> $GITHUB_OUTPUT + - if: ${{ inputs.cache == true || inputs.cache == 'true' }} + name: Restore build cache directory + id: cache-build-restore + uses: actions/cache/restore@v4.2.3 + with: + path: | + ~/.esphome + ~/.platformio + ${{ steps.data-dir.outputs.data_dir }}/build + ${{ steps.data-dir.outputs.data_dir }}/storage + key: ${{ runner.os }}-esphome-${{ matrix.file }}-${{ inputs.esphome-version }}-build - name: Replace project version run: | sed -i "s/version: dev/version: ${{ needs.prepare.outputs.version }}/g" ${{ matrix.file }} @@ -92,6 +114,17 @@ jobs: complete-manifest: true release-summary: ${{ inputs.release-summary }} release-url: ${{ inputs.release-url }} + - if: ${{ inputs.cache == true || inputs.cache == 'true' }} + name: Save build cache directory + id: cache-build-save + uses: actions/cache/save@v4.2.3 + with: + path: | + ~/.esphome + ~/.platformio + ${{ steps.data-dir.outputs.data_dir }}/build + ${{ steps.data-dir.outputs.data_dir }}/storage + key: ${{ steps.cache-build-restore.outputs.cache-primary-key }} - name: Move files for versioning run: | mkdir -p output/${{ needs.prepare.outputs.version }} From 28cdb751154c9086c42f07a62d6494d1739f9879 Mon Sep 17 00:00:00 2001 From: Jordan Zucker Date: Fri, 4 Apr 2025 10:35:54 -0700 Subject: [PATCH 2/2] Fixing the caching stuff again --- .github/workflows/build.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 701444c..471587e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -101,7 +101,10 @@ jobs: ~/.platformio ${{ steps.data-dir.outputs.data_dir }}/build ${{ steps.data-dir.outputs.data_dir }}/storage - key: ${{ runner.os }}-esphome-${{ matrix.file }}-${{ inputs.esphome-version }}-build + key: ${{ runner.os }}-esphome-${{ matrix.file }}-${{ inputs.esphome-version }}-${{ github.ref }} + restore-keys: | + ${{ runner.os }}-esphome-${{ matrix.file }}-${{ inputs.esphome-version }}-${{ github.ref }} + ${{ runner.os }}-esphome-${{ matrix.file }}-${{ inputs.esphome-version }}- - name: Replace project version run: | sed -i "s/version: dev/version: ${{ needs.prepare.outputs.version }}/g" ${{ matrix.file }}