From 03ce1c21b55fd527abd4efc2274bf62af94eef25 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 5 Nov 2026 18:05:47 +0200 Subject: [PATCH 1/7] Support prefixed release tags in updater --- CHANGELOG.md | 1 + updater/README.md | 1 + updater/scripts/common.ps1 | 2 +- updater/scripts/update-changelog.ps1 | 8 +++++--- updater/scripts/update-dependency.ps1 | 3 ++- updater/tests/sort-versions.Tests.ps1 | 5 +++++ updater/tests/update-changelog.Tests.ps1 | 20 ++++++++++++++++++++ updater/tests/update-dependency.Tests.ps1 | 10 ++++++++++ 8 files changed, 45 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index daa5eaeb..7dbef4fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixes - Validate PR - Skip PRs opened by bots of GitHub Apps owned by Sentry (the `getsentry` organization or the `sentry` enterprise), such as `sentry-junior[bot]`. App bot users are never repo collaborators, so the write-access check couldn't recognize them. ([#179](https://github.com/getsentry/github-workflows/pull/179)) +- Updater - Support release tags with a product prefix, such as `cli@0.47.0` from Craft workspaces. Select the product with `pattern`; displayed versions omit the prefix. ([#TBD](https://github.com/getsentry/github-workflows/pull/TBD)) ## 3.4.1 diff --git a/updater/README.md b/updater/README.md index 7929dfb4..040c2650 100644 --- a/updater/README.md +++ b/updater/README.md @@ -153,6 +153,7 @@ Git lookup or fetch failures are also reported as errors. Annotated release tags * type: string * required: true * `pattern`: RegEx pattern that will be matched against available versions when picking the latest one. + For monorepos that tag releases with a product prefix (e.g. `cli@1.2.3`), select the product with a pattern like `'^cli@[0-9.]+$'`. The prefix is ignored when comparing versions and omitted from displayed versions. * type: string * required: false * default: '' diff --git a/updater/scripts/common.ps1 b/updater/scripts/common.ps1 index d248721a..c2d909a5 100644 --- a/updater/scripts/common.ps1 +++ b/updater/scripts/common.ps1 @@ -1,7 +1,7 @@ function GetComparableVersion([string] $value) { - $value = $value -replace '^v', '' + $value = $value -replace '^(.*@)?v?', '' try { [System.Management.Automation.SemanticVersion]::Parse($value) } catch { diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index 1ab2ec59..65de2f20 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -143,9 +143,11 @@ for ($i = 0; $i -lt $lines.Count; $i++) # What line we want to insert at - the empty line at the end of the currently unreleased section. $sectionEnd = $i -$tagAnchor = $NewTag.Replace('.', '') -$oldTagNice = ($OldTag -match "^[0-9]") ? "v$OldTag" : $OldTag -$newTagNice = ($NewTag -match "^[0-9]") ? "v$NewTag" : $NewTag +$oldVersion = $OldTag -replace '^.*@', '' +$newVersion = $NewTag -replace '^.*@', '' +$tagAnchor = $newVersion.Replace('.', '') +$oldTagNice = ($oldVersion -match "^[0-9]") ? "v$oldVersion" : $oldVersion +$newTagNice = ($newVersion -match "^[0-9]") ? "v$newVersion" : $newVersion $PullRequestMD = "[#$($PR | Split-Path -Leaf)]($PR)" diff --git a/updater/scripts/update-dependency.ps1 b/updater/scripts/update-dependency.ps1 index b0f84496..66cf7855 100644 --- a/updater/scripts/update-dependency.ps1 +++ b/updater/scripts/update-dependency.ps1 @@ -265,7 +265,8 @@ if ("$Tag" -eq '') { } while ($false) } - $latestTagNice = ($latestTag -match '^[0-9]') ? "v$latestTag" : $latestTag + $latestVersion = $latestTag -replace '^.*@', '' + $latestTagNice = ($latestVersion -match '^[0-9]') ? "v$latestVersion" : $latestVersion SetOutput 'originalTag' $originalTag SetOutput 'latestTag' $latestTag diff --git a/updater/tests/sort-versions.Tests.ps1 b/updater/tests/sort-versions.Tests.ps1 index aec246e8..4527f35d 100644 --- a/updater/tests/sort-versions.Tests.ps1 +++ b/updater/tests/sort-versions.Tests.ps1 @@ -27,4 +27,9 @@ Describe 'sort-versions' { $sorted = SortVersions @('1.0.0-rc.1', '1.0.0', '1.0.0-beta.11', '1.0.0-alpha.1', '1.0.0-beta', '1.0.0-alpha.beta', '1.0.0-alpha', '1.0.0-beta.2') $sorted | Should -Be @('1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-alpha.beta', '1.0.0-beta', '1.0.0-beta.2', '1.0.0-beta.11', '1.0.0-rc.1', '1.0.0') } + + It 'prefixed versions' { + $sorted = SortVersions @('cli@0.47.0', 'cli@0.9.0', 'cli@0.46.0', 'cli@0.47.0-beta.1') + $sorted | Should -Be @('cli@0.9.0', 'cli@0.46.0', 'cli@0.47.0-beta.1', 'cli@0.47.0') + } } diff --git a/updater/tests/update-changelog.Tests.ps1 b/updater/tests/update-changelog.Tests.ps1 index 2665c420..9d619523 100644 --- a/updater/tests/update-changelog.Tests.ps1 +++ b/updater/tests/update-changelog.Tests.ps1 @@ -48,4 +48,24 @@ Describe 'update-changelog' { Get-Content "$testCasePath/CHANGELOG.md" | Should -Be (Get-Content "$testCasePath/CHANGELOG.md.expected") } + + It 'should strip the tag prefix from displayed versions and the changelog anchor' { + $testCasePath = "$TestDrive/prefixed-tags" + New-Item $testCasePath -ItemType Directory | Out-Null + @('# Changelog', '', '## Unreleased', '', '### Dependencies', '', '- Existing entry', '') | Out-File "$testCasePath/CHANGELOG.md" + + pwsh -WorkingDirectory $testCasePath -File "$PSScriptRoot/../scripts/update-changelog.ps1" ` + -Name 'Dependency' ` + -PR 'https://github.com/getsentry/dependant/pulls/123' ` + -RepoUrl 'https://github.com/getsentry/dependency' ` + -MainBranch 'main' ` + -OldTag 'cli@0.46.0' ` + -NewTag 'cli@0.47.0' ` + -Section 'Dependencies' + + $content = Get-Content "$testCasePath/CHANGELOG.md" + $content | Should -Contain '- Bump Dependency from v0.46.0 to v0.47.0 ([#123](https://github.com/getsentry/dependant/pulls/123))' + $content | Should -Contain ' - [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#0470)' + $content | Should -Contain ' - [diff](https://github.com/getsentry/dependency/compare/cli@0.46.0...cli@0.47.0)' + } } diff --git a/updater/tests/update-dependency.Tests.ps1 b/updater/tests/update-dependency.Tests.ps1 index 46908049..1779a80d 100644 --- a/updater/tests/update-dependency.Tests.ps1 +++ b/updater/tests/update-dependency.Tests.ps1 @@ -56,6 +56,16 @@ Describe ('update-dependency') { Get-Content $testFile | Should -Be @("repo=$repo", 'version=3.2.1') } + It 'version pattern match with prefixed tags' { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/toolkit' + @("repo=$repo", 'version=0') | Out-File $testFile + $stdout = UpdateDependency $testFile '^cli@0\.46\.' + Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@0.46.0') + $stdout | Should -Contain 'latestTag=cli@0.46.0' + $stdout | Should -Contain 'latestTagNice=v0.46.0' + } + It 'will not update from a later release to an earlier release' { $testFile = "$testDir/test.properties" $repo = 'https://github.com/getsentry/sentry-java' From 1f467327446af7b97971f47f9943ab22d33c40e7 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 5 Nov 2026 18:15:48 +0200 Subject: [PATCH 2/7] Add PR number to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dbef4fc..30a12861 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Fixes - Validate PR - Skip PRs opened by bots of GitHub Apps owned by Sentry (the `getsentry` organization or the `sentry` enterprise), such as `sentry-junior[bot]`. App bot users are never repo collaborators, so the write-access check couldn't recognize them. ([#179](https://github.com/getsentry/github-workflows/pull/179)) -- Updater - Support release tags with a product prefix, such as `cli@0.47.0` from Craft workspaces. Select the product with `pattern`; displayed versions omit the prefix. ([#TBD](https://github.com/getsentry/github-workflows/pull/TBD)) +- Updater - Support release tags with a product prefix, such as `cli@0.47.0` from Craft workspaces. Select the product with `pattern`; displayed versions omit the prefix. ([#184](https://github.com/getsentry/github-workflows/pull/184)) ## 3.4.1 From ecd3115d36f4d1ed3405d5719ca5b2f86365806b Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 9 Nov 2026 10:57:20 +0200 Subject: [PATCH 3/7] Read the version from a named group in the tag pattern --- CHANGELOG.md | 2 +- updater/README.md | 4 +- updater/action.yml | 6 +- updater/scripts/common.ps1 | 37 ++++++++++- updater/scripts/sort-versions.ps1 | 7 +- updater/scripts/update-changelog.ps1 | 15 +++-- updater/scripts/update-dependency.ps1 | 19 ++++-- updater/tests/sort-versions.Tests.ps1 | 18 ++++-- updater/tests/update-changelog.Tests.ps1 | 78 ++++++++++++++++++----- updater/tests/update-dependency.Tests.ps1 | 23 ++++++- 10 files changed, 169 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30a12861..5454ff0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Fixes - Validate PR - Skip PRs opened by bots of GitHub Apps owned by Sentry (the `getsentry` organization or the `sentry` enterprise), such as `sentry-junior[bot]`. App bot users are never repo collaborators, so the write-access check couldn't recognize them. ([#179](https://github.com/getsentry/github-workflows/pull/179)) -- Updater - Support release tags with a product prefix, such as `cli@0.47.0` from Craft workspaces. Select the product with `pattern`; displayed versions omit the prefix. ([#184](https://github.com/getsentry/github-workflows/pull/184)) +- Updater - Support release tags with a product prefix, such as `cli@0.47.0` from Craft workspaces. Mark the version part of the tag with a `version` named group in `pattern`, such as `'^cli@(?[0-9.]+)$'`. ([#184](https://github.com/getsentry/github-workflows/pull/184)) ## 3.4.1 diff --git a/updater/README.md b/updater/README.md index 040c2650..3d09e18a 100644 --- a/updater/README.md +++ b/updater/README.md @@ -153,7 +153,9 @@ Git lookup or fetch failures are also reported as errors. Annotated release tags * type: string * required: true * `pattern`: RegEx pattern that will be matched against available versions when picking the latest one. - For monorepos that tag releases with a product prefix (e.g. `cli@1.2.3`), select the product with a pattern like `'^cli@[0-9.]+$'`. The prefix is ignored when comparing versions and omitted from displayed versions. + An optional `version` named group marks the version part of the tag, which is used to compare versions and in the PR title and changelog entry. + For monorepos that tag releases with a product prefix (e.g. `cli@1.2.3`), use a pattern like `'^cli@(?[0-9.]+)$'`. + Without the group, only a leading `v` is removed from the tag. * type: string * required: false * default: '' diff --git a/updater/action.yml b/updater/action.yml index ead6fa15..5a534867 100644 --- a/updater/action.yml +++ b/updater/action.yml @@ -10,7 +10,7 @@ inputs: description: 'Name used in the PR title and the changelog entry.' required: true pattern: - description: 'RegEx pattern that will be matched against available versions when picking the latest one.' + description: 'RegEx pattern that will be matched against available versions when picking the latest one. An optional `version` named group marks the version part of the tag, e.g. `^cli@(?[0-9.]+)$`.' required: false default: '' gh-title-pattern: @@ -448,6 +448,8 @@ runs: TARGET_MAIN_BRANCH: ${{ steps.target.outputs.mainBranch }} ORIGINAL_TAG: ${{ steps.target.outputs.originalTag }} LATEST_TAG: ${{ steps.target.outputs.latestTag }} + ORIGINAL_VERSION: ${{ steps.target.outputs.originalVersion }} + LATEST_VERSION: ${{ steps.target.outputs.latestVersion }} run: | ${{ github.action_path }}/scripts/update-changelog.ps1 ` -Name $env:DEPENDENCY_NAME ` @@ -456,6 +458,8 @@ runs: -MainBranch $env:TARGET_MAIN_BRANCH ` -OldTag $env:ORIGINAL_TAG ` -NewTag $env:LATEST_TAG ` + -OldVersion $env:ORIGINAL_VERSION ` + -NewVersion $env:LATEST_VERSION ` -Section $env:CHANGELOG_SECTION - name: Show final git diff diff --git a/updater/scripts/common.ps1 b/updater/scripts/common.ps1 index c2d909a5..229d7257 100644 --- a/updater/scripts/common.ps1 +++ b/updater/scripts/common.ps1 @@ -1,7 +1,42 @@ +$FallbackVersionPattern = '^v?(?.+)$' + +function GetVersionFromTag([string] $tag, [string] $pattern = '') +{ + if ($pattern -ne '' -and $tag -match $pattern -and $Matches.ContainsKey('version')) + { + return $Matches['version'] + } + if ($tag -match $FallbackVersionPattern) + { + return $Matches['version'] + } + return $tag +} + +# E.g. `cli@` for both `cli@1.2.3` and `cli@v1.2.3` +function GetTagPrefix([string] $tag, [string] $pattern) +{ + $match = [regex]::Match($tag, $pattern) + if (-not $match.Success -or -not $match.Groups['version'].Success) + { + return '' + } + return $tag.Substring(0, $match.Groups['version'].Index) -replace 'v$', '' +} + +function GetVersionAfterPrefix([string] $tag, [string] $prefix) +{ + if ($tag -match ('^' + [regex]::Escape($prefix) + 'v?(?.+)$')) + { + return $Matches['version'] + } + return $null +} + function GetComparableVersion([string] $value) { - $value = $value -replace '^(.*@)?v?', '' + $value = $value -replace '^v', '' try { [System.Management.Automation.SemanticVersion]::Parse($value) } catch { diff --git a/updater/scripts/sort-versions.ps1 b/updater/scripts/sort-versions.ps1 index 0c23c000..21bbf223 100644 --- a/updater/scripts/sort-versions.ps1 +++ b/updater/scripts/sort-versions.ps1 @@ -1,10 +1,11 @@ param( - [Parameter(Mandatory = $true)][string[]] $List + [Parameter(Mandatory = $true)][string[]] $List, + [string] $Pattern = '' ) Set-StrictMode -Version latest . "$PSScriptRoot/common.ps1" $List ` - | Where-Object { $null -ne (GetComparableVersion $_) } ` - | Sort-Object -Property @{Expression = { GetComparableVersion $_ } } + | Where-Object { $null -ne (GetComparableVersion (GetVersionFromTag $_ $Pattern)) } ` + | Sort-Object -Property @{Expression = { GetComparableVersion (GetVersionFromTag $_ $Pattern) } } diff --git a/updater/scripts/update-changelog.ps1 b/updater/scripts/update-changelog.ps1 index 65de2f20..a9864a1e 100644 --- a/updater/scripts/update-changelog.ps1 +++ b/updater/scripts/update-changelog.ps1 @@ -5,10 +5,13 @@ param( [Parameter(Mandatory = $true)][string] $MainBranch, [Parameter(Mandatory = $true)][string] $OldTag, [Parameter(Mandatory = $true)][string] $NewTag, - [Parameter(Mandatory = $true)][string] $Section + [Parameter(Mandatory = $true)][string] $Section, + [string] $OldVersion = '', + [string] $NewVersion = '' ) Set-StrictMode -Version latest +. "$PSScriptRoot/common.ps1" $file = $(Get-ChildItem | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } ) if ("$file" -eq "") @@ -143,11 +146,11 @@ for ($i = 0; $i -lt $lines.Count; $i++) # What line we want to insert at - the empty line at the end of the currently unreleased section. $sectionEnd = $i -$oldVersion = $OldTag -replace '^.*@', '' -$newVersion = $NewTag -replace '^.*@', '' -$tagAnchor = $newVersion.Replace('.', '') -$oldTagNice = ($oldVersion -match "^[0-9]") ? "v$oldVersion" : $oldVersion -$newTagNice = ($newVersion -match "^[0-9]") ? "v$newVersion" : $newVersion +if ("$OldVersion" -eq '') { $OldVersion = GetVersionFromTag $OldTag } +if ("$NewVersion" -eq '') { $NewVersion = GetVersionFromTag $NewTag } +$tagAnchor = ($NewTag.EndsWith("v$NewVersion") ? "v$NewVersion" : $NewVersion).Replace('.', '') +$oldTagNice = ($OldVersion -match "^[0-9]") ? "v$OldVersion" : $OldTag +$newTagNice = ($NewVersion -match "^[0-9]") ? "v$NewVersion" : $NewTag $PullRequestMD = "[#$($PR | Split-Path -Leaf)]($PR)" diff --git a/updater/scripts/update-dependency.ps1 b/updater/scripts/update-dependency.ps1 index 66cf7855..71c2efae 100644 --- a/updater/scripts/update-dependency.ps1 +++ b/updater/scripts/update-dependency.ps1 @@ -205,7 +205,7 @@ if ("$Tag" -eq '') { if ("$Pattern" -eq '') { # Use a default pattern that excludes pre-releases - $Pattern = '^v?([0-9.]+)$' + $Pattern = '^v?(?[0-9.]+)$' } Write-Host "Filtering tags with pattern '$Pattern'" @@ -215,10 +215,15 @@ if ("$Tag" -eq '') { throw "Found no tags matching pattern '$Pattern'" } - $tags = & "$PSScriptRoot/sort-versions.ps1" $tags + $tags = & "$PSScriptRoot/sort-versions.ps1" $tags -Pattern $Pattern Write-Host "Sorted tags: $tags" $latestTag = $tags[-1] + $latestVersion = GetVersionFromTag $latestTag $Pattern + + # Read the original tag with the latest tag's prefix, so that a tag of another product is never read as a version + $tagPrefix = GetTagPrefix $latestTag $Pattern + $originalVersion = GetVersionAfterPrefix $originalTag $tagPrefix if (("$originalTag" -ne '') -and ("$latestTag" -ne '') -and ("$latestTag" -ne "$originalTag")) { do { @@ -245,7 +250,7 @@ if ("$Tag" -eq '') { # It's possible that the dependency was updated to a pre-release version manually in which case we don't want to # roll back, even though it's not the latest version matching the configured pattern. - if (-not $isUnreleasedPin -and (GetComparableVersion $originalTag) -ge (GetComparableVersion $latestTag)) { + if (-not $isUnreleasedPin -and $null -ne $originalVersion -and (GetComparableVersion $originalVersion) -ge (GetComparableVersion $latestVersion)) { Write-Host "SemVer represented by the original tag '$originalTag' is newer than the latest tag '$latestTag'. Skipping update." $latestTag = $originalTag break @@ -265,11 +270,15 @@ if ("$Tag" -eq '') { } while ($false) } - $latestVersion = $latestTag -replace '^.*@', '' - $latestTagNice = ($latestVersion -match '^[0-9]') ? "v$latestVersion" : $latestVersion + if ("$originalTag" -eq "$latestTag") { + $latestVersion = $originalVersion + } + $latestTagNice = ($latestVersion -match '^[0-9]') ? "v$latestVersion" : $latestTag SetOutput 'originalTag' $originalTag + SetOutput 'originalVersion' $originalVersion SetOutput 'latestTag' $latestTag + SetOutput 'latestVersion' $latestVersion SetOutput 'latestTagNice' $latestTagNice SetOutput 'url' $url SetOutput 'mainBranch' $mainBranch diff --git a/updater/tests/sort-versions.Tests.ps1 b/updater/tests/sort-versions.Tests.ps1 index 4527f35d..1cde4bdb 100644 --- a/updater/tests/sort-versions.Tests.ps1 +++ b/updater/tests/sort-versions.Tests.ps1 @@ -1,8 +1,8 @@ BeforeAll { - function SortVersions([Parameter(Mandatory = $true)][string[]] $List) + function SortVersions([Parameter(Mandatory = $true)][string[]] $List, [string] $Pattern = '') { - $result = & "$PSScriptRoot/../scripts/sort-versions.ps1" $List + $result = & "$PSScriptRoot/../scripts/sort-versions.ps1" $List -Pattern $Pattern if (-not $?) { throw $result @@ -28,8 +28,18 @@ Describe 'sort-versions' { $sorted | Should -Be @('1.0.0-alpha', '1.0.0-alpha.1', '1.0.0-alpha.beta', '1.0.0-beta', '1.0.0-beta.2', '1.0.0-beta.11', '1.0.0-rc.1', '1.0.0') } - It 'prefixed versions' { - $sorted = SortVersions @('cli@0.47.0', 'cli@0.9.0', 'cli@0.46.0', 'cli@0.47.0-beta.1') + It 'prefixed versions with a version group' { + $sorted = SortVersions @('cli@0.47.0', 'cli@0.9.0', 'cli@0.46.0', 'cli@0.47.0-beta.1') '^cli@(?.+)$' $sorted | Should -Be @('cli@0.9.0', 'cli@0.46.0', 'cli@0.47.0-beta.1', 'cli@0.47.0') } + + It 'skips prefixed versions without a version group' { + $sorted = SortVersions @('cli@0.47.0', '0.42.0') '^(cli@)?[0-9.]+$' 3>$null + $sorted | Should -Be @('0.42.0') + } + + It 'skips tags of another product' { + $sorted = SortVersions @('cli@0.47.0', 'logger@9.0.0') '^cli@(?.+)$' 3>$null + $sorted | Should -Be @('cli@0.47.0') + } } diff --git a/updater/tests/update-changelog.Tests.ps1 b/updater/tests/update-changelog.Tests.ps1 index 9d619523..214220c4 100644 --- a/updater/tests/update-changelog.Tests.ps1 +++ b/updater/tests/update-changelog.Tests.ps1 @@ -49,23 +49,69 @@ Describe 'update-changelog' { Get-Content "$testCasePath/CHANGELOG.md" | Should -Be (Get-Content "$testCasePath/CHANGELOG.md.expected") } - It 'should strip the tag prefix from displayed versions and the changelog anchor' { - $testCasePath = "$TestDrive/prefixed-tags" - New-Item $testCasePath -ItemType Directory | Out-Null - @('# Changelog', '', '## Unreleased', '', '### Dependencies', '', '- Existing entry', '') | Out-File "$testCasePath/CHANGELOG.md" + Context 'prefixed tags' { + BeforeEach { + $testCasePath = "$TestDrive/prefixed-tags" + New-Item $testCasePath -ItemType Directory -Force | Out-Null + } - pwsh -WorkingDirectory $testCasePath -File "$PSScriptRoot/../scripts/update-changelog.ps1" ` - -Name 'Dependency' ` - -PR 'https://github.com/getsentry/dependant/pulls/123' ` - -RepoUrl 'https://github.com/getsentry/dependency' ` - -MainBranch 'main' ` - -OldTag 'cli@0.46.0' ` - -NewTag 'cli@0.47.0' ` - -Section 'Dependencies' + It 'should use the versions in displayed versions and the changelog anchor' { + @('# Changelog', '', '## Unreleased', '', '### Dependencies', '', '- Existing entry', '') | Out-File "$testCasePath/CHANGELOG.md" + + pwsh -WorkingDirectory $testCasePath -File "$PSScriptRoot/../scripts/update-changelog.ps1" ` + -Name 'Dependency' ` + -PR 'https://github.com/getsentry/dependant/pulls/123' ` + -RepoUrl 'https://github.com/getsentry/dependency' ` + -MainBranch 'main' ` + -OldTag 'cli@0.46.0' ` + -NewTag 'cli@0.47.0' ` + -OldVersion '0.46.0' ` + -NewVersion '0.47.0' ` + -Section 'Dependencies' + + $content = Get-Content "$testCasePath/CHANGELOG.md" + $content | Should -Contain '- Bump Dependency from v0.46.0 to v0.47.0 ([#123](https://github.com/getsentry/dependant/pulls/123))' + $content | Should -Contain ' - [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#0470)' + $content | Should -Contain ' - [diff](https://github.com/getsentry/dependency/compare/cli@0.46.0...cli@0.47.0)' + } + + It 'should update an existing entry' { + @('# Changelog', '', '## Unreleased', '', '### Dependencies', '', + '- Bump Dependency from v0.45.0 to v0.46.0 ([#100](https://github.com/getsentry/dependant/pulls/100))', + ' - [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#0460)', + ' - [diff](https://github.com/getsentry/dependency/compare/cli@0.45.0...cli@0.46.0)', '') | Out-File "$testCasePath/CHANGELOG.md" + + pwsh -WorkingDirectory $testCasePath -File "$PSScriptRoot/../scripts/update-changelog.ps1" ` + -Name 'Dependency' ` + -PR 'https://github.com/getsentry/dependant/pulls/123' ` + -RepoUrl 'https://github.com/getsentry/dependency' ` + -MainBranch 'main' ` + -OldTag 'cli@0.46.0' ` + -NewTag 'cli@0.47.0' ` + -OldVersion '0.46.0' ` + -NewVersion '0.47.0' ` + -Section 'Dependencies' + + $content = Get-Content "$testCasePath/CHANGELOG.md" + $content | Should -Contain '- Bump Dependency from v0.45.0 to v0.47.0 ([#100](https://github.com/getsentry/dependant/pulls/100), [#123](https://github.com/getsentry/dependant/pulls/123))' + $content | Should -Contain ' - [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#0470)' + $content | Should -Contain ' - [diff](https://github.com/getsentry/dependency/compare/cli@0.45.0...cli@0.47.0)' + } + + It 'should show the tag when the old version is unknown' { + @('# Changelog', '', '## Unreleased', '', '### Dependencies', '', '- Existing entry', '') | Out-File "$testCasePath/CHANGELOG.md" + + pwsh -WorkingDirectory $testCasePath -File "$PSScriptRoot/../scripts/update-changelog.ps1" ` + -Name 'Dependency' ` + -PR 'https://github.com/getsentry/dependant/pulls/123' ` + -RepoUrl 'https://github.com/getsentry/dependency' ` + -MainBranch 'main' ` + -OldTag 'logger@0.46.0' ` + -NewTag 'cli@0.47.0' ` + -NewVersion '0.47.0' ` + -Section 'Dependencies' - $content = Get-Content "$testCasePath/CHANGELOG.md" - $content | Should -Contain '- Bump Dependency from v0.46.0 to v0.47.0 ([#123](https://github.com/getsentry/dependant/pulls/123))' - $content | Should -Contain ' - [changelog](https://github.com/getsentry/dependency/blob/main/CHANGELOG.md#0470)' - $content | Should -Contain ' - [diff](https://github.com/getsentry/dependency/compare/cli@0.46.0...cli@0.47.0)' + Get-Content "$testCasePath/CHANGELOG.md" | Should -Contain '- Bump Dependency from logger@0.46.0 to v0.47.0 ([#123](https://github.com/getsentry/dependant/pulls/123))' + } } } diff --git a/updater/tests/update-dependency.Tests.ps1 b/updater/tests/update-dependency.Tests.ps1 index 1779a80d..813f2cca 100644 --- a/updater/tests/update-dependency.Tests.ps1 +++ b/updater/tests/update-dependency.Tests.ps1 @@ -59,13 +59,32 @@ Describe ('update-dependency') { It 'version pattern match with prefixed tags' { $testFile = "$testDir/test.properties" $repo = 'https://github.com/getsentry/toolkit' - @("repo=$repo", 'version=0') | Out-File $testFile - $stdout = UpdateDependency $testFile '^cli@0\.46\.' + @("repo=$repo", 'version=cli@0.45.0') | Out-File $testFile + $stdout = UpdateDependency $testFile '^cli@(?0\.46\.[0-9]+)$' Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@0.46.0') + $stdout | Should -Contain 'originalVersion=0.45.0' $stdout | Should -Contain 'latestTag=cli@0.46.0' + $stdout | Should -Contain 'latestVersion=0.46.0' $stdout | Should -Contain 'latestTagNice=v0.46.0' } + It 'will not update from a later prefixed release to an earlier release' { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/toolkit' + @("repo=$repo", 'version=cli@99.0.0') | Out-File $testFile + UpdateDependency $testFile '^cli@(?0\.46\.[0-9]+)$' + Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@99.0.0') + } + + It 'does not read a tag without the prefix as a version' { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/toolkit' + @("repo=$repo", 'version=99.0.0') | Out-File $testFile + $stdout = UpdateDependency $testFile '^cli@(?0\.46\.[0-9]+)$' + Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@0.46.0') + $stdout | Should -Contain 'originalVersion=' + } + It 'will not update from a later release to an earlier release' { $testFile = "$testDir/test.properties" $repo = 'https://github.com/getsentry/sentry-java' From 61a5bfaebf078323d475e1951dc773e62bb91858 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 9 Nov 2026 11:30:12 +0200 Subject: [PATCH 4/7] Keep prefixed tags when removing at-mentions from the changelog --- CHANGELOG.md | 2 +- updater/scripts/get-changelog.ps1 | 4 ++-- updater/tests/get-changelog.Tests.ps1 | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5454ff0e..b4c8dbe2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### Fixes - Validate PR - Skip PRs opened by bots of GitHub Apps owned by Sentry (the `getsentry` organization or the `sentry` enterprise), such as `sentry-junior[bot]`. App bot users are never repo collaborators, so the write-access check couldn't recognize them. ([#179](https://github.com/getsentry/github-workflows/pull/179)) -- Updater - Support release tags with a product prefix, such as `cli@0.47.0` from Craft workspaces. Mark the version part of the tag with a `version` named group in `pattern`, such as `'^cli@(?[0-9.]+)$'`. ([#184](https://github.com/getsentry/github-workflows/pull/184)) +- Updater - Support prefixed release tags, such as `cli@1.2.3`, via a `version` named group in `pattern`. ([#184](https://github.com/getsentry/github-workflows/pull/184)) ## 3.4.1 diff --git a/updater/scripts/get-changelog.ps1 b/updater/scripts/get-changelog.ps1 index c892160a..39ff8ce5 100644 --- a/updater/scripts/get-changelog.ps1 +++ b/updater/scripts/get-changelog.ps1 @@ -201,8 +201,8 @@ function Format-ChangelogContent { } # Apply standard formatting - # Remove at-mentions - $changelog = $changelog -replace '@', '' + # Remove at-mentions, but keep prefixed tags (`cli@1.2.3`) and email addresses + $changelog = $changelog -replace '(? Date: Mon, 9 Nov 2026 11:58:57 +0200 Subject: [PATCH 5/7] Fail with a clear error when no matching tag has a semantic version --- updater/scripts/update-dependency.ps1 | 6 +++++- updater/tests/update-dependency.Tests.ps1 | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/updater/scripts/update-dependency.ps1 b/updater/scripts/update-dependency.ps1 index 71c2efae..f2729d44 100644 --- a/updater/scripts/update-dependency.ps1 +++ b/updater/scripts/update-dependency.ps1 @@ -215,7 +215,11 @@ if ("$Tag" -eq '') { throw "Found no tags matching pattern '$Pattern'" } - $tags = & "$PSScriptRoot/sort-versions.ps1" $tags -Pattern $Pattern + $tags = @(& "$PSScriptRoot/sort-versions.ps1" $tags -Pattern $Pattern) + + if ($tags.Count -eq 0) { + throw "Found no tags with a semantic version matching pattern '$Pattern'" + } Write-Host "Sorted tags: $tags" $latestTag = $tags[-1] diff --git a/updater/tests/update-dependency.Tests.ps1 b/updater/tests/update-dependency.Tests.ps1 index 813f2cca..8fa7bd61 100644 --- a/updater/tests/update-dependency.Tests.ps1 +++ b/updater/tests/update-dependency.Tests.ps1 @@ -76,6 +76,13 @@ Describe ('update-dependency') { Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@99.0.0') } + It 'fails when no matching tag has a semantic version' { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/toolkit' + @("repo=$repo", 'version=cli@0.45.0') | Out-File $testFile + { UpdateDependency $testFile '^cli@0\.46\.[0-9]+$' 3>$null } | Should -Throw '*Found no tags with a semantic version*' + } + It 'does not read a tag without the prefix as a version' { $testFile = "$testDir/test.properties" $repo = 'https://github.com/getsentry/toolkit' From 4ac3d942ae070464d629b399f79908165e6bd01a Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 9 Nov 2026 20:00:12 +0200 Subject: [PATCH 6/7] Add a pattern hint to the error and match the tag prefix case-insensitively --- updater/scripts/common.ps1 | 2 +- updater/scripts/update-dependency.ps1 | 2 +- updater/tests/update-dependency.Tests.ps1 | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/updater/scripts/common.ps1 b/updater/scripts/common.ps1 index 229d7257..ea64d9d7 100644 --- a/updater/scripts/common.ps1 +++ b/updater/scripts/common.ps1 @@ -17,7 +17,7 @@ function GetVersionFromTag([string] $tag, [string] $pattern = '') # E.g. `cli@` for both `cli@1.2.3` and `cli@v1.2.3` function GetTagPrefix([string] $tag, [string] $pattern) { - $match = [regex]::Match($tag, $pattern) + $match = [regex]::Match($tag, $pattern, 'IgnoreCase') if (-not $match.Success -or -not $match.Groups['version'].Success) { return '' diff --git a/updater/scripts/update-dependency.ps1 b/updater/scripts/update-dependency.ps1 index f2729d44..1ffb9485 100644 --- a/updater/scripts/update-dependency.ps1 +++ b/updater/scripts/update-dependency.ps1 @@ -218,7 +218,7 @@ if ("$Tag" -eq '') { $tags = @(& "$PSScriptRoot/sort-versions.ps1" $tags -Pattern $Pattern) if ($tags.Count -eq 0) { - throw "Found no tags with a semantic version matching pattern '$Pattern'" + throw "Found no tags with a semantic version matching pattern '$Pattern'. If the tags have a prefix, mark the version with a ``version`` named group, e.g. '^cli@(?[0-9.]+)$'." } Write-Host "Sorted tags: $tags" diff --git a/updater/tests/update-dependency.Tests.ps1 b/updater/tests/update-dependency.Tests.ps1 index 8fa7bd61..d8b50f76 100644 --- a/updater/tests/update-dependency.Tests.ps1 +++ b/updater/tests/update-dependency.Tests.ps1 @@ -76,6 +76,14 @@ Describe ('update-dependency') { Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@99.0.0') } + It 'reads the prefix of the original tag regardless of case' { + $testFile = "$testDir/test.properties" + $repo = 'https://github.com/getsentry/toolkit' + @("repo=$repo", 'version=cli@99.0.0') | Out-File $testFile + UpdateDependency $testFile '^CLI@(?0\.46\.[0-9]+)$' + Get-Content $testFile | Should -Be @("repo=$repo", 'version=cli@99.0.0') + } + It 'fails when no matching tag has a semantic version' { $testFile = "$testDir/test.properties" $repo = 'https://github.com/getsentry/toolkit' From 221f08a301ece3906c42da1c24d7453cd9d1584a Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Mon, 9 Nov 2026 20:10:31 +0200 Subject: [PATCH 7/7] Use a smaller repository for the prefixed tags changelog test --- updater/tests/get-changelog.Tests.ps1 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/updater/tests/get-changelog.Tests.ps1 b/updater/tests/get-changelog.Tests.ps1 index 96574ab2..86b619ef 100644 --- a/updater/tests/get-changelog.Tests.ps1 +++ b/updater/tests/get-changelog.Tests.ps1 @@ -324,9 +324,22 @@ Features, fixes and improvements in this release have been contributed by: It 'git commit fallback keeps prefixed tags' { $actual = & "$PSScriptRoot/../scripts/get-changelog.ps1" ` - -RepoUrl 'https://github.com/getsentry/toolkit' -OldTag 'cli@0.46.0' -NewTag 'cli@0.47.0' + -RepoUrl 'https://github.com/getsentry/javascript-debug-ids' -OldTag '@debugids/browser@0.1.2' -NewTag '@debugids/browser@0.1.3' - $actual | Should -Match '### Commits between cli@0\.46\.0 and cli@0\.47\.0' + $expected = @' +## Changelog + +### Commits between debugids/browser@0.1.2 and debugids/browser@0.1.3 + +- meta(changelog): Update package versions ([#50](https://github-redirect.dependabot.com/getsentry/javascript-debug-ids/issues/50)) +- chore: Update dev deps to latest versions ([#49](https://github-redirect.dependabot.com/getsentry/javascript-debug-ids/issues/49)) +- chore: Add changeset for native vite support +- feat: Document native Vite support ([#48](https://github-redirect.dependabot.com/getsentry/javascript-debug-ids/issues/48)) +- feat: Update LICENSE date range for 2025 ([#47](https://github-redirect.dependabot.com/getsentry/javascript-debug-ids/issues/47)) +- chore: Format package.json +'@ + + $actual | Should -Be $expected } It 'git commit fallback returns empty when no commits found' {