fix: Test release

releases/v3
Tycho Bokdam 2019-10-18 11:10:48 +02:00
parent 57d7d4594f
commit 1f63990fab
No known key found for this signature in database
GPG Key ID: A0FAE77C8CDF33C7
2 changed files with 77 additions and 44 deletions

View File

@ -1,32 +1,55 @@
const core = require('@actions/core') const core = require('@actions/core')
const exec = require('@actions/exec') const exec = require('@actions/exec')
const git = command => new Promise(async(resolve, reject) => { const { GITHUB_REPOSITORY } = process.env
let myOutput = ''
let myError = ''
const options = { module.exports = new (class Git {
listeners: {
stdout: (data) => { constructor() {
myOutput += data.toString() const githubToken = core.getInput('github-token', { required: true })
},
stderr: (data) => { // Make the Github token secret
myError += data.toString() core.setSecret(githubToken)
},
}, this.config('user.name', 'Conventional Changelog Action')
this.config('user.email', 'conventional.changelog.action@github.com')
this.updateOrigin(`https://${githubToken}@github.com/${GITHUB_REPOSITORY}.git`)
} }
try { exec = command => new Promise(async(resolve, reject) => {
await exec.exec(`git ${command}`, null, options) let myOutput = ''
let myError = ''
resolve(myOutput) const options = {
listeners: {
stdout: (data) => {
myOutput += data.toString()
},
stderr: (data) => {
myError += data.toString()
},
},
}
} catch (e) { try {
reject(e) await exec.exec(`git ${command}`, null, options)
}
})
module.exports = { resolve(myOutput)
} catch (e) {
reject(e)
}
})
/**
* Set a git config prop
*
* @param prop
* @param value
* @returns {*}
*/
config = (prop, value) => this.exec(`config ${prop} "${value}"`)
/** /**
* Add a file to commit * Add a file to commit
@ -34,20 +57,19 @@ module.exports = {
* @param file * @param file
* @returns {*} * @returns {*}
*/ */
add: file => git(`add ${file}`), add = file => this.exec(`add ${file}`)
/** /**
* Commit all changes * Commit all changes
* *
* @param message * @param message
* @param skipBuild
* @param args * @param args
* *
* @returns {*} * @returns {*}
*/ */
commit: (message, skipBuild = true, args = []) => ( commit = (message, args = []) => (
git(`commit -m "${message} ${skipBuild ? '[skip ci]' : ''}" ${args.join(' ')}`) this.exec(`commit -m "${message}" ${args.join(' ')}`)
), )
/** /**
* Push all changes * Push all changes
@ -58,21 +80,35 @@ module.exports = {
* *
* @returns {*} * @returns {*}
*/ */
push: (branch, origin, args = []) => ( push = (branch, origin, args = []) => (
git(`push ${args.join(' ')} ${origin} ${branch}`, { silent: true }) this.exec(`push ${args.join(' ')} ${origin} ${branch}`)
), )
tag: { /**
* Updates the origin remote
*
* @param repo
* @returns {*}
*/
updateOrigin = (repo) => this.exec(`remote set-url origin ${repo}`)
getCurrent: () => git('describe --tags --abbrev=0').toString().trim(), })()
//
getSha: (tag) => git(`rev-list -n 1 ${tag}`).toString().trim(), // module.exports = {
//
latest: () => git('describe --tags $(git rev-list --tags --max-count=1)').toString().trim(), //
//
create: (tag) => git(`tag -a ${tag} -m "${tag}"`), // tag: {
//
update: (tag) => git(`tag -fa ${tag} -m "${tag}"`), // getCurrent: () => git('describe --tags --abbrev=0').toString().trim(),
//
}, // getSha: (tag) => git(`rev-list -n 1 ${tag}`).toString().trim(),
} //
// latest: () => git('describe --tags $(git rev-list --tags --max-count=1)').toString().trim(),
//
// create: (tag) => git(`tag -a ${tag} -m "${tag}"`),
//
// update: (tag) => git(`tag -fa ${tag} -m "${tag}"`),
//
// },
// }

View File

@ -14,9 +14,6 @@ async function run() {
const tagPrefix = core.getInput('tag-prefix') const tagPrefix = core.getInput('tag-prefix')
const preset = core.getInput('preset') const preset = core.getInput('preset')
// Make the Github token secret
core.setSecret(githubToken)
core.info(`Using "${preset}" preset`) core.info(`Using "${preset}" preset`)
conventionalRecommendedBump({ preset }, (error, recommendation) => { conventionalRecommendedBump({ preset }, (error, recommendation) => {