Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
text eol=lf
19 changes: 18 additions & 1 deletion .github/workflows/updater-scripts-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,25 @@ on:

jobs:
test:
runs-on: ubuntu-latest
name: ${{ matrix.host }}
runs-on: ${{ matrix.host }}-latest
strategy:
fail-fast: false
matrix:
host:
- ubuntu
- macos
- windows
steps:
- run: git config --global core.autocrlf false

- uses: actions/checkout@v3

- name: Install make
if: ${{ matrix.host == 'macos' }}
run: |
brew install make
echo "$(brew --prefix)/opt/make/libexec/gnubin" >> $GITHUB_PATH

- run: make test
working-directory: updater
2 changes: 1 addition & 1 deletion .github/workflows/versioning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
steps:
- uses: Actions-R-Us/actions-tagger@f411bd910a5ad370d4511517e3eac7ff887c90ea # v2.0.2
with:
publish_latest_tag: true
publish_latest_tag: true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

- Updater - update deprecated actions ([#48](https://github.com/getsentry/github-workflows/pull/48))

### Features

- Danger - ignore "deps" and "test" PR flavors in changelog checks ([#49](https://github.com/getsentry/github-workflows/pull/49))

## 2.4.0

### Features
Expand Down
2 changes: 1 addition & 1 deletion danger/dangerfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function checkChangelog() {

// Check if skipped
if (
["ci", "chore(deps)", "build(deps)"].includes(prFlavor) ||
["ci", "test", "deps", "chore(deps)", "build(deps)"].includes(prFlavor) ||
(danger.github.pr.body + "").includes("#skip-changelog")
) {
return;
Expand Down
188 changes: 94 additions & 94 deletions updater/scripts/get-changelog.ps1
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
param(
[Parameter(Mandatory = $true)][string] $RepoUrl,
[Parameter(Mandatory = $true)][string] $OldTag,
[Parameter(Mandatory = $true)][string] $NewTag
)
Set-StrictMode -Version latest
$prefix = 'https?://(www\.)?github.com/'
if (-not ($RepoUrl -match "^$prefix"))
{
Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl"
return
}
$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())
try
{
git clone --depth 1 $RepoUrl $tmpDir
$file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } )
if ("$file" -eq "")
{
Write-Warning "Couldn't find a changelog"
return
}
elseif ($file -is [Array])
{
Write-Warning "Multiple changelogs found: $file"
return
}
Write-Host "Found changelog: $file"
[string[]]$lines = Get-Content $file
}
finally
{
Write-Host "Removing $tmpDir"
Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir
}
$foundFirst = $false
$changelog = ""
for ($i = 0; $i -lt $lines.Count; $i++)
{
$line = $lines[$i]
if (-not $foundFirst)
{
if ($line -match "^#+ +v?$NewTag\b")
{
$foundFirst = $true
}
else
{
continue
}
}
elseif ($line -match "^#+ +v?$OldTag\b")
{
break
}
$changelog += "$line`n"
}
$changelog = $changelog.Trim()
if ($changelog.Length -gt 1)
{
$changelog = "# Changelog`n$changelog"
# Increase header level by one.
$changelog = $changelog -replace "(#+) ", '$1# '
# Remove at-mentions.
$changelog = $changelog -replace '@', ''
# Make PR/issue references into links to the original repository (unless they already are links).
$changelog = $changelog -replace '(?<!\[)#([0-9]+)', ('[#$1](' + $RepoUrl + '/issues/$1)')
# Replace any links pointing to github.com so that the target PRs/Issues don't get na notification.
$changelog = $changelog -replace ('\(' + $prefix), '(https://github-redirect.dependabot.com/'
}
# Limit the changelog length to ~60k to allow for other text in the PR body (total PR limit is 65536 characters).
$limit = 60000
if ($changelog.Length -gt $limit)
{
$oldLength = $changelog.Length
Write-Warning "Truncating changelog because it's $($changelog.Length - $limit) characters longer than the limit $limit."
while ($changelog.Length -gt $limit)
{
$changelog = $changelog.Substring(0, $changelog.LastIndexOf("`n"))
}
$changelog += "`n`n> :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
}
$changelog
param(
[Parameter(Mandatory = $true)][string] $RepoUrl,
[Parameter(Mandatory = $true)][string] $OldTag,
[Parameter(Mandatory = $true)][string] $NewTag
)

Set-StrictMode -Version latest

$prefix = 'https?://(www\.)?github.com/'
if (-not ($RepoUrl -match "^$prefix"))
{
Write-Warning "Only github.com repositories are currently supported. Given RepoUrl doesn't look like one: $RepoUrl"
return
}

$tmpDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid())

try
{
git clone --depth 1 $RepoUrl $tmpDir

$file = $(Get-ChildItem -Path $tmpDir | Where-Object { $_.Name -match '^changelog(\.md|\.txt|)$' } )
if ("$file" -eq "")
{
Write-Warning "Couldn't find a changelog"
return
}
elseif ($file -is [Array])
{
Write-Warning "Multiple changelogs found: $file"
return
}
Write-Host "Found changelog: $file"
[string[]]$lines = Get-Content $file
}
finally
{
Write-Host "Removing $tmpDir"
Remove-Item -Recurse -Force -ErrorAction Continue -Path $tmpDir
}

$foundFirst = $false
$changelog = ""
for ($i = 0; $i -lt $lines.Count; $i++)
{
$line = $lines[$i]

if (-not $foundFirst)
{
if ($line -match "^#+ +v?$NewTag\b")
{
$foundFirst = $true
}
else
{
continue
}
}
elseif ($line -match "^#+ +v?$OldTag\b")
{
break
}

$changelog += "$line`n"
}

$changelog = $changelog.Trim()
if ($changelog.Length -gt 1)
{
$changelog = "# Changelog`n$changelog"
# Increase header level by one.
$changelog = $changelog -replace "(#+) ", '$1# '
# Remove at-mentions.
$changelog = $changelog -replace '@', ''
# Make PR/issue references into links to the original repository (unless they already are links).
$changelog = $changelog -replace '(?<!\[)#([0-9]+)', ('[#$1](' + $RepoUrl + '/issues/$1)')
# Replace any links pointing to github.com so that the target PRs/Issues don't get na notification.
$changelog = $changelog -replace ('\(' + $prefix), '(https://github-redirect.dependabot.com/'
}

# Limit the changelog length to ~60k to allow for other text in the PR body (total PR limit is 65536 characters).
$limit = 60000
if ($changelog.Length -gt $limit)
{
$oldLength = $changelog.Length
Write-Warning "Truncating changelog because it's $($changelog.Length - $limit) characters longer than the limit $limit."
while ($changelog.Length -gt $limit)
{
$changelog = $changelog.Substring(0, $changelog.LastIndexOf("`n"))
}
$changelog += "`n`n> :warning: **Changelog content truncated by $($oldLength - $changelog.Length) characters because it was over the limit ($limit) and wouldn't fit into PR description.**"
}

$changelog
24 changes: 12 additions & 12 deletions updater/scripts/set-github-env.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
param(
[Parameter(Mandatory = $true)][string] $Name,
[string] $Data = ''
)
Set-StrictMode -Version latest
if ($null -eq $env:GITHUB_ENV) {
throw "GITHUB_ENV environment variable is missing - this script is supposed to be run in GitHub-Actions."
}
Write-Output "$Name<<EOF`n$Data`nEOF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
param(
[Parameter(Mandatory = $true)][string] $Name,
[string] $Data = ''
)

Set-StrictMode -Version latest

if ($null -eq $env:GITHUB_ENV) {
throw "GITHUB_ENV environment variable is missing - this script is supposed to be run in GitHub-Actions."
}

Write-Output "$Name<<EOF`n$Data`nEOF" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
1 change: 0 additions & 1 deletion updater/scripts/sort-versions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ function GetComparableVersion([Parameter(Mandatory = $true)][string] $value)
}

$List | Sort-Object -Property @{Expression = { GetComparableVersion $_ } }

Loading