fix: simplify logic fallback version logic, remove default from action.yaml

releases/v3
Patrick Dreker 2022-11-23 14:56:33 +01:00
parent fc4c16dd9b
commit ecddc26229
No known key found for this signature in database
GPG Key ID: 5492FCBC60059A4E
2 changed files with 67 additions and 65 deletions

View File

@ -1,156 +1,155 @@
name: 'Conventional Changelog Action' name: "Conventional Changelog Action"
description: 'Bump version, tag commit and generates changelog with conventional commits.' description: "Bump version, tag commit and generates changelog with conventional commits."
author: 'Tycho Bokdam' author: "Tycho Bokdam"
runs: runs:
using: 'node16' using: "node16"
main: 'src/index.js' main: "src/index.js"
branding: branding:
icon: 'edit' icon: "edit"
color: 'red' color: "red"
inputs: inputs:
github-token: github-token:
description: 'Github token' description: "Github token"
default: ${{ github.token }} default: ${{ github.token }}
required: false required: false
git-message: git-message:
description: 'Commit message to use' description: "Commit message to use"
default: 'chore(release): {version}' default: "chore(release): {version}"
required: false required: false
git-user-name: git-user-name:
description: 'The git user.name to use for the commit' description: "The git user.name to use for the commit"
default: 'Conventional Changelog Action' default: "Conventional Changelog Action"
required: false required: false
git-user-email: git-user-email:
description: 'The git user.email to use for the commit' description: "The git user.email to use for the commit"
default: 'conventional.changelog.action@github.com' default: "conventional.changelog.action@github.com"
required: false required: false
git-pull-method: git-pull-method:
description: 'The git pull method used when pulling all changes from remote' description: "The git pull method used when pulling all changes from remote"
default: '--ff-only' default: "--ff-only"
required: false required: false
git-push: git-push:
description: 'Should all the git changes be push' description: "Should all the git changes be push"
default: 'true' default: "true"
required: false required: false
git-branch: git-branch:
description: 'The git branch to be pushed' description: "The git branch to be pushed"
default: ${{ github.ref }} default: ${{ github.ref }}
required: false required: false
preset: preset:
description: 'The preset from Conventional Changelog to use' description: "The preset from Conventional Changelog to use"
default: 'angular' default: "angular"
required: false required: false
tag-prefix: tag-prefix:
description: 'Prefix that is used for the git tag' description: "Prefix that is used for the git tag"
default: 'v' default: "v"
required: false required: false
output-file: output-file:
description: 'File to output the changelog to' description: "File to output the changelog to"
default: 'CHANGELOG.md' default: "CHANGELOG.md"
required: false required: false
release-count: release-count:
description: 'Number of releases to preserve in changelog' description: "Number of releases to preserve in changelog"
default: '5' default: "5"
required: false required: false
version-file: version-file:
description: 'The path to the file that contains the version to bump (supports comma-separated list of file paths)' description: "The path to the file that contains the version to bump (supports comma-separated list of file paths)"
default: './package.json' default: "./package.json"
required: false required: false
version-path: version-path:
description: 'The place inside the version file to bump' description: "The place inside the version file to bump"
default: 'version' default: "version"
required: false required: false
skip-git-pull: skip-git-pull:
description: 'Do not pull the repo before tagging. Ensure you full cloned the repo in the first place to get tags' description: "Do not pull the repo before tagging. Ensure you full cloned the repo in the first place to get tags"
default: 'false' default: "false"
required: false required: false
skip-on-empty: skip-on-empty:
description: 'Do nothing when the changelog from the latest release is empty' description: "Do nothing when the changelog from the latest release is empty"
default: 'true' default: "true"
required: false required: false
skip-version-file: skip-version-file:
description: 'Do not update the version file' description: "Do not update the version file"
default: 'false' default: "false"
required: false required: false
skip-commit: skip-commit:
description: 'Do create a release commit' description: "Do create a release commit"
default: 'false' default: "false"
required: false required: false
pre-commit: pre-commit:
description: 'Path to the pre-commit script file' description: "Path to the pre-commit script file"
required: false required: false
fallback-version: fallback-version:
description: 'The fallback version, if no older one can be detected, or if it is the first one' description: "The fallback version, if no older one can be detected, or if it is the first one"
default: '0.1.0'
required: false required: false
config-file-path: config-file-path:
description: 'Path to the conventional changelog config file. If set, the preset setting will be ignored' description: "Path to the conventional changelog config file. If set, the preset setting will be ignored"
required: false required: false
pre-changelog-generation: pre-changelog-generation:
description: 'Path to the pre-changelog-generation script file' description: "Path to the pre-changelog-generation script file"
required: false required: false
git-url: git-url:
description: 'Git Url' description: "Git Url"
default: 'github.com' default: "github.com"
required: false required: false
git-path: git-path:
description: 'Path filter for the logs. If set, only commits that match the path filter will be considered' description: "Path filter for the logs. If set, only commits that match the path filter will be considered"
default: '' default: ""
required: false required: false
skip-ci: skip-ci:
description: 'Adds [skip ci] to commit message, to avoid triggering a new build' description: "Adds [skip ci] to commit message, to avoid triggering a new build"
default: 'true' default: "true"
required: false required: false
create-summary: create-summary:
description: 'Adds the generated changelog as Action Summary' description: "Adds the generated changelog as Action Summary"
default: 'false' default: "false"
required: false required: false
pre-release: pre-release:
description: 'Marks the release as pre-release' description: "Marks the release as pre-release"
default: 'false' default: "false"
required: false required: false
pre-release-identifier: pre-release-identifier:
description: 'The identifier to use for pre-releases' description: "The identifier to use for pre-releases"
default: 'rc' default: "rc"
required: false required: false
outputs: outputs:
changelog: changelog:
description: 'The generated changelog for the new version' description: "The generated changelog for the new version"
clean_changelog: clean_changelog:
description: 'The generated changelog for the new version without the version name in it' description: "The generated changelog for the new version without the version name in it"
version: version:
description: 'The new version' description: "The new version"
tag: tag:
description: 'The name of the generated tag' description: "The name of the generated tag"
skipped: skipped:
description: 'boolean to check if this step have been skipped' description: "boolean to check if this step have been skipped"

View File

@ -19,11 +19,14 @@ module.exports = async (releaseType, version) => {
if (version) { if (version) {
newVersion = semver.inc(version, (prerelease ? 'prerelease' : releaseType), identifier) newVersion = semver.inc(version, (prerelease ? 'prerelease' : releaseType), identifier)
} else { } else {
let version = semver.valid(core.getInput('fallback-version'))
if (version) { const fallbackVersion = core.getInput('fallback-version')
newVersion = version
} else { if (fallbackVersion) {
newVersion = semver.valid(fallbackVersion)
}
if (!newVersion) {
// default // default
newVersion = (prerelease ? `0.1.0-${identifier}.0` : '0.1.0') newVersion = (prerelease ? `0.1.0-${identifier}.0` : '0.1.0')
} }