From 0c19b130bc154135208071a540d4b89ed79a2a11 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Feb 2024 16:56:00 +0100 Subject: [PATCH 1/6] Fix when labels is not provided --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index e512009..6c5fadc 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -88,7 +88,7 @@ $pull_request | Format-List Write-Output '::endgroup::' Write-Output '::group::Pull request - Labels' -$labels = @() +$labels = @('') $labels += $pull_request.labels.name $labels | Format-List Write-Output '::endgroup::' From 7474592f19b2ca15a4574e6b262aa4c220e91887 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Feb 2024 17:07:44 +0100 Subject: [PATCH 2/6] an empty trippledot lable --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 6c5fadc..499e9be 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -88,7 +88,7 @@ $pull_request | Format-List Write-Output '::endgroup::' Write-Output '::group::Pull request - Labels' -$labels = @('') +$labels = @('...') $labels += $pull_request.labels.name $labels | Format-List Write-Output '::endgroup::' From a101bd8db895c7477766eaed783219ed67ca9795 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Feb 2024 17:13:54 +0100 Subject: [PATCH 3/6] Fix --- README.md | 58 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 84bacc5..6a48248 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,28 @@ Auto-Release follows: - [GitHub Flow specifications](https://docs.github.com/en/get-started/using-github/github-flow) - [Continiuous Delivery practices](https://en.wikipedia.org/wiki/Continuous_delivery) + +## How it works + +The workflow will trigger on pull requests to the main branch. + +The following labels will inform the action what kind of release to create: +- For a major release, and increasing the first number in the version use: + - `major` + - `breaking` +- For a minor release, and increasing the second number in the version. + - `minor` + - `feature` + - `improvement` + - `enhancement` +- For a patch release, and increases the third number in the version. + - `patch` + - `bug` + - `fix` + +When a pull request is closed, the action will create a release based on the labels and clean up any previous prereleases that was created. + + ## Usage The action have the following parameters: @@ -25,7 +47,21 @@ The action have the following parameters: | `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 | | `VersionPrefix` | The prefix to use for the version number. | `v` | false | -### Example +### Configuration file + +The configuration file is a YAML file that can be used to configure the action. +The file can be placed in the `.github` directory of the repository and named `auto-release.yml`. +The file can be used to configure the action using the same parameters as the action inputs. + +```yaml +DatePrereleaseFormat: 'yyyyMMddHHmm' +IncrementalPrerelease: false +VersionPrefix: '' +``` + +This example uses the date format for the prerelease, disables the incremental prerelease and removes the version prefix. + +## Example Add a workflow in you repository using the following example: ```yaml @@ -57,23 +93,3 @@ jobs: env: GH_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication ``` - -## How it works - -The workflow will trigger on pull requests to the main branch. - -The following labels will inform the action what kind of release to create: -- For a major release, and increasing the first number in the version use: - - `major` - - `breaking` -- For a minor release, and increasing the second number in the version. - - `minor` - - `feature` - - `improvement` - - `enhancement` -- For a patch release, and increases the third number in the version. - - `patch` - - `bug` - - `fix` - -When a pull request is closed, the action will create a release based on the labels and clean up any previous prereleases that was created. From 16f3626613619bf61f545241a9fe19c1450b66d2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Feb 2024 17:16:27 +0100 Subject: [PATCH 4/6] ws --- scripts/main.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 166452c..499e9be 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -93,7 +93,6 @@ $labels += $pull_request.labels.name $labels | Format-List Write-Output '::endgroup::' - $majorTags = @('major', 'breaking') $minorTags = @('minor', 'feature', 'improvement') $patchTags = @('patch', 'fix', 'bug') From 1f5f32514bff2434c19126a40cc709724084a871 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Feb 2024 17:30:33 +0100 Subject: [PATCH 5/6] Fix --- scripts/main.ps1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 499e9be..5461f49 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -88,23 +88,23 @@ $pull_request | Format-List Write-Output '::endgroup::' Write-Output '::group::Pull request - Labels' -$labels = @('...') +$labels = @() $labels += $pull_request.labels.name $labels | Format-List Write-Output '::endgroup::' -$majorTags = @('major', 'breaking') -$minorTags = @('minor', 'feature', 'improvement') -$patchTags = @('patch', 'fix', 'bug') +$majorLabels = @('major', 'breaking') +$minorLabels = @('minor', 'feature', 'improvement') +$patchLabels = @('patch', 'fix', 'bug') $createRelease = $pull_request.base.ref -eq 'main' -and ($pull_request.merged).ToString() -eq 'True' $closedPullRequest = $pull_request.state -eq 'closed' -and ($pull_request.merged).ToString() -eq 'False' $preRelease = $labels -Contains 'prerelease' $createPrerelease = $preRelease -and -not $createRelease -and -not $closedPullRequest -$majorRelease = (Compare-Object -ReferenceObject $labels -DifferenceObject $majorTags -IncludeEqual -ExcludeDifferent).Count -gt 0 -$minorRelease = (Compare-Object -ReferenceObject $labels -DifferenceObject $minorTags -IncludeEqual -ExcludeDifferent).Count -gt 0 -and -not $majorRelease -$patchRelease = (Compare-Object -ReferenceObject $labels -DifferenceObject $patchTags -IncludeEqual -ExcludeDifferent).Count -gt 0 -and -not $majorRelease -and -not $minorRelease +$majorRelease = ($labels | Where-Object { $majorLabels -contains $_ }).Count -gt 0 +$minorRelease = ($labels | Where-Object { $minorLabels -contains $_ }).Count -gt 0 -and -not $majorRelease +$patchRelease = ($labels | Where-Object { $patchLabels -contains $_ }).Count -gt 0 -and -not $majorRelease -and -not $minorRelease Write-Output '-------------------------------------------------' Write-Output "Create a release: [$createRelease]" From d1cb3cc4e8b220ea494ed533bf94c5334add75fd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 17 Feb 2024 17:33:33 +0100 Subject: [PATCH 6/6] ws --- scripts/main.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ad570ad..5461f49 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -97,7 +97,6 @@ $majorLabels = @('major', 'breaking') $minorLabels = @('minor', 'feature', 'improvement') $patchLabels = @('patch', 'fix', 'bug') - $createRelease = $pull_request.base.ref -eq 'main' -and ($pull_request.merged).ToString() -eq 'True' $closedPullRequest = $pull_request.state -eq 'closed' -and ($pull_request.merged).ToString() -eq 'False' $preRelease = $labels -Contains 'prerelease'