Skip to content

Commit

Permalink
Merge pull request #61 from theohbrothers/enhancement/generate-add-su…
Browse files Browse the repository at this point in the history
…pport-for-generating-release-notes-with-default-ref-head-if-env-release_tag_ref-is-null-or-undefined

Enhancement (generate): Add support for generating release notes with default ref `HEAD` if `$env:RELEASE_TAG_REF` is null or undefined
  • Loading branch information
joeltimothyoh authored May 19, 2024
2 parents f65e7a9 + f008447 commit c488059
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Releases supports all tag refs. Tags *need not* follow [Semantic Versioning](htt
| Name | Example value | Mandatory | Type |
|:-:|:-:|:-:|:-:|
| `PROJECT_DIRECTORY` | `/path/to/my-project` | true | string |
| `RELEASE_TAG_REF` | `vx.x.x` / `branch` / `HEAD` / `remote/branch` / commit-hash | true | string |
| `RELEASE_TAG_REF` | `vx.x.x` / `branch` / `HEAD` / `remote/branch` / commit-hash | false (Generate), true (Release) | string |

###### Generate

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ Describe "PSRepositoryReleaseManager" -Tag 'Integration' {
$env:RELEASE_NOTES_VARIANT = $null
$env:RELEASE_NOTES_PATH = $null
}
It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY" {
$env:RELEASE_TAG_REF = $null

$stdout = ../src/scripts/ci/Invoke-Generate.ps1
"Generate notes content:" | Write-Verbose
Get-Content -Path "$stdout" | Out-String -Stream | % { $_.Trim() } | ? { $_ } | Write-Host
}
It "Runs Invoke-Generate.ps1 with `$env:PROJECT_DIRECTORY `$env:RELEASE_TAG_REF (HEAD)" {
$env:RELEASE_TAG_REF = 'HEAD'

Expand Down
10 changes: 9 additions & 1 deletion src/scripts/ci/Invoke-Generate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ param()
<# Examples
# Maximum defaults
./Invoke-Generate.ps1
# Default project directory, release notes variant, and release notes path
$env:RELEASE_TAG_REF = 'v1.0.12'
./Invoke-Generate.ps1
Expand Down Expand Up @@ -57,7 +60,12 @@ try {
}
$private:generateArgs = @{
Path = $private:ProjectDir
TagName = $env:RELEASE_TAG_REF
TagName = if ($env:RELEASE_TAG_REF) {
$env:RELEASE_TAG_REF
}else {
"`$env:RELEASE_TAG_REF is null or undefined. Using the default ref 'HEAD'" | Write-Verbose
'HEAD'
}
Variant = if ($env:RELEASE_NOTES_VARIANT) { $env:RELEASE_NOTES_VARIANT } else { 'VersionDate-HashSubject-NoMerges' }
ReleaseNotesPath = if ($env:RELEASE_NOTES_PATH) {
"Using specified release notes path '$env:RELEASE_NOTES_PATH'" | Write-Verbose
Expand Down
1 change: 0 additions & 1 deletion templates/azure-pipelines/entrypoint/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ steps:
$VerbosePreference = 'Continue'
.\build\PSRepositoryReleaseManager\src\scripts\ci\Invoke-Generate.ps1
displayName: Generate release notes
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
env:
RELEASE_NOTES_VARIANT: ${{ parameters['VARIANT'] }}
RELEASE_NOTES_PATH: ${{ parameters['NOTES_PATH'] }}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ steps:
$VerbosePreference = 'Continue'
.\build\PSRepositoryReleaseManager\src\scripts\ci\Invoke-Generate.ps1
displayName: Generate release notes
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
env:
RELEASE_NOTES_VARIANT: ${{ parameters['VARIANT'] }}
RELEASE_NOTES_PATH: ${{ parameters['NOTES_PATH'] }}
1 change: 0 additions & 1 deletion templates/azure-pipelines/entrypoint/pwsh/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ steps:
$VerbosePreference = 'Continue'
.\build\PSRepositoryReleaseManager\src\scripts\ci\Invoke-Generate.ps1
displayName: Generate release notes
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
env:
RELEASE_NOTES_VARIANT: ${{ parameters['VARIANT'] }}
RELEASE_NOTES_PATH: ${{ parameters['NOTES_PATH'] }}

0 comments on commit c488059

Please sign in to comment.