feat: Added skip commit and skip tag

When skip commit is enabled no new commit will be created, when skip tag is enabled no new tag will be created
releases/v3
Tycho Bokdam 2020-06-28 20:20:21 +02:00
parent 9ee9c27448
commit 3eab2417f9
No known key found for this signature in database
GPG Key ID: A0FAE77C8CDF33C7
2 changed files with 34 additions and 10 deletions

View File

@ -61,6 +61,14 @@ inputs:
skip-on-empty:
description: 'Do nothing when the changelog from the latest release is empty'
skip-commit:
description: 'Do create a release commit'
default: 'false'
required: false
skip-tag:
description: 'Do not create an new tag'
default: 'false'
required: false
@ -74,4 +82,6 @@ outputs:
tag:
description: 'The name of the generated tag'
skipped:
description: 'boolean to check if this step have been skipped'
description: 'boolean to check if this step have been skipped'
skipped:
description: 'boolean to check if this step have been skipped'

View File

@ -63,20 +63,34 @@ async function run() {
await changelog.generateFileChangelog(tagPrefix, preset, jsonPackage, outputFile, releaseCount)
}
core.info('Push all changes')
const gitTag = `${tagPrefix}${versioning.newVersion}`
// Add changed files to git
await git.add('.')
await git.commit(commitMessage.replace('{version}', `${tagPrefix}${jsonPackage.version}`))
await git.createTag(`${tagPrefix}${jsonPackage.version}`)
await git.push()
if (!skipCommit) {
// Add changed files to git
await git.add('.')
await git.commit(gitCommitMessage.replace('{version}', gitTag))
}
if (!skipTag) {
// Only create the tag if skip tag is false
await git.createTag(gitTag)
}
if (!skipCommit || !skipTag) {
core.info('Push all changes')
await git.push()
}
// Set outputs so other actions (for example actions/create-release) can use it
core.setOutput('changelog', stringChangelog)
// Removes the version number from the changelog
core.setOutput('clean_changelog', cleanChangelog)
core.setOutput('version', jsonPackage.version)
core.setOutput('tag', `${tagPrefix}${jsonPackage.version}`)
core.setOutput('version', versioning.newVersion)
// Only add the output tag if we did not skip it
if (!skipTag) {
core.setOutput('tag', gitTag)
}
core.setOutput('skipped', 'false')
})