From 02c2803c9e555156773fa601edef9ce082a114dc Mon Sep 17 00:00:00 2001 From: Finn Voorhees Date: Fri, 5 Apr 2024 19:35:28 +0100 Subject: [PATCH] Cache actions dependencies --- .github/workflows/Build.yml | 39 ++++++++++++++++++++++++++------- .github/workflows/BuildDocs.yml | 39 ++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 1956246b..6e59e106 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -7,21 +7,44 @@ on: jobs: Build: - runs-on: macos-14 + runs-on: macos-latest steps: - uses: actions/checkout@v3 - - name: Install nightly Swift + - name: Get latest Swift version + id: swift-version run: | DOWNLOAD=$(curl "https://raw.githubusercontent.com/apple/swift-org-website/main/_data/builds/development/xcode.yml" | yq '.[0].download') DIR=$(curl "https://raw.githubusercontent.com/apple/swift-org-website/main/_data/builds/development/xcode.yml" | yq '.[0].dir') - curl -L -sS --show-error --fail "https://download.swift.org/development/xcode/$DIR/$DOWNLOAD" -o $DOWNLOAD - sudo installer -store -pkg $DOWNLOAD -target / - - name: Select Xcode - run: sudo xcode-select -s '/Applications/Xcode_15.3.app' - - name: Install Playdate SDK + echo "swift=https://download.swift.org/development/xcode/$DIR/$DOWNLOAD" >> $GITHUB_OUTPUT + - name: Cache Swift + id: cache-swift + uses: actions/cache@v3 + with: + path: swift.pkg + key: ${{ steps.swift-version.outputs.swift }} + - if: ${{ steps.cache-swift.outputs.cache-hit != 'true' }} + name: Download latest Swift version + run: curl -L -sS --show-error --fail ${{ steps.swift-version.outputs.swift }} -o swift.pkg + - name: Install latest Swift version + run: sudo installer -store -pkg swift.pkg -target / + - name: Get latest Playdate SDK version + id: playdate-version + run: | + echo "playdate=$(curl -Ls -o /dev/null -w %{url_effective} -X HEAD https://download.panic.com/playdate_sdk/PlaydateSDK-latest.zip)" >> $GITHUB_OUTPUT + - name: Cache Playdate + id: cache-playdate + uses: actions/cache@v3 + with: + path: PlaydateSDK.pkg + key: ${{ steps.playdate-version.outputs.playdate }} + - if: ${{ steps.cache-playdate.outputs.cache-hit != 'true' }} + name: Download Playdate SDK run: | curl -L -sS --show-error --fail "https://download.panic.com/playdate_sdk/PlaydateSDK-latest.zip" -o PlaydateSDK-latest.zip unzip PlaydateSDK-latest.zip - sudo installer -store -pkg "PlaydateSDK.pkg" -target / + - name: Install Playdate SDK + run: sudo installer -store -pkg "PlaydateSDK.pkg" -target / + - name: Select Xcode + run: sudo xcode-select -s '/Applications/Xcode_15.3.app' - name: Build run: set -o pipefail && $(xcrun -f swift -toolchain "swift latest") build -c release | xcbeautify --renderer github-actions diff --git a/.github/workflows/BuildDocs.yml b/.github/workflows/BuildDocs.yml index 9484ce90..2e6aff9d 100644 --- a/.github/workflows/BuildDocs.yml +++ b/.github/workflows/BuildDocs.yml @@ -14,22 +14,45 @@ jobs: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: macos-14 + runs-on: macos-latest steps: - uses: actions/checkout@v3 - - name: Install nightly Swift + - name: Get latest Swift version + id: swift-version run: | DOWNLOAD=$(curl "https://raw.githubusercontent.com/apple/swift-org-website/main/_data/builds/development/xcode.yml" | yq '.[0].download') DIR=$(curl "https://raw.githubusercontent.com/apple/swift-org-website/main/_data/builds/development/xcode.yml" | yq '.[0].dir') - curl -L -sS --show-error --fail "https://download.swift.org/development/xcode/$DIR/$DOWNLOAD" -o $DOWNLOAD - sudo installer -store -pkg $DOWNLOAD -target / - - name: Select Xcode - run: sudo xcode-select -s '/Applications/Xcode_15.3.app' - - name: Install Playdate SDK + echo "swift=https://download.swift.org/development/xcode/$DIR/$DOWNLOAD" >> $GITHUB_OUTPUT + - name: Cache Swift + id: cache-swift + uses: actions/cache@v3 + with: + path: swift.pkg + key: ${{ steps.swift-version.outputs.swift }} + - if: ${{ steps.cache-swift.outputs.cache-hit != 'true' }} + name: Download latest Swift version + run: curl -L -sS --show-error --fail ${{ steps.swift-version.outputs.swift }} -o swift.pkg + - name: Install latest Swift version + run: sudo installer -store -pkg swift.pkg -target / + - name: Get latest Playdate SDK version + id: playdate-version + run: | + echo "playdate=$(curl -Ls -o /dev/null -w %{url_effective} -X HEAD https://download.panic.com/playdate_sdk/PlaydateSDK-latest.zip)" >> $GITHUB_OUTPUT + - name: Cache Playdate + id: cache-playdate + uses: actions/cache@v3 + with: + path: PlaydateSDK.pkg + key: ${{ steps.playdate-version.outputs.playdate }} + - if: ${{ steps.cache-playdate.outputs.cache-hit != 'true' }} + name: Download Playdate SDK run: | curl -L -sS --show-error --fail "https://download.panic.com/playdate_sdk/PlaydateSDK-latest.zip" -o PlaydateSDK-latest.zip unzip PlaydateSDK-latest.zip - sudo installer -store -pkg "PlaydateSDK.pkg" -target / + - name: Install Playdate SDK + run: sudo installer -store -pkg "PlaydateSDK.pkg" -target / + - name: Select Xcode + run: sudo xcode-select -s '/Applications/Xcode_15.3.app' - name: Build run: | xcodebuild docbuild -scheme PlaydateKit \