Skip to content

Commit

Permalink
Add support for yarn 3+ (#14)
Browse files Browse the repository at this point in the history
* Accept a yarn version

* remove default yarn version

* Base install script based on the major version of yarn

This assumes that yarn will correctly pick up the intended version from
the source files.

* Do we even need to enable corepack?

* Also cache the .yarn/cache directory

* Remove the redundant `--frozen-lockfile` flag from the `yarn install` command

In yarn 3 and later, the `--frozen-lockfile` flag is an alias for `--immutable`
  • Loading branch information
soberstadt authored Mar 4, 2024
1 parent dde3055 commit 4739ab5
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions yarn/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,29 @@ runs:
path: node_modules
key: ${{ runner.os }}-${{ inputs.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ inputs.node-version }}-node-modules-
- run: yarn install --frozen-lockfile --prefer-offline --immutable
${{ runner.os }}-${{ inputs.node-version }}-node-modules-
- name: Cache yarn cache
id: cache-yarn-cache
uses: actions/cache@v3
with:
path: .yarn/cache
key: ${{ runner.os }}-${{ inputs.node-version }}-yarn-cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ inputs.node-version }}-yarn-cache-
- run: |
yarn_version=$(yarn --version)
major_version=$(echo "${yarn_version}" | cut -d. -f1)
if [[ "${major_version}" != "1" ]]; then
yarn install --immutable
else
yarn install --frozen-lockfile --prefer-offline --immutable
fi
shell: bash
inputs:
node-version:
description: Version of node to use
required: false
default: '18'
default: "18"
branding:
icon: life-buoy
color: orange

0 comments on commit 4739ab5

Please sign in to comment.