commit
24dece1cca
11
README.md
11
README.md
|
@ -8,9 +8,10 @@ This action will bump version, tag commit and generate a changelog with conventi
|
|||
- **Optional** `git-message`: Commit message that is used when committing the changelog.
|
||||
- **Optional** `preset`: Preset that is used from conventional commits. Default `angular`.
|
||||
- **Optional** `tag-prefix`: Prefix for the git tags. Default `v`.
|
||||
- **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`, when providing `false` no file will be generated / updated.
|
||||
- **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`, when providing `'false'` no file will be generated / updated.
|
||||
- **Optional** `release-count`: Number of releases to preserve in changelog. Default `5`, use `0` to regenerate all.
|
||||
- **Optional** `package-json`: The path to the package.json to use. Default `./package.json`.
|
||||
- **Optional** `skip-on-empty`: Boolean to specify if you want to skip empty release (no-changelog generated). This case occured when you push `chore` commit with `angular` for example. Default `'false'`.
|
||||
|
||||
## Outputs
|
||||
|
||||
|
@ -18,10 +19,12 @@ This action will bump version, tag commit and generate a changelog with conventi
|
|||
- `clean_changelog`: The generated changelog for the new version without the version name in it (Better for Github releases)
|
||||
- `version`: The new version.
|
||||
- `tag`: The name of the generated tag.
|
||||
- `skipped`: Boolean (`'true'` or `'false'`) specifying if this step have been skipped
|
||||
|
||||
## Example usages
|
||||
|
||||
Uses all the defaults
|
||||
|
||||
```yaml
|
||||
- name: Conventional Changelog Action
|
||||
uses: TriPSs/conventional-changelog-action@v2
|
||||
|
@ -30,6 +33,7 @@ Uses all the defaults
|
|||
```
|
||||
|
||||
Overwrite everything
|
||||
|
||||
```yaml
|
||||
- name: Conventional Changelog Action
|
||||
uses: TriPSs/conventional-changelog-action@v2
|
||||
|
@ -41,9 +45,11 @@ Overwrite everything
|
|||
output-file: 'CHANGELOG.md'
|
||||
release-count: '5'
|
||||
package-json: './package.json'
|
||||
skip-on-empty: 'false'
|
||||
```
|
||||
|
||||
No file changelog
|
||||
|
||||
```yaml
|
||||
- name: Conventional Changelog Action
|
||||
uses: TriPSs/conventional-changelog-action@v2
|
||||
|
@ -53,6 +59,7 @@ No file changelog
|
|||
```
|
||||
|
||||
Github releases
|
||||
|
||||
```yaml
|
||||
- name: Conventional Changelog Action
|
||||
id: changelog
|
||||
|
@ -60,9 +67,11 @@ Github releases
|
|||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
output-file: 'false'
|
||||
skip-on-empty: 'true'
|
||||
|
||||
- name: Create Release
|
||||
uses: actions/create-release@v1
|
||||
if: ${{ !steps.changelog.outputs.skipped }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.github_token }}
|
||||
with:
|
||||
|
|
|
@ -44,6 +44,11 @@ inputs:
|
|||
default: './package.json'
|
||||
required: false
|
||||
|
||||
skip-on-empty:
|
||||
description: 'Do nothing when the changelog from the latest release is empty'
|
||||
default: 'false'
|
||||
required: false
|
||||
|
||||
outputs:
|
||||
changelog:
|
||||
description: 'The generated changelog for the new version'
|
||||
|
@ -53,3 +58,5 @@ outputs:
|
|||
description: 'The new version'
|
||||
tag:
|
||||
description: 'The name of the generated tag'
|
||||
skipped:
|
||||
description: 'boolean to check if this step have been skipped'
|
25
src/index.js
25
src/index.js
|
@ -13,6 +13,7 @@ async function run() {
|
|||
const outputFile = core.getInput('output-file')
|
||||
const releaseCount = core.getInput('release-count')
|
||||
const packageJsonToUse = core.getInput('package-json')
|
||||
const skipOnEmptyRelease = core.getInput('skip-on-empty').toLowerCase() === 'true'
|
||||
|
||||
core.info(`Using "${preset}" preset`)
|
||||
core.info(`Using "${commitMessage}" as commit message`)
|
||||
|
@ -27,9 +28,11 @@ async function run() {
|
|||
conventionalRecommendedBump({ preset, tagPrefix }, async (error, recommendation) => {
|
||||
if (error) {
|
||||
core.setFailed(error.message)
|
||||
return
|
||||
}
|
||||
|
||||
} else {
|
||||
core.info(`Recommended release type: ${recommendation.releaseType}`)
|
||||
recommendation.reason && core.info(`because: ${recommendation.reason}`)
|
||||
|
||||
// Bump the version in the package.json
|
||||
const jsonPackage = packageJson.bump(
|
||||
|
@ -37,6 +40,18 @@ async function run() {
|
|||
recommendation.releaseType,
|
||||
)
|
||||
|
||||
const stringChangelog = await changelog.generateStringChangelog(tagPrefix, preset, jsonPackage, 1)
|
||||
core.info('Changelog generated')
|
||||
core.info(stringChangelog)
|
||||
|
||||
const cleanChangelog = stringChangelog.split('\n').slice(3).join('\n').trim()
|
||||
|
||||
if (skipOnEmptyRelease && cleanChangelog === '') {
|
||||
core.info('Generated changelog is empty and skip-on-empty has been activated so we skip this step')
|
||||
core.setOutput('skipped', 'true')
|
||||
return
|
||||
}
|
||||
|
||||
// Update the package.json file
|
||||
packageJson.update(jsonPackage)
|
||||
|
||||
|
@ -48,10 +63,6 @@ async function run() {
|
|||
await changelog.generateFileChangelog(tagPrefix, preset, jsonPackage, outputFile, releaseCount)
|
||||
}
|
||||
|
||||
const stringChangelog = await changelog.generateStringChangelog(tagPrefix, preset, jsonPackage, 1)
|
||||
core.info('Changelog generated')
|
||||
core.info(stringChangelog)
|
||||
|
||||
core.info('Push all changes')
|
||||
|
||||
// Add changed files to git
|
||||
|
@ -63,10 +74,10 @@ async function run() {
|
|||
// 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', stringChangelog.split('\n').slice(3).join('\n'))
|
||||
core.setOutput('clean_changelog', cleanChangelog)
|
||||
core.setOutput('version', jsonPackage.version)
|
||||
core.setOutput('tag', `${tagPrefix}${jsonPackage.version}`)
|
||||
}
|
||||
core.setOutput('skipped', 'false')
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue