From bf1e8f35935cb9a2361a40e47b6bf3a2ec0dad9c Mon Sep 17 00:00:00 2001 From: Maria Zhelezova <43066499+mazhelez@users.noreply.github.com> Date: Mon, 22 Jan 2024 15:05:33 +0100 Subject: [PATCH] Support release branches that start with "releases/" (#877) Support release branches that start with "releases/" - [x] Propagate workflow changes - [x] Add release notes --------- Co-authored-by: Alexander Holstrup <117829001+aholstrup1@users.noreply.github.com> --- .../CheckForUpdates.HelperFunctions.ps1 | 2 +- .../CreateReleaseNotes/CreateReleaseNotes.ps1 | 14 +++++++------- Actions/CreateReleaseNotes/README.md | 2 +- Actions/CreateReleaseNotes/action.yaml | 6 +++--- Actions/Github-Helper.psm1 | 6 ++++-- RELEASENOTES.md | 3 ++- .../AppSource App/.github/workflows/CICD.yaml | 2 +- .../.github/workflows/CreateRelease.yaml | 16 ++++++++++++---- .../.github/workflows/CICD.yaml | 2 +- .../.github/workflows/CreateRelease.yaml | 16 ++++++++++++---- Tests/CreateReleaseNotes.Test.ps1 | 2 +- 11 files changed, 45 insertions(+), 26 deletions(-) diff --git a/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 b/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 index 492e06735..4a4bd1c5e 100644 --- a/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 +++ b/Actions/CheckForUpdates/CheckForUpdates.HelperFunctions.ps1 @@ -66,7 +66,7 @@ function ModifyCICDWorkflow { } # update the branches: line with the new branches if ($CICDPushBranches) { - $yaml.Replace('on:/push:/branches:', "branches: [ '$($cicdPushBranches -join "', '")' ]") + $yaml.Replace('on:/push:/branches:', "branches: [ '$($CICDPushBranches -join "', '")' ]") } else { $yaml.Replace('on:/push:',@()) diff --git a/Actions/CreateReleaseNotes/CreateReleaseNotes.ps1 b/Actions/CreateReleaseNotes/CreateReleaseNotes.ps1 index c6bb09148..50d7ae6ee 100644 --- a/Actions/CreateReleaseNotes/CreateReleaseNotes.ps1 +++ b/Actions/CreateReleaseNotes/CreateReleaseNotes.ps1 @@ -23,21 +23,21 @@ try { # Check that tag is SemVer $SemVerObj = SemVerStrToSemVerObj -semVerStr $tag_name - # Calculate release branch - $releaseBranch = "release/$($SemVerObj.Prefix)$($SemVerObj.Major).$($SemVerObj.Minor)" + # Calculate release version + $releaseVersion = "$($SemVerObj.Prefix)$($SemVerObj.Major).$($SemVerObj.Minor)" if ($SemVerObj.Patch -or $SemVerObj.addt0 -ne 'zzz') { - $releaseBranch += ".$($SemVerObj.Patch)" + $releaseVersion += ".$($SemVerObj.Patch)" if ($SemVerObj.addt0 -ne 'zzz') { - $releaseBranch += "-$($SemVerObj.addt0)" + $releaseVersion += "-$($SemVerObj.addt0)" 1..4 | ForEach-Object { if ($SemVerObj."addt$($_)" -ne 'zzz') { - $releaseBranch += ".$($SemVerObj."addt$($_)")" + $releaseVersion += ".$($SemVerObj."addt$($_)")" } } } } - Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "releaseBranch=$releaseBranch" - Write-Host "releaseBranch=$releaseBranch" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "releaseVersion=$releaseVersion" + Write-Host "releaseVersion=$releaseVersion" $latestRelease = GetLatestRelease -token $token -api_url $ENV:GITHUB_API_URL -repository $ENV:GITHUB_REPOSITORY -ref $ENV:GITHUB_REF_NAME if ($latestRelease -and $latestRelease.PSobject.Properties.name -eq "target_commitish") { diff --git a/Actions/CreateReleaseNotes/README.md b/Actions/CreateReleaseNotes/README.md index 50f873045..72c82f3e5 100644 --- a/Actions/CreateReleaseNotes/README.md +++ b/Actions/CreateReleaseNotes/README.md @@ -23,5 +23,5 @@ none ### OUTPUT variables | Name | Description | | :-- | :-- | -| ReleaseBranch | Name of the release branch | +| ReleaseVersion | The release version | | ReleaseNotes | Release notes generated based on the changes | diff --git a/Actions/CreateReleaseNotes/action.yaml b/Actions/CreateReleaseNotes/action.yaml index 33f563715..826c58392 100644 --- a/Actions/CreateReleaseNotes/action.yaml +++ b/Actions/CreateReleaseNotes/action.yaml @@ -24,9 +24,9 @@ inputs: required: false default: '' outputs: - ReleaseBranch: - description: Name of the release branch - value: ${{ steps.createreleasenotes.outputs.ReleaseBranch }} + ReleaseVersion: + description: The release version + value: ${{ steps.createreleasenotes.outputs.releaseVersion }} ReleaseNotes: description: Release note generated based on the changes value: ${{ steps.createreleasenotes.outputs.ReleaseNotes }} diff --git a/Actions/Github-Helper.psm1 b/Actions/Github-Helper.psm1 index 25296919a..7d9d85025 100644 --- a/Actions/Github-Helper.psm1 +++ b/Actions/Github-Helper.psm1 @@ -532,8 +532,10 @@ function GetLatestRelease { # Get Latest release $latestRelease = $releases | Where-Object { -not ($_.prerelease -or $_.draft) } | Select-Object -First 1 - $releaseBranchPrefix = 'release/' - if ($ref -like "$releaseBranchPrefix*") { + $releaseBranchesFormats = 'release/*', 'releases/*' + $isReleaseBranch = [boolean] $($releaseBranchesFormats | Where-Object { $ref -like $_ }) + + if ($isReleaseBranch) { # If release branch, get the latest release from that the release branch # This is given by the latest release with the same major.minor as the release branch $semVerObj = SemVerStrToSemVerObj -semVerStr $ref.SubString($releaseBranchPrefix.Length) -allowMajorMinorOnly diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 06744f7cc..340a1f281 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -21,6 +21,7 @@ If false, the templateSha repository setting is used to download specific AL-Go - App artifacts for version 'latest' are now fetched from the latest CICD run that completed and successfully built all the projects for the corresponding branch. - Issue 824 Utilize `useCompilerFolder` setting when creating an development environment for an AL-Go project. - Issue 828 and 825 display warnings for secrets, which might cause AL-Go for GitHub to malfunction +- Support release branches that start with releases/ ### New Settings @@ -35,7 +36,7 @@ If false, the templateSha repository setting is used to download specific AL-Go - **footer** = Footer for the documentation site. (Default: Made with...) - **defaultIndexMD** = Markdown for the landing page of the documentation site. (Default: Reference documentation...) - **defaultReleaseMD** = Markdown for the landing page of the release sites. (Default: Release reference documentation...) - - *Note that in header, footer, defaultIndexMD and defaultReleaseMD you can use the following placeholders: {REPOSITORY}, {VERSION}, {INDEXTEMPLATERELATIVEPATH}, {RELEASENOTES}* + - *Note that in header, footer, defaultIndexMD and defaultReleaseMD you can use the following placeholders: {REPOSITORY}, {VERSION}, {INDEXTEMPLATERELATIVEPATH}, {RELEASENOTES}* ### New Workflows - **Deploy Reference Documentation** is a workflow, which you can invoke manually or on a schedule to generate and deploy reference documentation using the aldoc tool, using the ALDoc setting properties described above. diff --git a/Templates/AppSource App/.github/workflows/CICD.yaml b/Templates/AppSource App/.github/workflows/CICD.yaml index a803ab54c..d3dbb389a 100644 --- a/Templates/AppSource App/.github/workflows/CICD.yaml +++ b/Templates/AppSource App/.github/workflows/CICD.yaml @@ -153,7 +153,7 @@ jobs: projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} - publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} + publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || startswith(github.ref_name, 'releases/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} signArtifacts: true useArtifactCache: true diff --git a/Templates/AppSource App/.github/workflows/CreateRelease.yaml b/Templates/AppSource App/.github/workflows/CreateRelease.yaml index e93ba654a..978865587 100644 --- a/Templates/AppSource App/.github/workflows/CreateRelease.yaml +++ b/Templates/AppSource App/.github/workflows/CreateRelease.yaml @@ -27,6 +27,10 @@ on: description: Create Release Branch? type: boolean default: false + releaseBranchPrefix: + description: The prefix for the release branch. Used only if 'Create Release Branch?' is checked. + type: string + default: release/ updateVersionNumber: description: New Version Number in main branch. Use Major.Minor for absolute change, use +Major.Minor for incremental change. required: false @@ -64,7 +68,7 @@ jobs: artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }} releaseId: ${{ steps.createrelease.outputs.releaseId }} commitish: ${{ steps.analyzeartifacts.outputs.commitish }} - releaseBranch: ${{ steps.createreleasenotes.outputs.releaseBranch }} + releaseVersion: ${{ steps.createreleasenotes.outputs.releaseVersion }} steps: - name: Dump Workflow Information uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@main @@ -302,13 +306,17 @@ jobs: ref: '${{ needs.createRelease.outputs.commitish }}' - name: Create Release Branch + env: + releaseBranchPrefix: ${{ github.event.inputs.releaseBranchPrefix }} run: | $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - git checkout -b ${{ needs.CreateRelease.outputs.releaseBranch }} + $releaseBranch = "$($env:releaseBranchPrefix)" + "${{ needs.CreateRelease.outputs.releaseVersion }}" + Write-Host "Creating release branch $releaseBranch" + git checkout -b $releaseBranch git config user.name ${{ github.actor}} git config user.email ${{ github.actor}}@users.noreply.github.com - git commit --allow-empty -m "Release branch ${{ needs.CreateRelease.outputs.releaseBranch }}" - git push origin ${{ needs.CreateRelease.outputs.releaseBranch }} + git commit --allow-empty -m "Release branch $releaseBranch" + git push origin $releaseBranch UpdateVersionNumber: needs: [ CreateRelease, UploadArtifacts ] diff --git a/Templates/Per Tenant Extension/.github/workflows/CICD.yaml b/Templates/Per Tenant Extension/.github/workflows/CICD.yaml index a803ab54c..d3dbb389a 100644 --- a/Templates/Per Tenant Extension/.github/workflows/CICD.yaml +++ b/Templates/Per Tenant Extension/.github/workflows/CICD.yaml @@ -153,7 +153,7 @@ jobs: projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} - publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} + publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || startswith(github.ref_name, 'releases/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} signArtifacts: true useArtifactCache: true diff --git a/Templates/Per Tenant Extension/.github/workflows/CreateRelease.yaml b/Templates/Per Tenant Extension/.github/workflows/CreateRelease.yaml index e93ba654a..978865587 100644 --- a/Templates/Per Tenant Extension/.github/workflows/CreateRelease.yaml +++ b/Templates/Per Tenant Extension/.github/workflows/CreateRelease.yaml @@ -27,6 +27,10 @@ on: description: Create Release Branch? type: boolean default: false + releaseBranchPrefix: + description: The prefix for the release branch. Used only if 'Create Release Branch?' is checked. + type: string + default: release/ updateVersionNumber: description: New Version Number in main branch. Use Major.Minor for absolute change, use +Major.Minor for incremental change. required: false @@ -64,7 +68,7 @@ jobs: artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }} releaseId: ${{ steps.createrelease.outputs.releaseId }} commitish: ${{ steps.analyzeartifacts.outputs.commitish }} - releaseBranch: ${{ steps.createreleasenotes.outputs.releaseBranch }} + releaseVersion: ${{ steps.createreleasenotes.outputs.releaseVersion }} steps: - name: Dump Workflow Information uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@main @@ -302,13 +306,17 @@ jobs: ref: '${{ needs.createRelease.outputs.commitish }}' - name: Create Release Branch + env: + releaseBranchPrefix: ${{ github.event.inputs.releaseBranchPrefix }} run: | $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 - git checkout -b ${{ needs.CreateRelease.outputs.releaseBranch }} + $releaseBranch = "$($env:releaseBranchPrefix)" + "${{ needs.CreateRelease.outputs.releaseVersion }}" + Write-Host "Creating release branch $releaseBranch" + git checkout -b $releaseBranch git config user.name ${{ github.actor}} git config user.email ${{ github.actor}}@users.noreply.github.com - git commit --allow-empty -m "Release branch ${{ needs.CreateRelease.outputs.releaseBranch }}" - git push origin ${{ needs.CreateRelease.outputs.releaseBranch }} + git commit --allow-empty -m "Release branch $releaseBranch" + git push origin $releaseBranch UpdateVersionNumber: needs: [ CreateRelease, UploadArtifacts ] diff --git a/Tests/CreateReleaseNotes.Test.ps1 b/Tests/CreateReleaseNotes.Test.ps1 index 9b1a79e09..613f206aa 100644 --- a/Tests/CreateReleaseNotes.Test.ps1 +++ b/Tests/CreateReleaseNotes.Test.ps1 @@ -31,7 +31,7 @@ Describe 'CreateReleaseNotes Tests' { "pull-requests" = "write" } $outputs = [ordered]@{ - "ReleaseBranch" = "Name of the release branch" + "ReleaseVersion" = "The release version" "ReleaseNotes" = "Release note generated based on the changes" } YamlTest -scriptRoot $scriptRoot -actionName $actionName -actionScript $actionScript -permissions $permissions -outputs $outputs