Update checkout + node actions in workflows, use .nvmrc + caching (#387)

* Update workflows to resolve node version from nvmrc

* Bump actions/checkout to v3

* Add step to resolve package.json engines.npm version specifically

* Remove wrong committed .npmrc file
This commit is contained in:
Lovekesh Kumar 2022-10-02 20:34:13 +05:30 committed by GitHub
parent e95e615c18
commit 6cdd0898c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 70 additions and 60 deletions

View file

@ -7,21 +7,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Read Node.js & NPM versions - name: Setup Node
run: | uses: actions/setup-node@v3.5.0
echo "##[set-output name=NODE;]$(cat package.json | jq -r '.engines.node')"
echo "##[set-output name=NPM;]$(cat package.json | jq -r '.engines.npm')"
id: versions
- name: Use correct Node.js version
uses: actions/setup-node@v2
with: with:
node-version: "${{ steps.versions.outputs.NODE }}" node-version-file: ".nvmrc"
cache: npm
- name: Use correct NPM version - name: Setup NPM
run: npm i -g npm@"${{ steps.versions.outputs.NPM }}" run: |
NPM_VERSION=$(jq -r .engines.npm package.json)
NPM_VERSION=${NPM_VERSION/\^/}
if [ "$(npm --version)" != "$NPM_VERSION" ]; then
npm install -g npm@$NPM_VERSION && npm --version
else
echo "NPM version is same as package.json engines.npm"
fi
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci

View file

@ -10,21 +10,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Read Node.js & NPM versions - name: Setup Node
run: | uses: actions/setup-node@v3.5.0
echo "##[set-output name=NODE;]$(cat package.json | jq -r '.engines.node')"
echo "##[set-output name=NPM;]$(cat package.json | jq -r '.engines.npm')"
id: versions
- name: Use correct Node.js version
uses: actions/setup-node@v2
with: with:
node-version: "${{ steps.versions.outputs.NODE }}" node-version-file: ".nvmrc"
cache: npm
- name: Use correct NPM version - name: Setup NPM
run: npm i -g npm@"${{ steps.versions.outputs.NPM }}" run: |
NPM_VERSION=$(jq -r .engines.npm package.json)
NPM_VERSION=${NPM_VERSION/\^/}
if [ "$(npm --version)" != "$NPM_VERSION" ]; then
npm install -g npm@$NPM_VERSION && npm --version
else
echo "NPM version is same as package.json engines.npm"
fi
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci

View file

@ -7,21 +7,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Read Node.js & NPM versions - name: Setup Node
run: | uses: actions/setup-node@v3.5.0
echo "##[set-output name=NODE;]$(cat package.json | jq -r '.engines.node')"
echo "##[set-output name=NPM;]$(cat package.json | jq -r '.engines.npm')"
id: versions
- name: Use correct Node.js version
uses: actions/setup-node@v2
with: with:
node-version: "${{ steps.versions.outputs.NODE }}" node-version-file: ".nvmrc"
cache: npm
- name: Use correct NPM version - name: Setup NPM
run: npm i -g npm@"${{ steps.versions.outputs.NPM }}" run: |
NPM_VERSION=$(jq -r .engines.npm package.json)
NPM_VERSION=${NPM_VERSION/\^/}
if [ "$(npm --version)" != "$NPM_VERSION" ]; then
npm install -g npm@$NPM_VERSION && npm --version
else
echo "NPM version is same as package.json engines.npm"
fi
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@ -33,21 +35,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Read Node.js & NPM versions - name: Setup Node
run: | uses: actions/setup-node@v3.5.0
echo "##[set-output name=NODE;]$(cat package.json | jq -r '.engines.node')"
echo "##[set-output name=NPM;]$(cat package.json | jq -r '.engines.npm')"
id: versions
- name: Use correct Node.js version
uses: actions/setup-node@v2
with: with:
node-version: "${{ steps.versions.outputs.NODE }}" node-version-file: ".nvmrc"
cache: npm
- name: Use correct NPM version - name: Setup NPM
run: npm i -g npm@"${{ steps.versions.outputs.NPM }}" run: |
NPM_VERSION=$(jq -r .engines.npm package.json)
NPM_VERSION=${NPM_VERSION/\^/}
if [ "$(npm --version)" != "$NPM_VERSION" ]; then
npm install -g npm@$NPM_VERSION && npm --version
else
echo "NPM version is same as package.json engines.npm"
fi
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@ -59,21 +63,23 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Read Node.js & NPM versions - name: Setup Node
run: | uses: actions/setup-node@v3.5.0
echo "##[set-output name=NODE;]$(cat package.json | jq -r '.engines.node')"
echo "##[set-output name=NPM;]$(cat package.json | jq -r '.engines.npm')"
id: versions
- name: Use correct Node.js version
uses: actions/setup-node@v2
with: with:
node-version: "${{ steps.versions.outputs.NODE }}" node-version-file: ".nvmrc"
cache: npm
- name: Use correct NPM version - name: Setup NPM
run: npm i -g npm@"${{ steps.versions.outputs.NPM }}" run: |
NPM_VERSION=$(jq -r .engines.npm package.json)
NPM_VERSION=${NPM_VERSION/\^/}
if [ "$(npm --version)" != "$NPM_VERSION" ]; then
npm install -g npm@$NPM_VERSION && npm --version
else
echo "NPM version is same as package.json engines.npm"
fi
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci