Skip to content

Commit 93d444d

Browse files
🚀 [Feature] Date-based prerelease suffix (#14)
- Resolves #8 but instead of having to choose incremental or date-based, you can use both. Other: - Fixes an issue where the action main script did not run. Path was incorrect when running in a remote repo. - Fixes a log issue where the setting of the incremental feature enablement was showing incorrect value.
1 parent 4a17003 commit 93d444d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The action have the following parameters:
1919
| --- | --- | --- | --- |
2020
| `AutoPatching` | Control wether to automatically handle patches. If disabled, the action will only create a patch release if the pull request has a 'patch' label. | `true` | false |
2121
| `IncrementalPrerelease` | Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. | `true` | false |
22+
| `DataPrereleaseFormat` | The format to use for the prerelease number using [.NET DateTime format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings). | `''` | false |
2223
| `VersionPrefix` | The prefix to use for the version number. | `v` | false |
2324

2425
### Example

action.yml

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch.
1515
required: false
1616
default: 'true'
17+
DatePrereleaseFormat:
18+
description: If specified, uses a date based prerelease scheme. The format should be a valid .NET format string like 'yyyyMMddHHmm'.
19+
required: false
20+
default: ''
1721
VersionPrefix:
1822
description: The prefix to use for the version number.
1923
required: false
@@ -28,4 +32,5 @@ runs:
2832
AutoPatching: ${{ inputs.AutoPatching }}
2933
IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }}
3034
VersionPrefix: ${{ inputs.VersionPrefix }}
31-
run: ./scripts/main.ps1
35+
DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }}
36+
run: . "$env:GITHUB_ACTION_PATH\scripts\main.ps1"

scripts/main.ps1

+10-1
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ Write-Output '::endgroup::'
1717

1818
$autoPatching = $env:AutoPatching -eq 'true'
1919
$incrementalPrerelease = $env:IncrementalPrerelease -eq 'true'
20+
$datePrereleaseFormat = $env:DatePrereleaseFormat
2021
$versionPrefix = $env:VersionPrefix
22+
2123
Write-Output '-------------------------------------------------'
2224
Write-Output "Auto patching enabled: [$autoPatching]"
23-
Write-Output "Incremental prerelease enabled: [$autoPatching]"
25+
Write-Output "Incremental prerelease enabled: [$incrementalPrerelease]"
26+
Write-Output "Date-based prerelease format: [$datePrereleaseFormat]"
2427
Write-Output "Version prefix: [$versionPrefix]"
2528
Write-Output '-------------------------------------------------'
2629

@@ -139,6 +142,12 @@ if ($preRelease) {
139142
$newVersion = "$newVersion-$preReleaseName"
140143
Write-Output "Partly new version: [$newVersion]"
141144

145+
if ($env:DatePrereleaseFormat | IsNotNullOrEmpty) {
146+
Write-Output "Using date-based prerelease: [$datePrereleaseFormat]."
147+
$newVersion = $newVersion + '.' + (Get-Date -Format $datePrereleaseFormat)
148+
Write-Output "Partly new version: [$newVersion]"
149+
}
150+
142151
if ($incrementalPrerelease) {
143152
$prereleases = $releases | Where-Object { $_.tagName -like "$newVersion*" } | Sort-Object -Descending -Property tagName
144153
Write-Output "Prereleases: [$($prereleases.count)]"

0 commit comments

Comments
 (0)