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

chore: add github action for release #4659

Merged
merged 6 commits into from
Apr 13, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"overrides": [{
"files": [
"scripts/**",
"smoke-tests/**",
"bin/**",
"test/**"
],
Expand Down
55 changes: 19 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
with:
node-version: 16.x
cache: npm
- run: node ./bin/npm-cli.js run resetdeps
- run: node ./bin/npm-cli.js run lint
- run: node bin/npm-cli.js run resetdeps
- run: node bin/npm-cli.js run lint

check_docs:
runs-on: ubuntu-latest
Expand All @@ -43,40 +43,23 @@ jobs:
with:
node-version: 16.x
cache: npm
- run: node ./bin/npm-cli.js run resetdeps
- run: node ./bin/npm-cli.js run licenses

- run: node bin/npm-cli.js run resetdeps
- run: node bin/npm-cli.js run licenses
smoke-tests:
strategy:
fail-fast: false
matrix:
node-version:
- 12.x
- 14.x
- 16.x
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: cmd
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: node ./bin/npm-cli.js run resetdeps
- run: node ./bin/npm-cli.js run smoke-tests --ignore-scripts
- name: git status
if: matrix.platform.os != 'windows-latest'
run: node scripts/git-dirty.js
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- run: node bin/npm-cli.js run resetdeps
- run: node bin/npm-cli.js test -w smoke-tests --ignore-scripts
- name: git status
if: matrix.platform.os != 'windows-latest'
run: node scripts/git-dirty.js

test:
strategy:
Expand Down Expand Up @@ -107,8 +90,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: node ./bin/npm-cli.js run resetdeps
- run: node ./bin/npm-cli.js run test --ignore-scripts
- run: node bin/npm-cli.js run resetdeps
- run: node bin/npm-cli.js run test --ignore-scripts
- name: git status
if: matrix.platform.os != 'windows-latest'
run: node scripts/git-dirty.js
118 changes: 118 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Release - cli

on:
workflow_dispatch:
pull_request:
schedule:
# 08:00am UTC everyday: https://crontab.guru/#0_8_*_*_*
# https://dateful.com/convert/utc?t=8am
- cron: "0 8 * * *"

jobs:
lint-all:
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
startsWith(github.head_ref, 'release/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- run: node bin/npm-cli.js run resetdeps
- run: node bin/npm-cli.js run lint-all --ignore-scripts

smoke-publish:
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
startsWith(github.head_ref, 'release/')
strategy:
fail-fast: false
matrix:
node-version:
- 12.13.0
- 12.x
- 14.15.0
- 14.x
- 16.0.0
- 16.x
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
# XXX: this should be possible in windows also
# but resetdeps cant be a bash script
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is almost ready to run in Windows, but needs resetdeps and the rm -rf to be cross platform. I'm saving that for a future PR.

runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "ops+npm-cli@npmjs.com"
git config --global user.name "npm cli ops bot"
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: npm
- name: Pack
run: |
NPM_VERSION="$(node bin/npm-cli.js --version)-$GITHUB_SHA.0"
node bin/npm-cli.js version $NPM_VERSION --ignore-scripts
node bin/npm-cli.js run resetdeps
git clean -fd
node bin/npm-cli.js ls --production >/dev/null
node bin/npm-cli.js prune --production --no-save --no-audit --no-fund
node scripts/git-dirty.js
node bin/npm-cli.js pack --pack-destination=$RUNNER_TEMP
node bin/npm-cli.js install -g $RUNNER_TEMP/npm-$NPM_VERSION.tgz
node bin/npm-cli.js install -w smoke-tests --ignore-scripts --no-audit --no-fund
rm -rf {lib,bin,index.js}
SMOKE_PUBLISH_NPM=1 npm test -w smoke-tests --ignore-scripts

test-all:
if: |
github.event_name == 'schedule' ||
github.event_name == 'workflow_dispatch' ||
startsWith(github.head_ref, 'release/')
strategy:
fail-fast: false
matrix:
node-version:
- 12.13.0
- 12.x
- 14.15.0
- 14.x
- 16.0.0
- 16.x
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: cmd
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: node bin/npm-cli.js run resetdeps
- run: node bin/npm-cli.js link -f --ignore-scripts
- run: node bin/npm-cli.js run test-all --ignore-scripts
- name: git status
if: matrix.platform.os != 'windows-latest'
run: node scripts/git-dirty.js
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,14 @@ docs/content/commands/npm-%.md: docs/bin/config-doc-command.js lib/commands/%.js

freshdocs:
touch lib/utils/config/definitions.js
touch "docs/bin/*.js"
touch docs/bin/*.js
make docs

test: deps
node bin/npm-cli.js test

smoke-tests: deps
node bin/npm-cli.js run smoke-tests
test-all: deps
node bin/npm-cli.js run test-all

ls-ok:
node . ls --production >/dev/null
node bin/npm-cli.js ls --production >/dev/null

gitclean:
git clean -fd
Expand All @@ -100,16 +97,15 @@ link: uninstall
node bin/npm-cli.js link -f --ignore-scripts

prune: deps
node bin/npm-cli.js prune --production --no-save --no-audit
@[[ "$(shell git status -s)" != "" ]] && echo "ERR: found unpruned files" && exit 1 || echo "git status is clean"
node bin/npm-cli.js prune --production --no-save --no-audit --no-fund
node scripts/git-dirty.js

publish: gitclean ls-ok link test smoke-tests docs prune
@git push origin :v$(shell node bin/npm-cli.js --no-timing -v) 2>&1 || true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our release process always includes us creating the tag before running this step, so this was unnecessary. It wasn't erroring but would show the message that the tag already existed.

publish: gitclean ls-ok link test-all docs prune
git push origin $(BRANCH) &&\
git push origin --tags &&\
node bin/npm-cli.js publish --tag=$(PUBLISHTAG)

release: gitclean ls-ok docs prune
@bash scripts/release.sh

.PHONY: all latest install dev link docs clean uninstall test man docsclean release ls-ok deps prune freshdocs
.PHONY: all latest install dev link docs clean uninstall test-all man docsclean release ls-ok deps prune freshdocs
10 changes: 9 additions & 1 deletion lib/utils/update-notifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const stat = promisify(require('fs').stat)
const writeFile = promisify(require('fs').writeFile)
const { resolve } = require('path')

const SKIP = Symbol('SKIP')

const isGlobalNpmUpdate = npm => {
return npm.flatOptions.global &&
['install', 'update'].includes(npm.command) &&
Expand Down Expand Up @@ -38,7 +40,7 @@ const updateNotifier = async (npm, spec = 'latest') => {
if (!npm.config.get('update-notifier') ||
isGlobalNpmUpdate(npm) ||
ciDetect()) {
return null
return SKIP
}

// if we're on a prerelease train, then updates are coming fast
Expand Down Expand Up @@ -118,6 +120,12 @@ const updateNotifier = async (npm, spec = 'latest') => {
// only update the notification timeout if we actually finished checking
module.exports = async npm => {
const notification = await updateNotifier(npm)

// dont write the file if we skipped checking altogether
if (notification === SKIP) {
return null
}

// intentional. do not await this. it's a best-effort update. if this
// fails, it's ok. might be using /dev/null as the cache or something weird
// like that.
Expand Down
1 change: 1 addition & 0 deletions node_modules/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ readme*
/side-channel
/simple-concat
/simple-get
/smoke-tests
/source-map
/source-map-support
/space-separated-tokens
Expand Down
45 changes: 42 additions & 3 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"license": "Artistic-2.0",
"workspaces": [
"docs",
"smoke-tests",
"workspaces/*"
],
"dependencies": {
Expand Down Expand Up @@ -5795,7 +5796,8 @@
},
"node_modules/promise-all-reject-late": {
"version": "1.0.1",
"license": "ISC",
"resolved": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz",
"integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw==",
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
Expand Down Expand Up @@ -6282,8 +6284,9 @@
},
"node_modules/rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"inBundle": true,
"license": "ISC",
"dependencies": {
"glob": "^7.1.3"
},
Expand Down Expand Up @@ -6447,6 +6450,10 @@
"npm": ">= 3.0.0"
}
},
"node_modules/smoke-tests": {
"resolved": "smoke-tests",
"link": true
},
"node_modules/socks": {
"version": "2.6.2",
"inBundle": true,
Expand Down Expand Up @@ -9741,6 +9748,22 @@
"url": "https://github.com/sponsors/wooorm"
}
},
"smoke-tests": {
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/promise-spawn": "^3.0.0",
"@npmcli/template-oss": "3.3.2",
"minify-registry-metadata": "^2.2.0",
"rimraf": "^3.0.2",
"tap": "^16.0.1",
"which": "^2.0.2"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
}
},
"workspaces/arborist": {
"name": "@npmcli/arborist",
"version": "5.0.4",
Expand Down Expand Up @@ -13798,7 +13821,9 @@
}
},
"promise-all-reject-late": {
"version": "1.0.1"
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/promise-all-reject-late/-/promise-all-reject-late-1.0.1.tgz",
"integrity": "sha512-vuf0Lf0lOxyQREH7GDIOUMLS7kz+gs8i6B+Yi8dC68a2sychGrHTJYghMBD6k7eUcH0H5P73EckCA48xijWqXw=="
},
"promise-call-limit": {
"version": "1.0.1"
Expand Down Expand Up @@ -14123,6 +14148,8 @@
},
"rimraf": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
"requires": {
"glob": "^7.1.3"
}
Expand Down Expand Up @@ -14198,6 +14225,18 @@
"smart-buffer": {
"version": "4.2.0"
},
"smoke-tests": {
"version": "file:smoke-tests",
"requires": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/promise-spawn": "^3.0.0",
"@npmcli/template-oss": "3.3.2",
"minify-registry-metadata": "^2.2.0",
"rimraf": "^3.0.2",
"tap": "^16.0.1",
"which": "^2.0.2"
}
},
"socks": {
"version": "2.6.2",
"requires": {
Expand Down
Loading