Skip to content

Commit

Permalink
fix: whatif prevents write-output (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArwynFr committed Apr 17, 2023
1 parent a4d371b commit 37ab0ca
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
File renamed without changes.
20 changes: 20 additions & 0 deletions functions/Get-NewVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[CmdletBinding(SupportsShouldProcess)]
param (
[Parameter(Mandatory)]
[string]
$RepositoryName,

[Parameter()]
[string]
$CommitMessage
)

$Private:currentVersion = & $PSScriptRoot/Get-CurrentVersion.ps1 -RepositoryName "$RepositoryName"
$Private:bumpType = & $PSScriptRoot/Get-VersionBumpType.ps1 -CommitMessage "$CommitMessage"
$Private:nextVersion = & $PSScriptRoot/New-SemVer.ps1 -Version $Private:currentVersion -BumpType $Private:bumpType

"current-version=$Private:currentVersion" >> $env:GITHUB_OUTPUT
"bump-type=$Private:bumpType" >> $env:GITHUB_OUTPUT
"next-version=$Private:nextVersion" >> $env:GITHUB_OUTPUT

return $Private:nextVersion #| Out-Null
11 changes: 2 additions & 9 deletions functions/New-GithubRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,12 @@ param (
$Pattern
)

$Private:currentVersion = & $PSScriptRoot/Get-SemVer.ps1 -RepositoryName "$RepositoryName"
$Private:bumpType = & $PSScriptRoot/Get-VersionBumpType.ps1 -CommitMessage "$CommitMessage"
$Private:nextVersion = & $PSScriptRoot/New-SemVer.ps1 -Version $Private:currentVersion -BumpType $Private:bumpType

Write-Host "current-version=$Private:currentVersion" >> $env:GITHUB_OUTPUT
Write-Host "bump-type=$Private:bumpType" >> $env:GITHUB_OUTPUT
Write-Host "next-version=$Private:nextVersion" >> $env:GITHUB_OUTPUT
$private:nextVersion = & $PSScriptRoot/Get-NewVersion.ps1 -RepositoryName $RepositoryName -CommitMessage $CommitMessage

if ($PSCmdlet.ShouldProcess($private:nextVersion, 'gh release create')) {
if (($null -eq $Pattern) -or ('' -eq $Pattern)) {
gh release create "$private:nextVersion" --generate-notes --repo "$RepositoryName"
}
else {
} else {
gh release create "$private:nextVersion" --generate-notes --repo "$RepositoryName" (Get-Item "$Pattern")
}
}
5 changes: 2 additions & 3 deletions get-newVersion/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ runs:
id: new-github-release
run: |
"${{ github.token }}" | gh auth login --with-token
& "${env:GITHUB_ACTION_PATH}/../functions/New-GithubRelease.ps1" `
& "${env:GITHUB_ACTION_PATH}/../functions/Get-NewVersion.ps1" `
-RepositoryName "${{ github.repository }}" `
-CommitMessage "${{ github.event.head_commit.message }}" `
-Whatif
-CommitMessage "${{ github.event.head_commit.message }}"

0 comments on commit 37ab0ca

Please sign in to comment.