chore: update npm publish script
parent
47da43b9c9
commit
42f79ecb23
|
@ -0,0 +1,3 @@
|
||||||
|
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||||
|
loglevel=info
|
||||||
|
registry=https://registry.npmjs.org/
|
|
@ -5,8 +5,10 @@ node_js:
|
||||||
before_script:
|
before_script:
|
||||||
- npm install vue vue-template-compiler
|
- npm install vue vue-template-compiler
|
||||||
script:
|
script:
|
||||||
|
- cp ./scripts/.npmrc.template $HOME/.npmrc
|
||||||
- COVERAGE=true npm run test
|
- COVERAGE=true npm run test
|
||||||
- npm run codecov
|
- npm run codecov
|
||||||
|
- npm run pub-with-ci
|
||||||
- bash ./scripts/deploy-to-gh-pages.sh
|
- bash ./scripts/deploy-to-gh-pages.sh
|
||||||
env:
|
env:
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
@ -25,6 +25,7 @@ const fs = require('fs')
|
||||||
const rimraf = require('rimraf')
|
const rimraf = require('rimraf')
|
||||||
const replaceLib = require('./replaceLib')
|
const replaceLib = require('./replaceLib')
|
||||||
const stripCode = require('gulp-strip-code')
|
const stripCode = require('gulp-strip-code')
|
||||||
|
const compareVersions = require('compare-versions')
|
||||||
|
|
||||||
const cwd = process.cwd()
|
const cwd = process.cwd()
|
||||||
const libDir = path.join(cwd, 'lib')
|
const libDir = path.join(cwd, 'lib')
|
||||||
|
@ -173,7 +174,6 @@ function githubRelease () {
|
||||||
const [_, owner, repo] = execSync('git remote get-url origin') // eslint-disable-line
|
const [_, owner, repo] = execSync('git remote get-url origin') // eslint-disable-line
|
||||||
.toString()
|
.toString()
|
||||||
.match(/github.com[:/](.+)\/(.+)\.git/)
|
.match(/github.com[:/](.+)\/(.+)\.git/)
|
||||||
|
|
||||||
github.repos.createRelease({
|
github.repos.createRelease({
|
||||||
owner,
|
owner,
|
||||||
repo,
|
repo,
|
||||||
|
@ -236,6 +236,9 @@ function pub (done) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// gulp.task('test', () => {
|
||||||
|
// githubRelease()
|
||||||
|
// })
|
||||||
|
|
||||||
gulp.task('dist', ['compile'], (done) => {
|
gulp.task('dist', ['compile'], (done) => {
|
||||||
dist(done)
|
dist(done)
|
||||||
|
@ -261,6 +264,43 @@ gulp.task('pub', ['check-git', 'compile'], (done) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gulp.task('pub-with-ci', (done) => {
|
||||||
|
if (process.env.NPM_TOKEN) {
|
||||||
|
console.log('NPM token found, skip')
|
||||||
|
} else {
|
||||||
|
const github = new GitHub()
|
||||||
|
github.authenticate({
|
||||||
|
type: 'oauth',
|
||||||
|
token: process.env.GITHUB_TOKEN,
|
||||||
|
})
|
||||||
|
const [_, owner, repo] = execSync('git remote get-url origin') // eslint-disable-line
|
||||||
|
.toString()
|
||||||
|
.match(/github.com[:/](.+)\/(.+)\.git/)
|
||||||
|
const getLatestRelease = github.repos.getLatestRelease({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
})
|
||||||
|
const getCommits = github.repos.getCommits({
|
||||||
|
owner,
|
||||||
|
repo,
|
||||||
|
per_page: 1,
|
||||||
|
})
|
||||||
|
Promise.all([getLatestRelease, getCommits]).then(([latestRelease, commits]) => {
|
||||||
|
const preVersion = latestRelease.data.tag_name
|
||||||
|
const { version } = packageJson
|
||||||
|
const [_, newVersion] = commits.data[0].commit.message.trim().match(/bump (.+)/) || []
|
||||||
|
if (compareVersions(version, preVersion) === 1 && newVersion && newVersion.trim() === version) {
|
||||||
|
gulp.run('pub', (err) => {
|
||||||
|
err && console.log('err', err)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('donot need publish' + version)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function reportError () {
|
function reportError () {
|
||||||
console.log(chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'))
|
console.log(chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'))
|
||||||
console.log(chalk.bgRed('!! `npm publish` is forbidden for this package. !!'))
|
console.log(chalk.bgRed('!! `npm publish` is forbidden for this package. !!'))
|
||||||
|
|
|
@ -29,8 +29,9 @@
|
||||||
"copy": "node scripts/run.js copy-html",
|
"copy": "node scripts/run.js copy-html",
|
||||||
"compile": "node antd-tools/cli/run.js compile",
|
"compile": "node antd-tools/cli/run.js compile",
|
||||||
"pub": "node antd-tools/cli/run.js pub",
|
"pub": "node antd-tools/cli/run.js pub",
|
||||||
|
"pub-with-ci": "node antd-tools/cli/run.js pub-with-ci",
|
||||||
"prepublish": "node antd-tools/cli/run.js guard",
|
"prepublish": "node antd-tools/cli/run.js guard",
|
||||||
"pre-publish": "npm run test && node ./scripts/prepub",
|
"pre-publish": "node ./scripts/prepub",
|
||||||
"dist": "node antd-tools/cli/run.js dist",
|
"dist": "node antd-tools/cli/run.js dist",
|
||||||
"lint": "eslint -c ./.eslintrc --fix --ext .jsx,.js,.vue ./components",
|
"lint": "eslint -c ./.eslintrc --fix --ext .jsx,.js,.vue ./components",
|
||||||
"lint:style": "stylelint \"./examples/**/*.less\" --fix --syntax less",
|
"lint:style": "stylelint \"./examples/**/*.less\" --fix --syntax less",
|
||||||
|
@ -89,6 +90,7 @@
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
"colorful": "^2.1.0",
|
"colorful": "^2.1.0",
|
||||||
"commander": "^2.15.0",
|
"commander": "^2.15.0",
|
||||||
|
"compare-versions": "^3.3.0",
|
||||||
"cross-env": "^5.1.4",
|
"cross-env": "^5.1.4",
|
||||||
"css-loader": "^0.28.7",
|
"css-loader": "^0.28.7",
|
||||||
"deep-assign": "^2.0.0",
|
"deep-assign": "^2.0.0",
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
|
||||||
|
loglevel=info
|
||||||
|
registry=https://registry.npmjs.org/
|
Loading…
Reference in New Issue