Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
306 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ | |
[Dd]ebug/ | ||
[Rr]elease/ | ||
x64/ | ||
build/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"types": [ | ||
{"type": "feat", "section": "**New Features and Enhancements:**", "hidden": false}, | ||
{"type": "fix", "section": "**Bug Fixes:**", "hidden": false}, | ||
{"type": "chore", "hidden": true}, | ||
{"type": "docs", "hidden": true}, | ||
{"type": "style", "hidden": true}, | ||
{"type": "refactor", "hidden": true}, | ||
{"type": "test", "hidden": true}, | ||
{"type": "ci", "hidden":true} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
Param | ||
( | ||
[Alias('dr')] | ||
[bool]$DryRun = $true, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('gh')] | ||
[string]$GithubToken, | ||
|
||
[Alias('b')] | ||
[string]$Branch="main" | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$ROOT_DIR=$pwd | ||
$GIT_SCRIPT="$PSScriptRoot" + "\ensure_git_clean.ps1" | ||
$CHANGELOG_PATH="$ROOT_DIR" + "\CHANGELOG.md" | ||
$FRAMEWORK_PROJ_DIR="$ROOT_DIR" + "\Box.V2" | ||
$CORE_PROJ_DIR="$ROOT_DIR" + "\Box.V2.Core" | ||
$CORE_CSPROJ_PATH="$CORE_PROJ_DIR" + "\Box.V2.Core.csproj" | ||
$ASSEMBLYINFO_PATH="$FRAMEWORK_PROJ_DIR" + "\Utility\AssemblyInfo.cs" | ||
$FRAMEWORK_NUSPEC_PATH="$FRAMEWORK_PROJ_DIR" + "\Box.V2.nuspec" | ||
$REPO_OWNER="box" | ||
$REPO_NAME="box-windows-sdk-v2" | ||
|
||
########################################################################### | ||
# Install dependencies | ||
########################################################################### | ||
|
||
npm install -g standard-version | ||
Install-Module -Name PowerShellForGitHub | ||
|
||
########################################################################### | ||
# Ensure git tree is clean | ||
########################################################################### | ||
|
||
Invoke-Expression "& `"$GIT_SCRIPT`" -b $Branch" | ||
if ($LASTEXITCODE -ne 0) { | ||
exit 1 | ||
} | ||
|
||
########################################################################### | ||
# Update changelog | ||
########################################################################### | ||
|
||
standard-version release --skip.commit --skip.tag | ||
$NEXT_VERSION = (Select-String -Pattern [0-9]+\.[0-9]+\.[0-9]+ -Path $CHANGELOG_PATH | Select-Object -First 1).Matches.Value | ||
$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" | ||
|
||
########################################################################### | ||
# Bump version files | ||
########################################################################### | ||
|
||
(Get-Content $CORE_CSPROJ_PATH) -replace '(?<=<Version>).*(?=</Version>)', $NEXT_VERSION | Set-Content $CORE_CSPROJ_PATH | ||
(Get-Content $CORE_CSPROJ_PATH) -replace '(?<=CHANGELOG\.md#).*(?=</PackageReleaseNotes>)', $RELEASE_NOTE_LINK | Set-Content $CORE_CSPROJ_PATH | ||
(Get-Content $FRAMEWORK_NUSPEC_PATH) -replace '(?<=<version>).*(?=</version>)', $NEXT_VERSION | Set-Content $FRAMEWORK_NUSPEC_PATH | ||
(Get-Content $FRAMEWORK_NUSPEC_PATH) -replace '(?<=CHANGELOG\.md#).*(?=</releaseNotes>)', $RELEASE_NOTE_LINK | Set-Content $FRAMEWORK_NUSPEC_PATH | ||
(Get-Content $ASSEMBLYINFO_PATH) -replace '(?<=NuGetVersion = ").*(?=";)', $NEXT_VERSION | Set-Content $ASSEMBLYINFO_PATH | ||
|
||
########################################################################### | ||
# Create PR with version bump | ||
########################################################################### | ||
|
||
if($DryRun){ | ||
Write-Output "Dry run. PR with version bump will not be created." | ||
}else{ | ||
git branch -D $NEXT_VERSION_TAG | ||
git checkout -b $NEXT_VERSION_TAG | ||
git commit -am $NEXT_VERSION_TAG | ||
git push --set-upstream origin $NEXT_VERSION_TAG | ||
|
||
$password = ConvertTo-SecureString "$GithubToken" -AsPlainText -Force | ||
$Cred = New-Object System.Management.Automation.PSCredential ("Release_Bot", $password) | ||
Set-GitHubAuthentication -SessionOnly -Credential $Cred | ||
|
||
$prParams = @{ | ||
OwnerName = $REPO_OWNER | ||
RepositoryName = $REPO_NAME | ||
Title = "chore: " + $NEXT_VERSION_TAG | ||
Head = $NEXT_VERSION_TAG | ||
Base = 'main' | ||
Body = "Bumping version files for the next release! " + $NEXT_VERSION_TAG | ||
MaintainerCanModify = $true | ||
} | ||
New-GitHubPullRequest @prParams | ||
|
||
Clear-GitHubAuthentication | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Param | ||
( | ||
[Alias('b')] | ||
[string]$ReleaseBranch="main" | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
git remote update | ||
$currentBranch = '' | ||
git branch | ForEach-Object { | ||
if ($_ -match "^\* (.*)") { | ||
$currentBranch += $matches[1] | ||
} | ||
} | ||
if(!($currentBranch -eq $ReleaseBranch)){ | ||
Write-Output "Local branch is not the same as the release branch " + $ReleaseBranch + ". Aborting script" | ||
exit 1 | ||
} | ||
$NumberOfDifferentCommits = git rev-list HEAD...origin/main --count | ||
if(!($NumberOfDifferentCommits -eq "0")){ | ||
Write-Output "Different commits local and on remote. Aborting script" | ||
exit 1 | ||
} | ||
if (git status --porcelain) { | ||
Write-Output "There are local changes that are not present on the remote. Aborting script." | ||
exit 1 | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Param | ||
( | ||
[Alias('dr')] | ||
[bool]$DryRun = $true, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('ng')] | ||
[string]$NugetKey, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('nv')] | ||
[string]$NextVersion, | ||
|
||
[Alias('b')] | ||
[string]$Branch="main" | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$ROOT_DIR=$pwd | ||
$GIT_SCRIPT="$PSScriptRoot" + "\ensure_git_clean.ps1" | ||
$CORE_PROJ_DIR="$ROOT_DIR" + "\Box.V2.Core" | ||
$CORE_ASSEMBLY_NAME="Box.V2.Core" | ||
$NUGET_URL="https://api.nuget.org/v3/index.json" | ||
$CORE_NUPKG_PATH="$CORE_PROJ_DIR" + "\bin\Release\" + "$CORE_ASSEMBLY_NAME" + "." + "$NextVersion" + ".nupkg" | ||
|
||
########################################################################### | ||
# Ensure git tree is clean | ||
########################################################################### | ||
|
||
Invoke-Expression "& `"$GIT_SCRIPT`" -b $Branch" | ||
if ($LASTEXITCODE -ne 0) { | ||
exit 1 | ||
} | ||
|
||
########################################################################### | ||
# Pack Core | ||
########################################################################### | ||
|
||
dotnet pack $CORE_PROJ_DIR -c Release | ||
|
||
########################################################################### | ||
# Publish Core to the Nuget | ||
########################################################################### | ||
|
||
if ($DryRun) { | ||
Write-Output "Dry run. Package will not be published" | ||
}else{ | ||
dotnet nuget push $CORE_NUPKG_PATH -k $NugetKey -s $NUGET_URL | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
Param | ||
( | ||
[Alias('dr')] | ||
[bool]$DryRun = $true, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('ng')] | ||
[string]$NugetKey, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('nv')] | ||
[string]$NextVersion, | ||
|
||
[Alias('b')] | ||
[string]$Branch="main" | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$ROOT_DIR=$pwd | ||
$GIT_SCRIPT="$PSScriptRoot" + "\ensure_git_clean.ps1" | ||
$FRAMEWORK_PROJ_DIR="$ROOT_DIR" + "\Box.V2" | ||
$FRAMEWORK_ASSEMBLY_NAME="Box.V2" | ||
$NUGET_URL="https://api.nuget.org/v3/index.json" | ||
$FRAMEWORK_NUPKG_PATH="$FRAMEWORK_PROJ_DIR" + "\bin\Release\" + "$FRAMEWORK_ASSEMBLY_NAME" + "." + "$NextVersion" + ".nupkg" | ||
|
||
########################################################################### | ||
# Ensure git tree is clean | ||
########################################################################### | ||
|
||
Invoke-Expression "& `"$GIT_SCRIPT`" -b $Branch" | ||
if ($LASTEXITCODE -ne 0) { | ||
exit 1 | ||
} | ||
|
||
########################################################################### | ||
# Pack Framework | ||
########################################################################### | ||
|
||
|
||
|
||
########################################################################### | ||
# Publish Framework to the Nuget | ||
########################################################################### | ||
|
||
if ($DryRun) { | ||
Write-Output "Running in Dry Run mode. Package will not be published" | ||
}else{ | ||
dotnet nuget push $FRAMEWORK_NUPKG_PATH -k $NugetKey -s $NUGET_URL | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
Param | ||
( | ||
[Alias('dr')] | ||
[bool]$DryRun = $true, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('gh')] | ||
[string]$GithubToken, | ||
|
||
[Parameter(Mandatory)] | ||
[Alias('nv')] | ||
[string]$NextVersion, | ||
|
||
[Alias('rs')] | ||
[string]$ReleaseNotes="Release notes" | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$ROOT_DIR=$pwd | ||
$FRAMEWORK_PROJ_DIR="$ROOT_DIR" + "\Box.V2" | ||
$CORE_PROJ_DIR="$ROOT_DIR" + "\Box.V2.Core" | ||
$REPO_OWNER="box" | ||
$REPO_NAME="box-windows-sdk-v2" | ||
$FRAMEWORK_NUPKG_PATH=$FRAMEWORK_PROJ_DIR + "\Box.V2." + $NextVersion + ".nupkg" | ||
$FRAMEWORK_PDB_PATH=$FRAMEWORK_PROJ_DIR + "\bin\Release\Box.V2.pdb" | ||
$CORE_NUPKG_PATH=$CORE_PROJ_DIR + "\bin\Release\Box.V2.Core." + $NextVersion + ".nupkg" | ||
$CORE_PDB_PATH=$CORE_PROJ_DIR + "\bin\Release\netstandard2.0\Box.V2.Core.pdb" | ||
|
||
########################################################################### | ||
# Install dependencies | ||
########################################################################### | ||
|
||
Install-Module -Name PowerShellForGitHub | ||
|
||
########################################################################### | ||
# Create git release | ||
########################################################################### | ||
|
||
if($DryRun){ | ||
Write-Output "Dry run. Release will not be created." | ||
}else{ | ||
$password = ConvertTo-SecureString "$GithubToken" -AsPlainText -Force | ||
$Cred = New-Object System.Management.Automation.PSCredential ("Release_Bot", $password) | ||
Set-GitHubAuthentication -SessionOnly -Credential $Cred | ||
$releaseParams = @{ | ||
OwnerName = $REPO_OWNER | ||
RepositoryName = $REPO_NAME | ||
Tag = "v" + $NextVersion | ||
Name = "v" + $NextVersion | ||
Body = $ReleaseNotes | ||
} | ||
$release = New-GitHubRelease @releaseParams | ||
|
||
$release | New-GitHubReleaseAsset -Path $FRAMEWORK_NUPKG_PATH | ||
$release | New-GitHubReleaseAsset -Path $FRAMEWORK_PDB_PATH | ||
$release | New-GitHubReleaseAsset -Path $CORE_NUPKG_PATH | ||
$release | New-GitHubReleaseAsset -Path $CORE_PDB_PATH | ||
|
||
Clear-GitHubAuthentication | ||
} | ||
|
||
exit 0 |