diff --git a/.github/actions/cache-gradle-build/action.yml b/.github/actions/cache-gradle-build/action.yml index dfaf467..6a64d0b 100644 --- a/.github/actions/cache-gradle-build/action.yml +++ b/.github/actions/cache-gradle-build/action.yml @@ -1,25 +1,20 @@ -name: Cache Gradle build directories -description: Restore or save module build/ trees for faster CI Gradle jobs - -inputs: - save: - description: Save cache at job end. Use false on parallel jobs that share the same cache key. - required: false - default: "true" +name: Restore Gradle build directories +description: Restore module build/ trees for faster CI Gradle jobs outputs: cache-hit: - description: Whether build directories were restored from cache + description: Whether an exact cache key match was restored value: ${{ steps.cache.outputs.cache-hit }} + cache-primary-key: + description: Primary cache key to pass to the save action after the build + value: ${{ steps.cache.outputs.cache-primary-key }} runs: using: composite steps: - - uses: actions/cache@v5 + - uses: actions/cache/restore@v5 id: cache with: - lookup-only: ${{ inputs.save != 'true' }} - save-always: ${{ inputs.save == 'true' }} path: | app/desktop/build app/shared/build diff --git a/.github/actions/save-gradle-build-cache/action.yml b/.github/actions/save-gradle-build-cache/action.yml new file mode 100644 index 0000000..0e96563 --- /dev/null +++ b/.github/actions/save-gradle-build-cache/action.yml @@ -0,0 +1,20 @@ +name: Save Gradle build directories +description: Save module build/ trees after a Gradle build (always runs, even on cache hit) + +inputs: + primary-key: + description: cache-primary-key from cache-gradle-build restore step + required: true + +runs: + using: composite + steps: + - uses: actions/cache/save@v5 + with: + key: ${{ inputs.primary-key }} + path: | + app/desktop/build + app/shared/build + app/android/build + utils/shared/build + utils/android/build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4cfd53e..ccfeeab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -85,10 +85,13 @@ jobs: with: version: ${{ needs.resolve-version.outputs.version }} - uses: ./.github/actions/cache-gradle-build - with: - save: "true" + id: gradle-build-cache - name: Compile and ProGuard release desktop jars run: ./gradlew :app:desktop:exportReleaseProguardForCi --no-daemon --console=plain + - uses: ./.github/actions/save-gradle-build-cache + if: always() + with: + primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} - uses: actions/upload-artifact@v5 with: name: desktop-proguard @@ -108,8 +111,7 @@ jobs: with: version: ${{ needs.resolve-version.outputs.version }} - uses: ./.github/actions/cache-gradle-build - with: - save: "true" + id: gradle-build-cache - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-pc-windows-msvc @@ -134,6 +136,10 @@ jobs: path: app/desktop/windows-setup/target/release/*.exe if-no-files-found: error retention-days: 3 + - uses: ./.github/actions/save-gradle-build-cache + if: always() + with: + primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} windows-package: name: Windows (${{ matrix.label }}) @@ -169,8 +175,6 @@ jobs: with: version: ${{ needs.resolve-version.outputs.version }} - uses: ./.github/actions/cache-gradle-build - with: - save: "false" - uses: actions/download-artifact@v5 with: name: desktop-proguard @@ -229,8 +233,7 @@ jobs: with: version: ${{ needs.resolve-version.outputs.version }} - uses: ./.github/actions/cache-gradle-build - with: - save: ${{ matrix.arch == 'arm64' }} + id: gradle-build-cache - uses: actions/download-artifact@v5 with: name: desktop-proguard @@ -262,6 +265,10 @@ jobs: name: macos-${{ matrix.arch }} path: app/desktop/build/distributions/release/*-macOS-${{ matrix.arch }}.dmg if-no-files-found: error + - uses: ./.github/actions/save-gradle-build-cache + if: always() && matrix.arch == 'arm64' + with: + primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} linux: name: Linux (${{ matrix.label }}) @@ -289,8 +296,7 @@ jobs: with: version: ${{ needs.resolve-version.outputs.version }} - uses: ./.github/actions/cache-gradle-build - with: - save: ${{ matrix.arch == 'arm64' }} + id: gradle-build-cache - uses: actions/download-artifact@v5 with: name: desktop-proguard @@ -320,6 +326,10 @@ jobs: app/desktop/build/distributions/release/*-linux-${{ matrix.arch }}.rpm app/desktop/build/distributions/release/*-linux-${{ matrix.arch }}.AppImage if-no-files-found: error + - uses: ./.github/actions/save-gradle-build-cache + if: always() && matrix.arch == 'arm64' + with: + primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} android: name: Android @@ -334,8 +344,6 @@ jobs: with: version: ${{ needs.resolve-version.outputs.version }} - uses: ./.github/actions/cache-gradle-build - with: - save: "false" - name: Cache Android SDK extras uses: actions/cache@v5 with: