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:
|
||||
- npm install vue vue-template-compiler
|
||||
script:
|
||||
- cp ./scripts/.npmrc.template $HOME/.npmrc
|
||||
- COVERAGE=true npm run test
|
||||
- npm run codecov
|
||||
- npm run pub-with-ci
|
||||
- bash ./scripts/deploy-to-gh-pages.sh
|
||||
env:
|
||||
matrix:
|
||||
|
|
|
@ -25,6 +25,7 @@ const fs = require('fs')
|
|||
const rimraf = require('rimraf')
|
||||
const replaceLib = require('./replaceLib')
|
||||
const stripCode = require('gulp-strip-code')
|
||||
const compareVersions = require('compare-versions')
|
||||
|
||||
const cwd = process.cwd()
|
||||
const libDir = path.join(cwd, 'lib')
|
||||
|
@ -173,7 +174,6 @@ function githubRelease () {
|
|||
const [_, owner, repo] = execSync('git remote get-url origin') // eslint-disable-line
|
||||
.toString()
|
||||
.match(/github.com[:/](.+)\/(.+)\.git/)
|
||||
|
||||
github.repos.createRelease({
|
||||
owner,
|
||||
repo,
|
||||
|
@ -236,6 +236,9 @@ function pub (done) {
|
|||
}
|
||||
})
|
||||
}
|
||||
// gulp.task('test', () => {
|
||||
// githubRelease()
|
||||
// })
|
||||
|
||||
gulp.task('dist', ['compile'], (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 () {
|
||||
console.log(chalk.bgRed('!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'))
|
||||
console.log(chalk.bgRed('!! `npm publish` is forbidden for this package. !!'))
|
||||
|
|
|
@ -29,8 +29,9 @@
|
|||
"copy": "node scripts/run.js copy-html",
|
||||
"compile": "node antd-tools/cli/run.js compile",
|
||||
"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",
|
||||
"pre-publish": "npm run test && node ./scripts/prepub",
|
||||
"pre-publish": "node ./scripts/prepub",
|
||||
"dist": "node antd-tools/cli/run.js dist",
|
||||
"lint": "eslint -c ./.eslintrc --fix --ext .jsx,.js,.vue ./components",
|
||||
"lint:style": "stylelint \"./examples/**/*.less\" --fix --syntax less",
|
||||
|
@ -89,6 +90,7 @@
|
|||
"codecov": "^3.0.0",
|
||||
"colorful": "^2.1.0",
|
||||
"commander": "^2.15.0",
|
||||
"compare-versions": "^3.3.0",
|
||||
"cross-env": "^5.1.4",
|
||||
"css-loader": "^0.28.7",
|
||||
"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