fix(post): Create a tag before makeing a release
This commit is contained in:
parent
f148a61339
commit
3f8559731f
30
src/post.js
30
src/post.js
@ -24,12 +24,18 @@ module.exports = function (config, cb) {
|
||||
if (err) return cb(err)
|
||||
|
||||
var ghRepo = parseSlug(pkg.repository.url)
|
||||
var tag = {
|
||||
owner: ghRepo[0],
|
||||
repo: ghRepo[1],
|
||||
ref: 'refs/heads/v' + pkg.version,
|
||||
sha: hash
|
||||
}
|
||||
var release = {
|
||||
owner: ghRepo[0],
|
||||
repo: ghRepo[1],
|
||||
name: 'v' + pkg.version,
|
||||
tag_name: 'v' + pkg.version,
|
||||
target_commitish: hash,
|
||||
name: 'v' + pkg.version,
|
||||
target_commitish: options.branch,
|
||||
draft: !!options.debug,
|
||||
body: log
|
||||
}
|
||||
@ -43,18 +49,18 @@ module.exports = function (config, cb) {
|
||||
token: options.githubToken
|
||||
})
|
||||
|
||||
github.repos.createRelease(release, function (err, res) {
|
||||
if (options.debug) {
|
||||
return github.repos.createRelease(release, function (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
cb(null, true, release)
|
||||
})
|
||||
}
|
||||
|
||||
github.gitdata.createReference(tag, function (err) {
|
||||
if (err) return cb(err)
|
||||
if (options.debug) return cb(null, true, release)
|
||||
|
||||
var editingRelease = {
|
||||
owner: ghRepo[0],
|
||||
repo: ghRepo[1],
|
||||
id: res.id,
|
||||
target_commitish: options.branch
|
||||
}
|
||||
|
||||
github.repos.editRelease(editingRelease, function (err) {
|
||||
github.repos.createRelease(release, function (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
cb(null, true, release)
|
||||
|
@ -3,11 +3,13 @@ module.exports = function () {
|
||||
authenticate: function () {
|
||||
return true
|
||||
},
|
||||
gitdata: {
|
||||
createReference: function (release, cb) {
|
||||
cb(null)
|
||||
}
|
||||
},
|
||||
repos: {
|
||||
createRelease: function (release, cb) {
|
||||
cb(null, {id: 1})
|
||||
},
|
||||
editRelease: function (release, cb) {
|
||||
cb(null)
|
||||
}
|
||||
}
|
||||
|
@ -23,14 +23,14 @@ var defaultRelease = {
|
||||
repo: 'up',
|
||||
name: 'v1.0.0',
|
||||
tag_name: 'v1.0.0',
|
||||
target_commitish: 'bar',
|
||||
target_commitish: 'master',
|
||||
body: 'the log'
|
||||
}
|
||||
|
||||
test('full post run', function (t) {
|
||||
t.test('in debug mode w/o token', function (tt) {
|
||||
post({
|
||||
options: {debug: true},
|
||||
options: {debug: true, branch: 'master'},
|
||||
pkg: pkg,
|
||||
plugins: plugins
|
||||
}, function (err, published, release) {
|
||||
@ -44,7 +44,7 @@ test('full post run', function (t) {
|
||||
|
||||
t.test('in debug mode w/token', function (tt) {
|
||||
post({
|
||||
options: {debug: true, githubToken: 'yo'},
|
||||
options: {debug: true, githubToken: 'yo', branch: 'master'},
|
||||
pkg: pkg,
|
||||
plugins: plugins
|
||||
}, function (err, published, release) {
|
||||
@ -58,7 +58,7 @@ test('full post run', function (t) {
|
||||
|
||||
t.test('production', function (tt) {
|
||||
post({
|
||||
options: {githubToken: 'yo'},
|
||||
options: {githubToken: 'yo', branch: 'master'},
|
||||
pkg: pkg,
|
||||
plugins: plugins
|
||||
}, function (err, published, release) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user