Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support release branches that start with "releases/" #877

Merged
merged 19 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -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:',@())
Expand Down
14 changes: 7 additions & 7 deletions Actions/CreateReleaseNotes/CreateReleaseNotes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
2 changes: 1 addition & 1 deletion Actions/CreateReleaseNotes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
6 changes: 3 additions & 3 deletions Actions/CreateReleaseNotes/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 4 additions & 2 deletions Actions/Github-Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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

Expand All @@ -33,7 +34,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.
Expand Down
2 changes: 1 addition & 1 deletion Templates/AppSource App/.github/workflows/CICD.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 12 additions & 4 deletions Templates/AppSource App/.github/workflows/CreateRelease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}"
mazhelez marked this conversation as resolved.
Show resolved Hide resolved
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 ]
Expand Down
2 changes: 1 addition & 1 deletion Tests/CreateReleaseNotes.Test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading