Skip to content

Commit

Permalink
chore: reorder changelog sections during release (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwwoda authored Feb 24, 2022
1 parent a9cbede commit 8021b8e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 7 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ on:
push:
branches:
- main
pull_request_target:
pull_request:
types: [opened, synchronize]
branches:
- main

jobs:
framework:
name: Build and Test - Framework
runs-on: windows-latest
runs-on: windows-2019

steps:
- name: Checkout
Expand All @@ -35,6 +35,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.0.0'
- name: Build
run: dotnet build .\Box.V2.Core
- name: Test
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Lint Code Base

on:
push:
branches:
- main
pull_request_target:
types: [opened, synchronize]
branches:
Expand All @@ -25,5 +22,6 @@ jobs:
VALIDATE_ALL_CODEBASE: false
VALIDATE_YAML: false
VALIDATE_JSCPD: false
VALIDATE_POWERSHELL: false
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion Box.V2.Test/Box.V2.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
<PackageReference Include="coverlet.collector" Version="1.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

Expand Down
54 changes: 54 additions & 0 deletions build/bump_version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,60 @@ $NEXT_VERSION_TAG = "v" + "$NEXT_VERSION"
$RELEASE_DATE = (Select-String -Pattern "\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])" -Path $CHANGELOG_PATH | Select-Object -First 1).Matches.Value
$RELEASE_NOTE_LINK = $NEXT_VERSION.Replace(".", "") + "-" + "$RELEASE_DATE"

###########################################################################
# Reorder changelog sections
###########################################################################

$sections = @()
$sections += ('### ⚠ BREAKING CHANGES')
foreach($line in Get-Content $VERSIONRC_PATH) {
$found = $line -match '(?<=section": ").*(?=",)'
if ($found) {
$sections += $matches[0]
}
}

$orderedSections = new-object string[] $sections.Length
$currentSection = $null
$previousSectionIndex = 0

foreach($line in Get-Content $CHANGELOG_PATH) {
if($line -match "#{2,3} [[0-9]+\.[0-9]+\.[0-9]+]"){
if($VersionFound){
if(![string]::IsNullOrWhiteSpace($currentSection)){
$orderedSections[$previousSectionIndex] = $currentSection
}
break
}
$VersionFound = $true
continue
}
if($VersionFound){
for ($i=0; $i -lt $sections.Length; $i++)
{
if($line -match [Regex]::Escape($sections[$i])){
if(![string]::IsNullOrWhiteSpace($currentSection)){
$orderedSections[$previousSectionIndex] = $currentSection
}
$previousSectionIndex = $i
$currentSection = $null
continue
}
}
$currentSection += "$line`n"
}
}

$orderedSectionsAsString

foreach($orderedSection in $orderedSections){
$orderedSectionsAsString += $orderedSection
}

$fileContent = Get-Content $CHANGELOG_PATH -Raw
$result = [regex]::match($fileContent, '(?s)(### [^\[].*?)#{2,3} [[0-9]+\.[0-9]+\.[0-9]+]').Groups[1].Value
$fileContent -replace [Regex]::Escape($result), $orderedSectionsAsString | Set-Content $CHANGELOG_PATH

###########################################################################
# Bump version files
###########################################################################
Expand Down
2 changes: 1 addition & 1 deletion build/draft_release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ if ($InstallDependencies){

$VersionFound = $false
foreach($line in Get-Content $CHANGELOG_PATH) {
if($line -match "## [[0-9]+\.[0-9]+\.[0-9]+]"){
if($line -match "#{2,3} [[0-9]+\.[0-9]+\.[0-9]+]"){
if($VersionFound){
break
}
Expand Down
1 change: 1 addition & 0 deletions build/variables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ $FRAMEWORK_PDB_PATH=$FRAMEWORK_PROJ_DIR + "\bin\Release\Box.V2.pdb"
$CORE_PDB_PATH=$CORE_PROJ_DIR + "\bin\Release\netstandard2.0\Box.V2.Core.pdb"
$PFX_PATH="$FRAMEWORK_PROJ_DIR" + "\BoxSDKKey.pfx"
$TEST_PATH="$ROOT_DIR" + "\Box.V2.Test"
$VERSIONRC_PATH="$ROOT_DIR" + "\.versionrc"

0 comments on commit 8021b8e

Please sign in to comment.