diff --git a/Utils/admin/HOWTO_MAKE_A_RELEASE.md b/Utils/admin/HOWTO_MAKE_A_RELEASE.md index b410c2eaf..1d964b490 100644 --- a/Utils/admin/HOWTO_MAKE_A_RELEASE.md +++ b/Utils/admin/HOWTO_MAKE_A_RELEASE.md @@ -23,40 +23,85 @@ branch is what's on GitHub and also what's on the PowerShell gallery. The release candidate is the `devel` branch. -We want to make sure the package version is newer than what is currently -released, and that it matches the latest entry in `CHANGELOG.md`. +#### 2.1. Curate the changelog -```powershell -.\Utils\admin\Test-RscSdkCandidate.ps1 +The top entry in `CHANGELOG.md` should say `TBD` : + +```markdown +# Changelog + +## Version TBD + +... changes ... ``` -If the version is not set on the package, or if it is not the same as the -latest entry in `CHANGELOG.md`, you need push a new commit to the `devel` -branch with the updated version: +At this point leave the "TBD" as is, we will update it later. Make sure +the content of the last entry is correct. In particular, make sure PR +links are included and that the PRs are closed. + +#### 2.2. bump the version ```powershell .\Utils\admin\Set-RscSdkVersion.ps1 . ``` -Then run `Test-RscSdkCandidate.ps1` again to verify. - -Verify also that the latest entry in `CHANGELOG.md` is correct. +and push it to the branch: ```powershell git commit -a -m "Bump version to ." git push ``` +#### 2.3. Test the release candidate + +We're not running SDK tests here, we are only testing if the package +is well formed. + +```powershell +PS > .\Utils\admin\Test-RscSdkCandidate.ps1 + +version in RubrikSecurityCloud.psd1: 1.11 +version in CHANGELOG.md: 1.11 +Published on GitHub repo: False + +This branch is a candidate for a release. + +semanticVersion isPublished versionTag versionEntry +--------------- ----------- ---------- ------------ +1.11 False Version_1.11 Version 1.11… +``` + ### 3. Create a new release -First do a dry run to see what will be released: +We first do a dry run to see if any error occurs during build, tests, packaging, +and commiting to the `main` branch. ```powershell -.\Utils\admin\New-RscSdkRelease.ps1 +PS> .\Utils\admin\New-RscSdkRelease.ps1 +... +Dry run completed. Local changes were not pushed to the remote repository. ``` -If everything looks good, run the script again with the `-NotDryRun` switch: +If no error occured, run the script again with the `-NotDry` switch: ```powershell .\Utils\admin\New-RscSdkRelease.ps1 -NotDry ``` + +## Troubleshoting + +```powershell +Exception: +Line | + | Remove-Item: + | ..\Utils\Clean-RscSdk.ps1:15 Line + | -Recurse -Force .\Output.Release -ErrorAction Stop + | Access to the path + | '..\Output.Release\...' + | is denied. +``` + +Part of the release process is to clean up build and output directories, +if you're on Windows and you get this error, it's likely because you have +a PowerShell session or an IDE holding files that the script is +trying to clean up. Close everything and start a new `pwsh.exe` session. diff --git a/Utils/admin/New-RscSdkRelease.ps1 b/Utils/admin/New-RscSdkRelease.ps1 index 72e0434c9..8b0ce2962 100644 --- a/Utils/admin/New-RscSdkRelease.ps1 +++ b/Utils/admin/New-RscSdkRelease.ps1 @@ -83,6 +83,11 @@ if ($script:NotDry) { .\Utils\admin\Publish-RscSdk.ps1 } +# Clean up published artifacts +Remove-Item -Recurse .\Output.Publish\ -Force -ErrorAction SilentlyContinue +git restore . + +# Pop back git checkout $sourceBranch # Prepare devel branch for further development @@ -94,6 +99,9 @@ RunIfNotDry { } } -Write-Host "Done." -ForegroundColor Green -Write-Host "git status:" -git status +if ($script:NotDry) { + $DoneMessage = "GitHub Release $versionTag created and published to the PowerShell Gallery." +} else { + $DoneMessage = "Dry run completed. Local changes were not pushed to the remote repository." +} +Write-Host $DoneMessage -ForegroundColor Green diff --git a/Utils/admin/Test-RscSdkCandidate.ps1 b/Utils/admin/Test-RscSdkCandidate.ps1 index 358bf9ab8..8ec4e906a 100644 --- a/Utils/admin/Test-RscSdkCandidate.ps1 +++ b/Utils/admin/Test-RscSdkCandidate.ps1 @@ -37,6 +37,11 @@ if ($versionTag -notmatch "^Version_\d+\.\d+.*$") { # Check if the version tag matches the module version $psd1SemanticVersion = (& "$SdkRoot\Utils\Get-RscSdkVersion.ps1") +Write-Host "Version in RubrikSecurityCloud.psd1: " -NoNewline +Write-Host $psd1SemanticVersion -ForegroundColor Cyan +Write-Host "Version in CHANGELOG.md: " -NoNewLine +Write-Host $changelogSemanticVersion -ForegroundColor Cyan + if ( $changelogSemanticVersion -ne $psd1SemanticVersion ) { Write-Host @" @@ -64,22 +69,24 @@ $psd1SemanticVersion throw "Version mismatch. CHANGELOG: $changelogSemanticVersion, psd1: $psd1SemanticVersion." } -Write-Host "Latest version tag: " -NoNewline -Write-Host $versionTag -ForegroundColor Cyan -Write-Host "Latest version entry:" -Write-Host $versionEntry -ForegroundColor Cyan # Make sure this version tag is not already published: $existingTag = gh release list --json tagName --jq ".[] | select(.tagName == `"$versionTag`")" if ($null -ne $existingTag) { $existingTag = $existingTag.Trim() } -if ( -not [string]::IsNullOrEmpty($existingTag)) { +$isPublished = -not [string]::IsNullOrEmpty($existingTag) +Write-Host "Published on GitHub repo: " -NoNewline +Write-Host $isPublished -ForegroundColor Cyan +if ( $isPublished ) { throw "Version tag $versionTag already exists in the GitHub repository." } +Write-Host "`nThis branch is a candidate for a release." -ForegroundColor Green + [PSCustomObject]@{ + semanticVersion = $psd1SemanticVersion + isPublished = $isPublished versionTag = $versionTag versionEntry = $versionEntry - semanticVersion = $psd1SemanticVersion } \ No newline at end of file diff --git a/Utils/admin/Update-RscSdkMainBranch.ps1 b/Utils/admin/Update-RscSdkMainBranch.ps1 index 3dc2fb79b..ede78b391 100644 --- a/Utils/admin/Update-RscSdkMainBranch.ps1 +++ b/Utils/admin/Update-RscSdkMainBranch.ps1 @@ -69,6 +69,8 @@ try { } } catch { + git reset --hard HEAD + git checkout $sourceBranch throw "Failed to build the SDK: $($_ | Out-String)" }