Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: install npm in CI based on node version #354

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,54 @@ jobs:
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: 18.x
- name: Install npm@latest
check-latest: contains('18.x', '.x')

# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
if: |
matrix.platform.os == 'windows-latest' && (
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
)
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package

# Start on Node 10 because we dont test on anything lower
- name: Install npm@7 on Node 10
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v10.')
id: npm-7
run: |
npm i --prefer-online --no-fund --no-audit -g npm@7
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@8 on Node 12
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v12.')
id: npm-8
run: |
npm i --prefer-online --no-fund --no-audit -g npm@8
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@9 on Node 14/16/18.0
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
id: npm-9
run: |
npm i --prefer-online --no-fund --no-audit -g npm@9
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@latest on Node
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest

- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
90 changes: 82 additions & 8 deletions .github/workflows/ci-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,54 @@ jobs:
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: 18.x
- name: Install npm@latest
check-latest: contains('18.x', '.x')

# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
if: |
matrix.platform.os == 'windows-latest' && (
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
)
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package

# Start on Node 10 because we dont test on anything lower
- name: Install npm@7 on Node 10
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v10.')
id: npm-7
run: |
npm i --prefer-online --no-fund --no-audit -g npm@7
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@8 on Node 12
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v12.')
id: npm-8
run: |
npm i --prefer-online --no-fund --no-audit -g npm@8
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@9 on Node 14/16/18.0
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
id: npm-9
run: |
npm i --prefer-online --no-fund --no-audit -g npm@9
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@latest on Node
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest

- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down Expand Up @@ -181,24 +225,54 @@ jobs:
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')

# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
if: |
matrix.platform.os == 'windows-latest' && (
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
)
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
if: ${{ !startsWith(matrix.node-version, '10.') }}

# Start on Node 10 because we dont test on anything lower
- name: Install npm@7 on Node 10
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v10.')
id: npm-7
run: |
npm i --prefer-online --no-fund --no-audit -g npm@7
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@8 on Node 12
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v12.')
id: npm-8
run: |
npm i --prefer-online --no-fund --no-audit -g npm@8
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@9 on Node 14/16/18.0
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
id: npm-9
run: |
npm i --prefer-online --no-fund --no-audit -g npm@9
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@latest on Node
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest

- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down
90 changes: 82 additions & 8 deletions .github/workflows/ci-test-workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,54 @@ jobs:
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: 18.x
- name: Install npm@latest
check-latest: contains('18.x', '.x')

# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
if: |
matrix.platform.os == 'windows-latest' && (
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
)
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package

# Start on Node 10 because we dont test on anything lower
- name: Install npm@7 on Node 10
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v10.')
id: npm-7
run: |
npm i --prefer-online --no-fund --no-audit -g npm@7
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@8 on Node 12
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v12.')
id: npm-8
run: |
npm i --prefer-online --no-fund --no-audit -g npm@8
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@9 on Node 14/16/18.0
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
id: npm-9
run: |
npm i --prefer-online --no-fund --no-audit -g npm@9
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@latest on Node
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest

- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down Expand Up @@ -82,24 +126,54 @@ jobs:
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')

# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
if: |
matrix.platform.os == 'windows-latest' && (
startsWith(steps.node.outputs.node-version, 'v10.') || startsWith(steps.node.outputs.node-version, 'v12.') || startsWith(steps.node.outputs.node-version, 'v14.')
)
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install npm@7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Install npm@latest
if: ${{ !startsWith(matrix.node-version, '10.') }}

# Start on Node 10 because we dont test on anything lower
- name: Install npm@7 on Node 10
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v10.')
id: npm-7
run: |
npm i --prefer-online --no-fund --no-audit -g npm@7
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@8 on Node 12
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v12.')
id: npm-8
run: |
npm i --prefer-online --no-fund --no-audit -g npm@8
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@9 on Node 14/16/18.0
shell: bash
if: startsWith(steps.node.outputs.node-version, 'v14.') || startsWith(steps.node.outputs.node-version, 'v16.') || startsWith(steps.node.outputs.node-version, 'v18.0.')
id: npm-9
run: |
npm i --prefer-online --no-fund --no-audit -g npm@9
echo "updated=true" >> "$GITHUB_OUTPUT"

- name: Install npm@latest on Node
if: ${{ !(steps.npm-7.outputs.updated || steps.npm-8.outputs.updated || steps.npm-9.outputs.updated) }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest

- name: npm Version
run: npm -v
- name: Install Dependencies
Expand Down