From 757a7dce3550ffddf5076e999586a8dc143d6e80 Mon Sep 17 00:00:00 2001 From: Elliott Kember Date: Fri, 16 Apr 2021 10:50:38 -0700 Subject: [PATCH] Yarn cacher action --- .github/workflows/build.yml | 4 +- .github/workflows/update-cache.yml | 59 ++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/update-cache.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce68bd4..44e6f1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,8 @@ name: Build/release # Further down the build, we check whether the tag key is present. on: push: - branches: - - master + tags: + - "v*" jobs: release: diff --git a/.github/workflows/update-cache.yml b/.github/workflows/update-cache.yml new file mode 100644 index 0000000..f44f3cd --- /dev/null +++ b/.github/workflows/update-cache.yml @@ -0,0 +1,59 @@ +# Commented while we wait for the new Electron versions to ship + +name: Update yarn cache + +on: + push: + branches: + - "master" + paths: + - "yarn" + - "yarn.lock" + +jobs: + release: + runs-on: ${{ matrix.os }} + if: startsWith(github.event.head_commit.message, 'v') + + timeout-minutes: 30 + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + strategy: + matrix: + os: [macos-10.15, windows-latest] + + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + + - uses: actions/setup-python@v2 + with: + python-version: "3.x" # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: "x64" # optional x64 or x86. Defaults to x64 if not specified + + - name: Install Node.js, NPM and Yarn for Mac + if: startsWith(matrix.os, 'macos') + uses: actions/setup-node@v1 + with: + node-version: 15 # v15 causes "Error: Command failed: yarn" in Windows? + + - name: Install Node.js, NPM and Yarn for Windows + if: startsWith(matrix.os, 'windows') + uses: actions/setup-node@v1 + with: + node-version: 12 # v15 causes "Error: Command failed: yarn" in Windows? + + # Cache both Yarn cache directory and node_modules + - uses: c-hive/gha-yarn-cache@v1 + - uses: actions/cache@v2.1.0 + with: + path: "**/node_modules" + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + + - name: yarn --frozen-lockfile + uses: nick-invision/retry@v2 + with: + timeout_minutes: 10 + max_attempts: 3 + command: yarn --frozen-lockfile