Skip to content

Commit

Permalink
major: use new conventions (#17)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: use new conventions
  • Loading branch information
ArwynFr committed May 22, 2023
1 parent 37ab0ca commit 9b8d734
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 42 deletions.
40 changes: 20 additions & 20 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
= Conventional Versioning: new release
:toc: preamble

This Github action creates a new Github Release, using https://semver.org/[Semantic Versioning] and https://www.conventionalcommits.org/[Conventional Commits] messages.
This Github action creates a new Github Release, using https://semver.org/[Semantic Versioning].

WARNING: Version 2 of this action dropped support from conventional commits 1.0.0.

== About
=== Current version
The current version is based on latest Github Release *tag name*.
If there is no release or the tag is not a valid version number, the action will default to `0.0.0`.
Current version should not include any prefix.
Values such as `v1.2.3` or `ver-1.2.3` are **not** understood and will default to `0.0.0`.
If there is no release or the tag is not a valid version number, the action will default to `0.1.0`. Current version should not include any prefix, values such as `v1.2.3` or `ver-1.2.3` are **not** understood by this action and will have the action use default value of `0.1.0`.

=== Change type
The type of version change is based on HEAD commit message, taken from https://docs.github.com/en/actions/learn-github-actions/contexts[`github.event` context]:
The type of version change is based on HEAD commit message, taken from https://docs.github.com/en/actions/learn-github-actions/contexts[`github.event` context]. The commit message is expected to follow the format `<type>: message`. The type of version change depends on the type provided:

* `patch` will bump the patch version number
* `minor` will bump the minor version number
* `major` will bump the major version number

* `Fix` will bump the patch version
* `Feature` will bump the minor version
* `Breaking` will bump major version
If type is not found the action will then look for long-format tokens in the commit message:

Breaking changes can either use the explicit notation (`BREAKING CHANGE:` in the body or footer) or the bang notation (`type(scope)!: description` in the first line).
Feature must use the `feat` type value.
If the message is not understood as a valid conventional commit, the change type will default to `Fix`.
* `BREAKING CHANGE:` for major updates
* `NEW FEATURE:` for minor updates

If the message is not understood as a valid conventional commit, the change type will default to `patch`.
You should consider using this action in conjunction with another one enforcing commit message format.

=== Release creation
This action uses https://cli.github.com/[Github CLI] and needs **not** to checkout the repository.
The release will autogenerate the notes, tag the source code, and include source archives to the release by default.
You can add additional files using the `pattern` input variable:

* Version `v0` matches the syntax for https://cli.github.com/manual/gh_release_create[`gh release create`] command and does not expand wildcards
* Version `v1` will expand wildcards so you can use patterns such as `*.zip`
You can add additional files using the `pattern` input variable.
This pattern matches the syntax for https://cli.github.com/manual/gh_release_create[`gh release create`] command.

== Inputs
Pattern::
Wildcard pattern used to add files in the release.
_None_

== Outputs
Current-version::
Current version found in the repository, format `1.2.3`.

Bump-type::
Type of version bumping, one of the following: `Breaking`, `Feature`, `Fix`.
Type of version bumping, one of the following: `major`, `minor`, `patch`.

Next-version::
Version number for the new release, format `1.2.3`.
Expand All @@ -51,7 +51,7 @@ This action will create a release with artifacts for each commit on the master b
```yml
on:
push:
branches: [master]
branches: [main]

jobs:

Expand All @@ -67,7 +67,7 @@ jobs:
name: my-artifact
path: artifacts

- uses: arwynfr/actions-conventional-versioning@v1
- uses: arwynfr/actions-conventional-versioning@v2
with:
pattern: artifacts/*
```
Expand Down
17 changes: 9 additions & 8 deletions functions/Get-VersionBumpType.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ param (
$CommitMessage
)

if ($CommitMessage -match 'BREAKING CHANGE:') {
return 'Breaking'
$ConventionalCommit = $CommitMessage -match '^(patch|minor|major): '

if ($ConventionalCommit) {
return $Matches[1]
}

$private:commitFirstLine = ($CommitMessage -split [Environment]::NewLine)[0]
if (($private:commitFirstLine -split ": ")[0].EndsWith('!')) {
return 'Breaking'
if ($CommitMessage -match 'BREAKING CHANGE:') {
return 'major'
}

if ($private:commitFirstLine.StartsWith("feat")) {
return 'Feature'
if ($CommitMessage -match 'NEW FEATURE:') {
return 'minor'
}

return 'Fix'
return 'patch'
4 changes: 2 additions & 2 deletions functions/New-SemVer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ param (
$BumpType
)

if ('Breaking' -eq $BumpType) {
if ('major' -eq $BumpType) {
return [semver]::new($Version.Major + 1)
}

if ('Feature' -eq $BumpType) {
if ('minor' -eq $BumpType) {
return [semver]::new($Version.Major, $Version.Minor + 1)
}

Expand Down
29 changes: 17 additions & 12 deletions get-newVersion/README.adoc
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
= Conventional Versioning: get new version
:toc: preamble

This Github action calculates a new product version, using https://semver.org/[Semantic Versioning] and https://www.conventionalcommits.org/[Conventional Commits] messages.
This Github action calculates a new product version, using https://semver.org/[Semantic Versioning].

WARNING: Version 2 of this action dropped support from conventional commits 1.0.0.

== About
=== Current version
The current version is based on latest Github Release *tag name*.
If there is no release or the tag is not a valid version number, the action will default to `0.0.0`. Current version should not include any prefix, values such as `v1.2.3` or `ver-1.2.3` are **not** understood by this action and will have the action use default value of `0.0.0`.
If there is no release or the tag is not a valid version number, the action will default to `0.1.0`. Current version should not include any prefix, values such as `v1.2.3` or `ver-1.2.3` are **not** understood by this action and will have the action use default value of `0.1.0`.

=== Change type
The type of version change is based on HEAD commit message, taken from https://docs.github.com/en/actions/learn-github-actions/contexts[`github.event` context]:
The type of version change is based on HEAD commit message, taken from https://docs.github.com/en/actions/learn-github-actions/contexts[`github.event` context]. The commit message is expected to follow the format `<type>: message`. The type of version change depends on the type provided:

* `patch` will bump the patch version number
* `minor` will bump the minor version number
* `major` will bump the major version number

If type is not found the action will then look for long-format tokens in the commit message:

* `Fix` will bump the patch version
* `Feature` will bump the minor version
* `Breaking` will bump major version
* `BREAKING CHANGE:` for major updates
* `NEW FEATURE:` for minor updates

Breaking changes can either use the explicit notation (`BREAKING CHANGE:` in the body or footer) or the bang notation (`type(scope)!: description` in the first line).
Feature must use the `feat` type value.
If the message is not understood as a valid conventional commit, the change type will default to `Fix`.
If the message is not understood as a valid conventional commit, the change type will default to `patch`.
You should consider using this action in conjunction with another one enforcing commit message format.

=== Release creation
Expand All @@ -34,7 +39,7 @@ Current-version::
Current version found in the repository, format `1.2.3`.

Bump-type::
Type of version bumping, one of the following: `Breaking`, `Feature`, `Fix`.
Type of version bumping, one of the following: `major`, `minor`, `patch`.

Next-version::
Version number for the new release, format `1.2.3`.
Expand All @@ -46,7 +51,7 @@ This action will create a release with artifacts for each commit on the master b
```yml
on:
push:
branches: [master]
branches: [main]

jobs:

Expand All @@ -55,7 +60,7 @@ jobs:
name: 'Compute new version'
steps:

- uses: arwynfr/actions-conventional-versioning/get-newVersion@1.0.0
- uses: arwynfr/actions-conventional-versioning/get-newVersion@v2
id: next-version

- run: echo ${{ steps.next-version.output.next-version }}
Expand Down

0 comments on commit 9b8d734

Please sign in to comment.