From e00cf67d5a54217cdcc60e1596b45ec52e823566 Mon Sep 17 00:00:00 2001 From: Alexander Holstrup <117829001+aholstrup1@users.noreply.github.com> Date: Fri, 30 Dec 2022 07:55:36 +0000 Subject: [PATCH] Updated AL-Go System Files (#21562) ## Preview Note that when using the preview version of AL-Go for GitHub, you need to Update your AL-Go system files, as soon as possible when told to do so. ### Issues - Issue #312 Branching enhancements - Issue #229 Create Release action tags wrong commit - Issue #283 Create Release workflow uses deprecated actions ### Build modes support AL-Go projects can now be built in different modes, by specifying the _buildModes_ setting in AL-Go-Settings.json. Read more about build modes in the [Basic Repository settings](https://github.com/microsoft/AL-Go/blob/main/Scenarios/settings.md#basic-repository-settings). ### Continuous Delivery Continuous Delivery can now run from other branches than main. By specifying a property called branches, containing an array of branches in the deliveryContext json construct, the artifacts generated from this branch are also delivered. The branch specification can include wildcards (like release/*). Default is main, i.e. no changes to functionality. ### Continuous Deployment Continuous Deployment can now run from other branches than main. By creating a repo setting (.github/AL-Go-Settings.json) called **`-Branches`**, which is an array of branches, which will deploy the generated artifacts to this environment. The branch specification can include wildcards (like release/*), although this probably won't be used a lot in continuous deployment. Default is main, i.e. no changes to functionality. ### Create Release When locating artifacts for the various projects, the SHA used to build the artifact is used for the release tag If all projects are not available with the same SHA, this error is thrown: **The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release.** There is no longer a hard dependency on the main branch name from Create Release. ### Experimental Support Setting the repo setting "shell" to "pwsh", followed by running Update AL-Go System Files, will cause all PowerShell code to be run using PowerShell 7 instead of PowerShell 5. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Update AL-Go System Files, will cause all non-build jobs to run using Linux. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues ## v2.2 ### Enhancements - Container Event log is added as a build artifact if builds or tests are failing ### Issues - Issue #280 Overflow error when test result summary was too big - Issue #282, 292 AL-Go for GitHub causes GitHub to issue warnings - Issue #273 Potential security issue in Pull Request Handler in Open Source repositories - Issue #303 PullRequestHandler fails on added files - Issue #299 Multi-project repositories build all projects on Pull Requests - Issue #291 Issues with new Pull Request Handler - Issue #287 AL-Go pipeline fails in ReadSettings step ### Changes - VersioningStrategy 1 is no longer supported. GITHUB_ID has changed behavior (Issue #277) Co-authored-by: aholstrup1 --- .github/RELEASENOTES.copy.md | 42 +++ .../workflows/AddExistingAppOrTestApp.yaml | 5 +- .github/workflows/CICD.yaml | 276 ++++++++++++------ .github/workflows/CreateApp.yaml | 6 +- .../CreateOnlineDevelopmentEnvironment.yaml | 9 +- .../workflows/CreatePerformanceTestApp.yaml | 5 +- .github/workflows/CreateRelease.yaml | 173 +++++++---- .github/workflows/CreateTestApp.yaml | 5 +- .github/workflows/Current.yaml | 46 ++- .github/workflows/IncrementVersionNumber.yaml | 5 +- .github/workflows/NextMajor.yaml | 46 ++- .github/workflows/NextMinor.yaml | 46 ++- .github/workflows/PublishToEnvironment.yaml | 17 +- .github/workflows/PullRequestHandler.yaml | 3 +- .../workflows/UpdateGitHubGoSystemFiles.yaml | 17 +- Modules/.AL-Go/localDevEnv.ps1 | 6 +- 16 files changed, 492 insertions(+), 215 deletions(-) diff --git a/.github/RELEASENOTES.copy.md b/.github/RELEASENOTES.copy.md index e22b5f539e..85200db07c 100644 --- a/.github/RELEASENOTES.copy.md +++ b/.github/RELEASENOTES.copy.md @@ -2,6 +2,48 @@ Note that when using the preview version of AL-Go for GitHub, you need to Update your AL-Go system files, as soon as possible when told to do so. +### Issues +- Issue #312 Branching enhancements +- Issue #229 Create Release action tags wrong commit +- Issue #283 Create Release workflow uses deprecated actions + +### Build modes support +AL-Go projects can now be built in different modes, by specifying the _buildModes_ setting in AL-Go-Settings.json. Read more about build modes in the [Basic Repository settings](https://github.com/microsoft/AL-Go/blob/main/Scenarios/settings.md#basic-repository-settings). + +### Continuous Delivery + +Continuous Delivery can now run from other branches than main. By specifying a property called branches, containing an array of branches in the deliveryContext json construct, the artifacts generated from this branch are also delivered. The branch specification can include wildcards (like release/*). Default is main, i.e. no changes to functionality. + +### Continuous Deployment + +Continuous Deployment can now run from other branches than main. By creating a repo setting (.github/AL-Go-Settings.json) called **`-Branches`**, which is an array of branches, which will deploy the generated artifacts to this environment. The branch specification can include wildcards (like release/*), although this probably won't be used a lot in continuous deployment. Default is main, i.e. no changes to functionality. + +### Create Release +When locating artifacts for the various projects, the SHA used to build the artifact is used for the release tag +If all projects are not available with the same SHA, this error is thrown: **The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release.** +There is no longer a hard dependency on the main branch name from Create Release. + +### Experimental Support +Setting the repo setting "shell" to "pwsh", followed by running Update AL-Go System Files, will cause all PowerShell code to be run using PowerShell 7 instead of PowerShell 5. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues +Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Update AL-Go System Files, will cause all non-build jobs to run using Linux. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues + +## v2.2 + +### Enhancements +- Container Event log is added as a build artifact if builds or tests are failing + +### Issues +- Issue #280 Overflow error when test result summary was too big +- Issue #282, 292 AL-Go for GitHub causes GitHub to issue warnings +- Issue #273 Potential security issue in Pull Request Handler in Open Source repositories +- Issue #303 PullRequestHandler fails on added files +- Issue #299 Multi-project repositories build all projects on Pull Requests +- Issue #291 Issues with new Pull Request Handler +- Issue #287 AL-Go pipeline fails in ReadSettings step + +### Changes +- VersioningStrategy 1 is no longer supported. GITHUB_ID has changed behavior (Issue #277) + ## v2.1 ### Issues diff --git a/.github/workflows/AddExistingAppOrTestApp.yaml b/.github/workflows/AddExistingAppOrTestApp.yaml index 235ca78dc7..8bac0c514f 100644 --- a/.github/workflows/AddExistingAppOrTestApp.yaml +++ b/.github/workflows/AddExistingAppOrTestApp.yaml @@ -21,7 +21,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: AddExistingAppOrTestApp: @@ -34,11 +34,13 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0090" - name: Add existing app uses: microsoft/AL-Go-Actions/AddExistingApp@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} url: ${{ github.event.inputs.url }} @@ -48,5 +50,6 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0090" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml index 15d25ab448..2f7aba3ec2 100644 --- a/.github/workflows/CICD.yaml +++ b/.github/workflows/CICD.yaml @@ -23,7 +23,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell env: workflowDepth: 1 @@ -42,10 +42,12 @@ jobs: deliveryTargets: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} deliveryTargetCount: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} checkRunId: ${{ steps.CreateCheckRun.outputs.checkRunId }} projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} + buildModes: ${{ steps.ReadSettings.outputs.BuildModes }} steps: - name: Create CI/CD Workflow Check Run id: CreateCheckRun @@ -103,17 +105,18 @@ jobs: PRREPOFULLNAME: ${{ github.event.workflow_run.head_repository.full_name }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $location = (Get-Location).path $prfolder = '.PullRequestChanges' - Expand-Archive -Path ".\$prfolder.zip" -DestinationPath ".\$prfolder" - Remove-Item -Path ".\$prfolder.zip" -force + Expand-Archive -Path (Join-Path "." "$prfolder.zip") -DestinationPath (Join-Path "." $prfolder) + Remove-Item -Path (Join-Path "." "$prfolder.zip") -force Get-ChildItem -Path $prfolder -Recurse -File | ForEach-Object { $path = $_.FullName $deleteFile = $path.EndsWith('.REMOVE') if ($deleteFile) { $path = $path.SubString(0,$path.Length-7) } - $newPath = $path.Replace("$prfolder\","") + $newPath = $path.Replace("$prfolder$([System.IO.Path]::DirectorySeparatorChar)","") $newFolder = [System.IO.Path]::GetDirectoryName($newPath) $extension = [System.IO.Path]::GetExtension($path) $filename = [System.IO.Path]::GetFileName($path) @@ -145,47 +148,80 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0091" - name: Read settings id: ReadSettings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getProjects: 'Y' getEnvironments: '*' + - name: Determine Delivery Target Secrets + id: DetermineDeliveryTargetSecrets + run: | + $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 + $deliveryTargetSecrets = @('GitHubPackagesContext','NuGetContext','StorageContext','AppSourceContext') + $namePrefix = 'DeliverTo' + Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github/$($namePrefix)*.ps1") | ForEach-Object { + $deliveryTarget = [System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString($namePrefix.Length)) + $deliveryTargetSecrets += @("$($deliveryTarget)Context") + } + Add-Content -Path $env:GITHUB_OUTPUT -Value "Secrets=$($deliveryTargetSecrets -join ',')" + - name: Read secrets uses: microsoft/AL-Go-Actions/ReadSecrets@preview env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} - secrets: 'GitHubPackagesContext,NuGetContext,StorageContext,AppSourceContext' + secrets: ${{ steps.DetermineDeliveryTargetSecrets.outputs.Secrets }} - name: Determine Delivery Targets id: DetermineDeliveryTargets run: | $ErrorActionPreference = "STOP" - $deliveryTargets = @() - if ($env:StorageContext) { - $deliveryTargets += @("Storage") - } - if ($env:NuGetContext) { - $deliveryTargets += @("NuGet") - } - if ($env:GitHubPackagesContext) { - $deliveryTargets += @("GitHubPackages") - } + Set-StrictMode -version 2.0 + $deliveryTargets = @('GitHubPackages','NuGet','Storage') if ($env:type -eq "AppSource App" -and $env:AppSourceContinuousDelivery -eq "true") { - if ($env:AppSourceContext) { - $deliveryTargets += @("AppSource") - } + $deliveryTargets += @("AppSource") } - Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github\DeliverTo*.ps1") | ForEach-Object { - $deliveryTargets += @([System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString(9))) + $namePrefix = 'DeliverTo' + Get-Item -Path (Join-Path $ENV:GITHUB_WORKSPACE ".github/$($namePrefix)*.ps1") | ForEach-Object { + $deliveryTarget = [System.IO.Path]::GetFileNameWithoutExtension($_.Name.SubString($namePrefix.Length)) + $deliveryTargets += @($deliveryTarget) } - $deliveryTargets = $deliveryTargets | Select-Object -unique + $deliveryTargets = @($deliveryTargets | Select-Object -unique | Where-Object { + $include = $false + Write-Host "Check DeliveryTarget $_" + $contextName = "$($_)Context" + $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) + if ($deliveryContext) { + $settingName = "DeliverTo$_" + $settings = $env:Settings | ConvertFrom-Json + if (($settings.PSObject.Properties.Name -eq $settingName) -and ($settings."$settingName".PSObject.Properties.Name -eq "Branches")) { + Write-Host "Branches:" + $settings."$settingName".Branches | ForEach-Object { + Write-Host "- $_" + if ($ENV:GITHUB_REF_NAME -like $_) { + $include = $true + } + } + } + else { + $include = ($ENV:GITHUB_REF_NAME -eq 'main') + } + } + if ($include) { + Write-Host "DeliveryTarget $_ included" + } + $include + }) $deliveryTargetsJson = $deliveryTargets | ConvertTo-Json -Depth 99 -compress if ($deliveryTargets.Count -lt 2) { $deliveryTargetsJson = "[$($deliveryTargetsJson)]" } Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetsJson=$deliveryTargetsJson" @@ -195,14 +231,15 @@ jobs: Add-Content -Path $env:GITHUB_ENV -Value "DeliveryTargets=$deliveryTargetsJson" - name: Determine Build Order - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 id: BuildOrder run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} + $workflowDepth = ${{ env.workflowDepth }} if ($depth -lt $workflowDepth) { Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" $host.SetShouldExit(1) @@ -217,18 +254,18 @@ jobs: $projectsJSon = $ps | ConvertTo-Json -compress } if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=$projectsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=$($ps.count)" + Write-Host "projects$($step)Json=$projectsJson" + Write-Host "projects$($step)Count=$($ps.count)" $step-- } } while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=0" + Write-Host "projects$($step)Json=" + Write-Host "projects$($step)Count=0" $step-- } @@ -243,24 +280,30 @@ jobs: - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - get: TemplateUrl + get: templateUrl - name: Check for updates to AL-Go system files uses: microsoft/AL-Go-Actions/CheckForUpdates@preview with: + shell: powershell parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - templateUrl: ${{ env.TemplateUrl }} + templateUrl: ${{ env.templateUrl }} Build: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: project: ${{ fromJson(needs.Initialization.outputs.projects) }} + buildMode: ${{ fromJson(needs.Initialization.outputs.buildModes) }} fail-fast: false - name: Build ${{ matrix.project }} + name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} outputs: AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} @@ -322,10 +365,10 @@ jobs: lfs: true - name: Download thisbuild artifacts - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\.dependencies' + path: '.dependencies' - name: Download Pull Request Changes if: github.event_name == 'workflow_run' @@ -356,17 +399,18 @@ jobs: PRREPOFULLNAME: ${{ github.event.workflow_run.head_repository.full_name }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $location = (Get-Location).path $prfolder = '.PullRequestChanges' - Expand-Archive -Path ".\$prfolder.zip" -DestinationPath ".\$prfolder" - Remove-Item -Path ".\$prfolder.zip" -force + Expand-Archive -Path (Join-Path "." "$prfolder.zip") -DestinationPath (Join-Path "." $prfolder) + Remove-Item -Path (Join-Path "." "$prfolder.zip") -force Get-ChildItem -Path $prfolder -Recurse -File | ForEach-Object { $path = $_.FullName $deleteFile = $path.EndsWith('.REMOVE') if ($deleteFile) { $path = $path.SubString(0,$path.Length-7) } - $newPath = $path.Replace("$prfolder\","") + $newPath = $path.Replace("$prfolder$([System.IO.Path]::DirectorySeparatorChar)","") $newFolder = [System.IO.Path]::GetDirectoryName($newPath) $extension = [System.IO.Path]::GetExtension($path) $filename = [System.IO.Path]::GetFileName($path) @@ -397,6 +441,7 @@ jobs: - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} @@ -405,81 +450,93 @@ jobs: env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,StorageContext,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,storageContext,gitHubPackagesContext' - name: Run pipeline id: RunPipeline uses: microsoft/AL-Go-Actions/RunPipeline@preview + env: + BuildMode: ${{ matrix.buildMode }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} settingsJson: ${{ env.Settings }} SecretsJson: ${{ env.RepoSecrets }} - - - name: Upload thisbuild artifacts - apps - if: env.WorkflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: 'thisbuild-${{ matrix.project }}-Apps' - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: env.WorkflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: 'thisbuild-${{ matrix.project }}-TestApps' - path: '${{ matrix.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 + buildMode: ${{ matrix.buildMode }} - name: Calculate Artifact names id: calculateArtifactNames if: success() || failure() run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $settings = '${{ env.Settings }}' | ConvertFrom-Json $project = '${{ matrix.project }}' + $buildMode = '${{ matrix.buildMode }}' if ("$ENV:GITHUB_EVENT_NAME" -eq 'workflow_run') { - $event = Get-Content $ENV:GITHUB_EVENT_PATH -Encoding UTF8 | ConvertFrom-Json + $eventStr = Get-Content $ENV:GITHUB_EVENT_PATH -Encoding UTF8 + $eventStr | Out-Host + $event = $eventStr | ConvertFrom-Json $ref = "PR$($event.workflow_run.pull_requests[0].number)" } else { $ref = "$ENV:GITHUB_REF_NAME".Replace('/','_') } - if ($project -eq ".") { $project = $settings.RepoName } + if ($project -eq ".") { $project = $settings.repoName } + if ($buildMode -eq 'Default') { $buildMode = '' } 'Apps','Dependencies','TestApps','TestResults','BcptTestResults','BuildOutput','ContainerEventLog' | ForEach-Object { $name = "$($_)ArtifactsName" - $value = "$($project.Replace('\','_'))-$($ref)-$_-$($settings.repoVersion).$($settings.appBuild).$($settings.appRevision)" + $value = "$($project.Replace('\','_').Replace('/','_'))-$($ref)-$buildMode$_-$($settings.repoVersion).$($settings.appBuild).$($settings.appRevision)" Add-Content -Path $env:GITHUB_OUTPUT -Value "$name=$value" Add-Content -Path $env:GITHUB_ENV -Value "$name=$value" } + Add-Content -Path $env:GITHUB_OUTPUT -Value "BuildMode=$buildMode" + Add-Content -Path $env:GITHUB_ENV -Value "BuildMode=$buildMode" + + - name: Upload thisbuild artifacts - apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: 'thisbuild-${{ matrix.project }}-${{ env.BuildMode }}Apps' + path: '${{ matrix.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: env.workflowDepth > 1 + uses: actions/upload-artifact@v3 + with: + name: 'thisbuild-${{ matrix.project }}-${{ env.BuildMode }}TestApps' + path: '${{ matrix.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 - name: Publish artifacts - apps uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') + if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 with: - name: ${{ env.appsArtifactsName }} + name: ${{ env.AppsArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/Apps/' if-no-files-found: ignore - name: Publish artifacts - dependencies uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') + if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 with: - name: ${{ env.dependenciesArtifactsName }} + name: ${{ env.DependenciesArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/Dependencies/' if-no-files-found: ignore - name: Publish artifacts - test apps uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') + if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 with: - name: ${{ env.testAppsArtifactsName }} + name: ${{ env.TestAppsArtifactsName }} path: '${{ matrix.project }}/.buildartifacts/TestApps/' if-no-files-found: ignore @@ -487,7 +544,7 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') with: - name: ${{ env.buildOutputArtifactsName }} + name: ${{ env.BuildOutputArtifactsName }} path: '${{ matrix.project }}/BuildOutput.txt' if-no-files-found: ignore @@ -503,7 +560,7 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') with: - name: ${{ env.testResultsArtifactsName }} + name: ${{ env.TestResultsArtifactsName }} path: '${{ matrix.project }}/TestResults.xml' if-no-files-found: ignore @@ -511,7 +568,7 @@ jobs: uses: actions/upload-artifact@v3 if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') with: - name: ${{ env.bcptTestResultsArtifactsName }} + name: ${{ env.BcptTestResultsArtifactsName }} path: '${{ matrix.project }}/bcptTestResults.json' if-no-files-found: ignore @@ -520,6 +577,7 @@ jobs: if: success() || failure() uses: microsoft/AL-Go-Actions/AnalyzeTests@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -549,12 +607,13 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/PipelineCleanup@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} Deploy: needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && github.ref_name == 'main' && needs.Initialization.outputs.environmentCount > 0 + if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && needs.Initialization.outputs.environmentCount > 0 strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} runs-on: ${{ fromJson(matrix.os) }} name: Deploy to ${{ matrix.environment }} @@ -567,37 +626,49 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\.artifacts' + path: '.artifacts' - name: EnvName id: envName run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ matrix.environment }}'.split(' ')[0] Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview + with: + shell: powershell - name: Read secrets uses: microsoft/AL-Go-Actions/ReadSecrets@preview env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} - secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,Projects' + secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' - name: AuthContext id: authContext run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ steps.envName.outputs.envName }}' + $deployToSettingStr = [System.Environment]::GetEnvironmentVariable("DeployTo$envName") + if ($deployToSettingStr) { + $deployToSetting = $deployToSettingStr | ConvertFrom-Json + } + else { + $deployToSetting = [PSCustomObject]@{} + } $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { if (!($authContext)) { $authContext = [System.Environment]::GetEnvironmentVariable($_) if ($authContext) { - Write-Host "Using $_ secret" + Write-Host "Using $_ secret as AuthContext" } } } @@ -605,28 +676,39 @@ jobs: Write-Host "::Error::No AuthContext provided" exit 1 } - $environmentName = $null - "$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { - if (!($EnvironmentName)) { - $EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) - if ($EnvironmentName) { - Write-Host "Using $_ secret" - } - } + if ($deployToSetting.PSObject.Properties.name -eq "EnvironmentName") { + $environmentName = $deployToSetting.EnvironmentName + } + else { + $environmentName = $null + "$($envName)-EnvironmentName", "$($envName)_EnvironmentName", "EnvironmentName" | ForEach-Object { + if (!($EnvironmentName)) { + $EnvironmentName = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($_))) + if ($EnvironmentName) { + Write-Host "Using $_ secret as EnvironmentName" + Write-Host "Please consider using the DeployTo$_ setting instead, where you can specify EnvironmentName, projects and branches" + } + } + } } if (!($environmentName)) { $environmentName = '${{ steps.envName.outputs.envName }}' } $environmentName = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($environmentName + '${{ matrix.environment }}'.SubString($envName.Length)).ToUpperInvariant())) - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-Projects") - if (-not $projects) { - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") + if ($deployToSetting.PSObject.Properties.name -eq "projects") { + $projects = $deployToSetting.projects + } + else { + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") if (-not $projects) { - $projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") + if (-not $projects) { + $projects = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('projects'))) + } } } - if ($projects -eq '') { + if ($projects -eq '' -or $projects -eq '*') { $projects = '*' } else { @@ -637,23 +719,25 @@ jobs: Add-Content -Path $env:GITHUB_OUTPUT -Value "authContext=$authContext" Write-Host "authContext=$authContext" Add-Content -Path $env:GITHUB_OUTPUT -Value "environmentName=$environmentName" - Write-Host "environmentName=$environmentName" + Write-Host "environmentName=$([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($environmentName)))" + Write-Host "environmentName (as Base64)=$environmentName" Add-Content -Path $env:GITHUB_OUTPUT -Value "projects=$projects" Write-Host "projects=$projects" - name: Deploy uses: microsoft/AL-Go-Actions/Deploy@preview env: - authContext: ${{ steps.authContext.outputs.authContext }} + AuthContext: ${{ steps.authContext.outputs.authContext }} with: + shell: powershell type: 'CD' projects: ${{ steps.authContext.outputs.projects }} environmentName: ${{ steps.authContext.outputs.environmentName }} - artifacts: '${{ github.workspace }}\.artifacts' + artifacts: '.artifacts' Deliver: needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && github.ref_name == 'main' && needs.Initialization.outputs.deliveryTargetCount > 0 + if: always() && needs.Build.result == 'Success' && github.event_name != 'workflow_run' && needs.Initialization.outputs.deliveryTargetCount > 0 strategy: matrix: deliveryTarget: ${{ fromJson(needs.Initialization.outputs.deliveryTargets) }} @@ -667,16 +751,19 @@ jobs: - name: Download artifacts uses: actions/download-artifact@v3 with: - path: '${{ github.workspace }}\.artifacts' + path: '.artifacts' - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview + with: + shell: powershell - name: Read secrets uses: microsoft/AL-Go-Actions/ReadSecrets@preview env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} secrets: '${{ matrix.deliveryTarget }}Context' @@ -684,6 +771,7 @@ jobs: id: deliveryContext run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $contextName = '${{ matrix.deliveryTarget }}Context' $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) Add-Content -Path $env:GITHUB_OUTPUT -Value "deliveryContext=$deliveryContext" @@ -694,10 +782,11 @@ jobs: env: deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} with: + shell: powershell type: 'CD' projects: ${{ needs.Initialization.outputs.projects }} deliveryTarget: ${{ matrix.deliveryTarget }} - artifacts: '${{ github.workspace }}\.artifacts' + artifacts: '.artifacts' UpdatePRcheck: if: always() && github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' @@ -728,5 +817,6 @@ jobs: id: PostProcess uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0091" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateApp.yaml b/.github/workflows/CreateApp.yaml index 0b6a2dd229..bb47dca1f3 100644 --- a/.github/workflows/CreateApp.yaml +++ b/.github/workflows/CreateApp.yaml @@ -31,7 +31,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: CreateApp: @@ -44,17 +44,20 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0092" - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} get: type - name: Creating a new app uses: microsoft/AL-Go-Actions/CreateApp@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: ${{ env.type }} @@ -68,5 +71,6 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0092" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml index eb8a1b5ed3..88d00be6b6 100644 --- a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml +++ b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml @@ -21,7 +21,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: CreateOnlineDevelopmentEnvironment: @@ -34,11 +34,13 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0093" - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - name: Read secrets @@ -46,12 +48,15 @@ jobs: env: secrets: ${{ toJson(secrets) }} with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} secrets: 'adminCenterApiCredentials' - name: Check AdminCenterApiCredentials / Initiate Device Login (open to see code) run: | + $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $adminCenterApiCredentials = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($env:adminCenterApiCredentials)) if ($adminCenterApiCredentials) { Write-Host "AdminCenterApiCredentials provided!" @@ -73,6 +78,7 @@ jobs: - name: Create Development Environment uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} environmentName: ${{ github.event.inputs.environmentName }} reUseExistingEnvironment: ${{ github.event.inputs.reUseExistingEnvironment }} @@ -83,5 +89,6 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0093" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreatePerformanceTestApp.yaml b/.github/workflows/CreatePerformanceTestApp.yaml index 0877e5c1f1..a0390256f4 100644 --- a/.github/workflows/CreatePerformanceTestApp.yaml +++ b/.github/workflows/CreatePerformanceTestApp.yaml @@ -37,7 +37,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: CreatePerformanceTestApp: @@ -50,11 +50,13 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0102" - name: Creating a new test app uses: microsoft/AL-Go-Actions/CreateApp@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: 'Performance Test App' @@ -69,5 +71,6 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0102" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateRelease.yaml b/.github/workflows/CreateRelease.yaml index 55b1d53c7a..f6387d7bb0 100644 --- a/.github/workflows/CreateRelease.yaml +++ b/.github/workflows/CreateRelease.yaml @@ -45,13 +45,15 @@ concurrency: release defaults: run: - shell: PowerShell + shell: powershell jobs: - Initialization: + CreateRelease: runs-on: [ windows-latest ] outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }} + releaseId: ${{ steps.createrelease.outputs.releaseId }} steps: - name: Checkout uses: actions/checkout@v3 @@ -60,60 +62,87 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0094" - CreateRelease: - runs-on: [ windows-latest ] - needs: [ Initialization ] - outputs: - artifacts: ${{ steps.analyzeartifacts.outputs.artifacts }} - upload_url: ${{ steps.createrelease.outputs.upload_url }} - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Read settings id: ReadSettings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - get: TemplateUrl,RepoName + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + get: templateUrl,repoName getProjects: 'Y' - name: Check for updates to AL-Go system files uses: microsoft/AL-Go-Actions/CheckForUpdates@preview with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - templateUrl: ${{ env.TemplateUrl }} + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + templateUrl: ${{ env.templateUrl }} - name: Analyze Artifacts id: analyzeartifacts run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json - $projects | out-host + Write-Host "projects:" + $projects | ForEach-Object { Write-Host "- $_" } $include = @() + $sha = '' + $allArtifacts = @() + $page = 1 + $headers = @{ + "Authorization" = "token ${{ github.token }}" + "Accept" = "application/json" + } + do { + $repoArtifacts = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts?per_page=100&page=$page" | ConvertFrom-Json + $allArtifacts += $repoArtifacts.Artifacts + $page++ + } + while ($repoArtifacts.Artifacts.Count -gt 0) + Write-Host "Repo Artifacts count: $($repoArtifacts.total_count)" + Write-Host "Downloaded Artifacts count: $($allArtifacts.Count)" $projects | ForEach-Object { $thisProject = $_ if ($thisProject -and ($thisProject -ne '.')) { $project = $thisProject.Replace('\','_') } else { - $project = $env:RepoName + $project = $env:repoName } + $refname = "$ENV:GITHUB_REF_NAME".Replace('/','_') Write-Host "Analyzing artifacts for project $project" $appVersion = '${{ github.event.inputs.appVersion }}' - $headers = @{ - "Authorization" = "token ${{ github.token }}" - "Accept" = "application/json" - } - $allArtifacts = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts" | ConvertFrom-Json - $artifactsVersion = $appVersion if ($appVersion -eq "latest") { - $artifact = $allArtifacts.artifacts | Where-Object { $_.name -notlike "$project-PR*" -and $_.name -like "$project-*-Apps-*" } | Select-Object -First 1 + Write-Host "Grab latest" + $artifact = $allArtifacts | Where-Object { $_.name -like "$project-$refname-Apps-*" } | Select-Object -First 1 + } + else { + Write-Host "Search for $project-$refname-Apps-$appVersion" + $artifact = $allArtifacts | Where-Object { $_.name -eq "$project-$refname-Apps-$appVersion" } | Select-Object -First 1 + } + if ($artifact) { $artifactsVersion = $artifact.name.SubString($artifact.name.LastIndexOf('-Apps-')+6) } - $allArtifacts.artifacts | Where-Object { $_.name -notlike "$project-PR*" -and ($_.name -like "$project-*-Apps-$($artifactsVersion)" -or $_.name -like "$project-*-TestApps-$($artifactsVersion)" -or $_.name -like "$project-*-Dependencies-$($artifactsVersion)") } | ForEach-Object { + else { + Write-Host "::Error::No artifacts found for this project" + exit 1 + } + $artifact | out-host + if ($sha) { + if ($artifact.workflow_run.head_sha -ne $sha) { + Write-Host "::Error::The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release." + throw "The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release." + } + } + else { + $sha = $artifact.workflow_run.head_sha + } + + $allArtifacts | Where-Object { ($_.name -like "$project-$refname-Apps-$($artifactsVersion)" -or $_.name -like "$project-$refname-TestApps-$($artifactsVersion)" -or $_.name -like "$project-$refname-Dependencies-$($artifactsVersion)") } | ForEach-Object { $atype = $_.name.SubString(0,$_.name.Length-$artifactsVersion.Length-1) $atype = $atype.SubString($atype.LastIndexOf('-')+1) $include += $( [ordered]@{ "name" = $_.name; "url" = $_.archive_download_url; "atype" = $atype; "project" = $thisproject } ) @@ -127,25 +156,40 @@ jobs: $artifactsJson = $artifacts | ConvertTo-Json -compress Add-Content -Path $env:GITHUB_OUTPUT -Value "artifacts=$artifactsJson" Write-Host "artifacts=$artifactsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "commitish=$sha" + Write-Host "commitish=$sha" - name: Prepare release notes id: createreleasenotes uses: microsoft/AL-Go-Actions/CreateReleaseNotes@preview with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} tag_name: ${{ github.event.inputs.tag }} - name: Create release - uses: actions/create-release@v1 + uses: actions/github-script@v6 id: createrelease env: - GITHUB_TOKEN: ${{ github.token }} + bodyMD: ${{ steps.createreleasenotes.outputs.releaseNotes }} with: - draft: ${{ github.event.inputs.draft=='Y' }} - prerelease: ${{ github.event.inputs.prerelease=='Y' }} - release_name: ${{ github.event.inputs.name }} - tag_name: ${{ github.event.inputs.tag }} - body: ${{ steps.createreleasenotes.outputs.releaseNotes }} + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var bodyMD = process.env.bodyMD + const createReleaseResponse = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: '${{ github.event.inputs.tag }}', + name: '${{ github.event.inputs.name }}', + body: bodyMD.replaceAll('\\n','\n'), + draft: ${{ github.event.inputs.draft=='Y' }}, + prerelease: ${{ github.event.inputs.prerelease=='Y' }}, + target_commitish: '${{ steps.analyzeartifacts.outputs.commitish }}' + }); + const { + data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl } + } = createReleaseResponse; + core.setOutput('releaseId', releaseId); UploadArtifacts: runs-on: [ windows-latest ] @@ -160,45 +204,58 @@ jobs: - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} - name: Read secrets uses: microsoft/AL-Go-Actions/ReadSecrets@preview env: secrets: ${{ toJson(secrets) }} with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'NuGetContext,StorageContext' + secrets: 'nuGetContext,storageContext' - name: Download artifact run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 Write-Host "Downloading artifact ${{ matrix.name}}" $headers = @{ "Authorization" = "token ${{ github.token }}" "Accept" = "application/vnd.github.v3+json" } Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri '${{ matrix.url }}' -OutFile '${{ matrix.name }}.zip' - + - name: Upload release artifacts - uses: actions/upload-release-asset@v1 + uses: actions/github-script@v6 env: - GITHUB_TOKEN: ${{ github.token }} + releaseId: ${{ needs.createrelease.outputs.releaseId }} with: - upload_url: ${{ needs.createrelease.outputs.upload_url }} - asset_path: '${{ matrix.name }}.zip' - asset_name: '${{ matrix.name }}.zip' - asset_content_type: application/zip + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const releaseId = process.env.releaseId + const assetPath = '${{ matrix.name }}.zip' + const assetName = '${{ matrix.name }}.zip' + const fs = require('fs'); + const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: releaseId, + name: assetName, + data: fs.readFileSync(assetPath) + }); - - name: NuGetContext + - name: nuGetContext id: nuGetContext - if: ${{ env.NuGetContext }} + if: ${{ env.nuGetContext }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $nuGetContext = '' if ('${{ matrix.atype }}' -eq 'Apps') { - $nuGetContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('NuGetContext'))) + $nuGetContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('nuGetContext'))) } Add-Content -Path $env:GITHUB_OUTPUT -Value "nuGetContext=$nuGetContext" @@ -208,20 +265,22 @@ jobs: env: deliveryContext: ${{ steps.nuGetContext.outputs.nuGetContext }} with: + shell: powershell type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'NuGet' artifacts: ${{ github.event.inputs.appVersion }} atypes: 'Apps,TestApps' - - name: StorageContext + - name: storageContext id: storageContext - if: ${{ env.StorageContext }} + if: ${{ env.storageContext }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $storageContext = '' if ('${{ matrix.atype }}' -eq 'Apps') { - $storageContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('StorageContext'))) + $storageContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable('storageContext'))) } Add-Content -Path $env:GITHUB_OUTPUT -Value "storageContext=$storageContext" @@ -231,6 +290,7 @@ jobs: env: deliveryContext: ${{ steps.storageContext.outputs.storageContext }} with: + shell: powershell type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'Storage' @@ -240,7 +300,7 @@ jobs: CreateReleaseBranch: if: ${{ github.event.inputs.createReleaseBranch=='Y' }} runs-on: [ windows-latest ] - needs: [ Initialization, CreateRelease, UploadArtifacts ] + needs: [ CreateRelease, UploadArtifacts ] steps: - name: Checkout uses: actions/checkout@v3 @@ -248,6 +308,7 @@ jobs: - name: Create Release Branch run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 git checkout -b release/${{ github.event.inputs.tag }} git config user.name ${{ github.actor}} git config user.email ${{ github.actor}}@users.noreply.github.com @@ -257,19 +318,20 @@ jobs: UpdateVersionNumber: if: ${{ github.event.inputs.updateVersionNumber!='' }} runs-on: [ windows-latest ] - needs: [ Initialization, CreateRelease, UploadArtifacts ] + needs: [ CreateRelease, UploadArtifacts ] steps: - name: Update Version Number uses: microsoft/AL-Go-Actions/IncrementVersionNumber@preview with: - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: powershell + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} versionNumber: ${{ github.event.inputs.updateVersionNumber }} directCommit: ${{ github.event.inputs.directCommit }} PostProcess: if: always() runs-on: [ windows-latest ] - needs: [ Initialization, CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] + needs: [ CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] steps: - name: Checkout uses: actions/checkout@v3 @@ -278,5 +340,6 @@ jobs: id: PostProcess uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0094" - telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + telemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateTestApp.yaml b/.github/workflows/CreateTestApp.yaml index 9e099e3283..02fd15402b 100644 --- a/.github/workflows/CreateTestApp.yaml +++ b/.github/workflows/CreateTestApp.yaml @@ -33,7 +33,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: CreateTestApp: @@ -46,11 +46,13 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0095" - name: Creating a new test app uses: microsoft/AL-Go-Actions/CreateApp@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: 'Test App' @@ -64,5 +66,6 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0095" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/Current.yaml b/.github/workflows/Current.yaml index 8e6531217b..31a89b2e3e 100644 --- a/.github/workflows/Current.yaml +++ b/.github/workflows/Current.yaml @@ -8,7 +8,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell env: workflowDepth: 1 @@ -22,6 +22,7 @@ jobs: projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} @@ -33,24 +34,27 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0101" - name: Read settings id: ReadSettings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getProjects: 'Y' - name: Determine Build Order - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 id: BuildOrder run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} + $workflowDepth = ${{ env.workflowDepth }} if ($depth -lt $workflowDepth) { Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" $host.SetShouldExit(1) @@ -65,18 +69,18 @@ jobs: $projectsJSon = $ps | ConvertTo-Json -compress } if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=$projectsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=$($ps.count)" + Write-Host "projects$($step)Json=$projectsJson" + Write-Host "projects$($step)Count=$($ps.count)" $step-- } } while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=0" + Write-Host "projects$($step)Json=" + Write-Host "projects$($step)Count=0" $step-- } @@ -84,6 +88,9 @@ jobs: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: project: ${{ fromJson(needs.Initialization.outputs.projects) }} @@ -98,7 +105,7 @@ jobs: uses: actions/checkout@v3 - name: Download thisbuild artifacts - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: path: '${{ github.workspace }}\.dependencies' @@ -106,6 +113,7 @@ jobs: - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} @@ -114,13 +122,15 @@ jobs: env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - name: Run pipeline uses: microsoft/AL-Go-Actions/RunPipeline@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} @@ -128,7 +138,7 @@ jobs: SecretsJson: ${{ env.RepoSecrets }} - name: Upload thisbuild artifacts - apps - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/upload-artifact@v3 with: name: 'thisbuild-${{ matrix.project }}-Apps' @@ -137,7 +147,7 @@ jobs: retention-days: 1 - name: Upload thisbuild artifacts - test apps - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/upload-artifact@v3 with: name: 'thisbuild-${{ matrix.project }}-TestApps' @@ -150,9 +160,10 @@ jobs: if: success() || failure() run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $settings = '${{ env.Settings }}' | ConvertFrom-Json $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } + if ($project -eq ".") { $project = $settings.repoName } 'TestResults','BcptTestResults','BuildOutput','ContainerEventLog' | ForEach-Object { $name = "$($_)ArtifactsName" $value = "$($project.Replace('\','_'))-$_-Current-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" @@ -197,6 +208,7 @@ jobs: if: success() || failure() uses: microsoft/AL-Go-Actions/AnalyzeTests@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -204,6 +216,7 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/PipelineCleanup@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -219,5 +232,6 @@ jobs: id: PostProcess uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0101" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/IncrementVersionNumber.yaml b/.github/workflows/IncrementVersionNumber.yaml index 0a9ad90428..d4aa936001 100644 --- a/.github/workflows/IncrementVersionNumber.yaml +++ b/.github/workflows/IncrementVersionNumber.yaml @@ -21,7 +21,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: IncrementVersionNumber: @@ -34,11 +34,13 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0096" - name: Increment Version Number uses: microsoft/AL-Go-Actions/IncrementVersionNumber@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} versionNumber: ${{ github.event.inputs.versionNumber }} @@ -48,5 +50,6 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0096" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMajor.yaml b/.github/workflows/NextMajor.yaml index 99e724076c..667ec0e6f5 100644 --- a/.github/workflows/NextMajor.yaml +++ b/.github/workflows/NextMajor.yaml @@ -8,7 +8,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell env: workflowDepth: 1 @@ -22,6 +22,7 @@ jobs: projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} @@ -33,24 +34,27 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0099" - name: Read settings id: ReadSettings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getProjects: 'Y' - name: Determine Build Order - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 id: BuildOrder run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} + $workflowDepth = ${{ env.workflowDepth }} if ($depth -lt $workflowDepth) { Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" $host.SetShouldExit(1) @@ -65,18 +69,18 @@ jobs: $projectsJSon = $ps | ConvertTo-Json -compress } if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=$projectsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=$($ps.count)" + Write-Host "projects$($step)Json=$projectsJson" + Write-Host "projects$($step)Count=$($ps.count)" $step-- } } while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=0" + Write-Host "projects$($step)Json=" + Write-Host "projects$($step)Count=0" $step-- } @@ -84,6 +88,9 @@ jobs: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: project: ${{ fromJson(needs.Initialization.outputs.projects) }} @@ -98,7 +105,7 @@ jobs: uses: actions/checkout@v3 - name: Download thisbuild artifacts - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: path: '${{ github.workspace }}\.dependencies' @@ -106,6 +113,7 @@ jobs: - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} @@ -114,13 +122,15 @@ jobs: env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - name: Run pipeline uses: microsoft/AL-Go-Actions/RunPipeline@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} @@ -128,7 +138,7 @@ jobs: SecretsJson: ${{ env.RepoSecrets }} - name: Upload thisbuild artifacts - apps - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/upload-artifact@v3 with: name: 'thisbuild-${{ matrix.project }}-Apps' @@ -137,7 +147,7 @@ jobs: retention-days: 1 - name: Upload thisbuild artifacts - test apps - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/upload-artifact@v3 with: name: 'thisbuild-${{ matrix.project }}-TestApps' @@ -150,9 +160,10 @@ jobs: if: success() || failure() run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $settings = '${{ env.Settings }}' | ConvertFrom-Json $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } + if ($project -eq ".") { $project = $settings.repoName } 'TestResults','BcptTestResults','BuildOutput','ContainerEventLog' | ForEach-Object { $name = "$($_)ArtifactsName" $value = "$($project.Replace('\','_'))-$_-NextMajor-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" @@ -197,6 +208,7 @@ jobs: if: success() || failure() uses: microsoft/AL-Go-Actions/AnalyzeTests@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -204,6 +216,7 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/PipelineCleanup@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -219,5 +232,6 @@ jobs: id: PostProcess uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0099" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMinor.yaml b/.github/workflows/NextMinor.yaml index 173f9e20ba..8c2afb426d 100644 --- a/.github/workflows/NextMinor.yaml +++ b/.github/workflows/NextMinor.yaml @@ -8,7 +8,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell env: workflowDepth: 1 @@ -22,6 +22,7 @@ jobs: projects: ${{ steps.ReadSettings.outputs.ProjectsJson }} projectCount: ${{ steps.ReadSettings.outputs.ProjectCount }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projectDependenciesJson: ${{ steps.ReadSettings.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.ReadSettings.outputs.BuildOrderJson }} buildOrderDepth: ${{ steps.ReadSettings.outputs.BuildOrderDepth }} @@ -33,24 +34,27 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0100" - name: Read settings id: ReadSettings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getProjects: 'Y' - name: Determine Build Order - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 id: BuildOrder run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $projects = '${{ steps.ReadSettings.outputs.ProjectsJson }}' | ConvertFrom-Json $buildOrder = '${{ steps.ReadSettings.outputs.BuildOrderJson }}' | ConvertFrom-Json $depth = ${{ steps.ReadSettings.outputs.BuildOrderDepth }} - $workflowDepth = ${{ steps.ReadSettings.outputs.WorkflowDepth }} + $workflowDepth = ${{ env.workflowDepth }} if ($depth -lt $workflowDepth) { Write-Host "::Error::Project Dependencies depth is $depth. Workflow is only setup for $workflowDepth. You need to Run Update AL-Go System Files to update the workflows" $host.SetShouldExit(1) @@ -65,18 +69,18 @@ jobs: $projectsJSon = $ps | ConvertTo-Json -compress } if ($ps.Count -gt 0) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=$projectsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=$($ps.count)" - Write-Host "Projects$($step)Json=$projectsJson" - Write-Host "Projects$($step)Count=$($ps.count)" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=$projectsJson" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=$($ps.count)" + Write-Host "projects$($step)Json=$projectsJson" + Write-Host "projects$($step)Count=$($ps.count)" $step-- } } while ($step -ge 1) { - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Json=" - Add-Content -Path $env:GITHUB_OUTPUT -Value "Projects$($step)Count=0" - Write-Host "Projects$($step)Json=" - Write-Host "Projects$($step)Count=0" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Json=" + Add-Content -Path $env:GITHUB_OUTPUT -Value "projects$($step)Count=0" + Write-Host "projects$($step)Json=" + Write-Host "projects$($step)Count=0" $step-- } @@ -84,6 +88,9 @@ jobs: needs: [ Initialization ] if: ${{ needs.Initialization.outputs.projectCount > 0 }} runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: project: ${{ fromJson(needs.Initialization.outputs.projects) }} @@ -98,7 +105,7 @@ jobs: uses: actions/checkout@v3 - name: Download thisbuild artifacts - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/download-artifact@v3 with: path: '${{ github.workspace }}\.dependencies' @@ -106,6 +113,7 @@ jobs: - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} project: ${{ matrix.project }} @@ -114,13 +122,15 @@ jobs: env: secrets: ${{ toJson(secrets) }} with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,CodeSignCertificateUrl,CodeSignCertificatePassword,KeyVaultCertificateUrl,KeyVaultCertificatePassword,KeyVaultClientId,GitHubPackagesContext' + secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - name: Run pipeline uses: microsoft/AL-Go-Actions/RunPipeline@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} ProjectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} @@ -128,7 +138,7 @@ jobs: SecretsJson: ${{ env.RepoSecrets }} - name: Upload thisbuild artifacts - apps - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/upload-artifact@v3 with: name: 'thisbuild-${{ matrix.project }}-Apps' @@ -137,7 +147,7 @@ jobs: retention-days: 1 - name: Upload thisbuild artifacts - test apps - if: env.WorkflowDepth > 1 + if: env.workflowDepth > 1 uses: actions/upload-artifact@v3 with: name: 'thisbuild-${{ matrix.project }}-TestApps' @@ -150,9 +160,10 @@ jobs: if: success() || failure() run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $settings = '${{ env.Settings }}' | ConvertFrom-Json $project = '${{ matrix.project }}' - if ($project -eq ".") { $project = $settings.RepoName } + if ($project -eq ".") { $project = $settings.repoName } 'TestResults','BcptTestResults','BuildOutput','ContainerEventLog' | ForEach-Object { $name = "$($_)ArtifactsName" $value = "$($project.Replace('\','_'))-$_-NextMinor-$([DateTime]::UtcNow.ToString('yyyyMMdd'))" @@ -197,6 +208,7 @@ jobs: if: success() || failure() uses: microsoft/AL-Go-Actions/AnalyzeTests@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -204,6 +216,7 @@ jobs: if: always() uses: microsoft/AL-Go-Actions/PipelineCleanup@preview with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} Project: ${{ matrix.project }} @@ -219,5 +232,6 @@ jobs: id: PostProcess uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0100" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PublishToEnvironment.yaml b/.github/workflows/PublishToEnvironment.yaml index 9d57a96009..dd17dbda42 100644 --- a/.github/workflows/PublishToEnvironment.yaml +++ b/.github/workflows/PublishToEnvironment.yaml @@ -17,7 +17,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: Initialization: @@ -35,12 +35,14 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0097" - name: Read settings id: ReadSettings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getEnvironments: ${{ github.event.inputs.environmentName }} includeProduction: 'Y' @@ -61,24 +63,29 @@ jobs: id: envName run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ matrix.environment }}'.split(' ')[0] Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview + with: + shell: powershell - name: Read secrets uses: microsoft/AL-Go-Actions/ReadSecrets@preview env: secrets: ${{ toJson(secrets) }} with: + shell: powershell settingsJson: ${{ env.Settings }} - secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,Projects' + secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' - name: AuthContext id: authContext run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $envName = '${{ steps.envName.outputs.envName }}' $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { @@ -107,7 +114,7 @@ jobs: } $environmentName = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($environmentName + '${{ matrix.environment }}'.SubString($envName.Length)).ToUpperInvariant())) - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-Projects") + $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") if (-not $projects) { $projects = [System.Environment]::GetEnvironmentVariable("$($envName)_Projects") if (-not $projects) { @@ -128,8 +135,9 @@ jobs: - name: Deploy uses: microsoft/AL-Go-Actions/Deploy@preview env: - authContext: ${{ steps.authContext.outputs.authContext }} + AuthContext: ${{ steps.authContext.outputs.authContext }} with: + shell: powershell parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} type: 'Publish' projects: ${{ steps.authContext.outputs.projects }} @@ -148,5 +156,6 @@ jobs: id: PostProcess uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0097" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PullRequestHandler.yaml b/.github/workflows/PullRequestHandler.yaml index 95a02cda8e..9d0f463c44 100644 --- a/.github/workflows/PullRequestHandler.yaml +++ b/.github/workflows/PullRequestHandler.yaml @@ -8,7 +8,7 @@ on: defaults: run: - shell: PowerShell + shell: powershell permissions: contents: read @@ -28,6 +28,7 @@ jobs: id: ChangedFiles run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $sb = [System.Text.StringBuilder]::new() $headers = @{ "Authorization" = 'token ${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/UpdateGitHubGoSystemFiles.yaml b/.github/workflows/UpdateGitHubGoSystemFiles.yaml index b23b2e54f8..80abbff205 100644 --- a/.github/workflows/UpdateGitHubGoSystemFiles.yaml +++ b/.github/workflows/UpdateGitHubGoSystemFiles.yaml @@ -17,7 +17,7 @@ permissions: defaults: run: - shell: PowerShell + shell: powershell jobs: UpdateALGoSystemFiles: @@ -30,32 +30,36 @@ jobs: id: init uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview with: + shell: powershell eventId: "DO0098" - name: Read settings uses: microsoft/AL-Go-Actions/ReadSettings@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - get: KeyVaultName,GhTokenWorkflowSecretName,TemplateUrl + get: keyVaultName,ghTokenWorkflowSecretName,templateUrl - name: Read secrets uses: microsoft/AL-Go-Actions/ReadSecrets@preview env: secrets: ${{ toJson(secrets) }} with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} settingsJson: ${{ env.Settings }} secrets: 'ghTokenWorkflow=${{ env.GHTOKENWORKFLOWSECRETNAME }}' - - name: Override TemplateUrl + - name: Override templateUrl env: templateUrl: ${{ github.event.inputs.templateUrl }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $templateUrl = $ENV:templateUrl if ($templateUrl) { Write-Host "Using Template Url: $templateUrl" - Add-Content -Path $env:GITHUB_ENV -Value "TemplateUrl=$templateUrl" + Add-Content -Path $env:GITHUB_ENV -Value "templateUrl=$templateUrl" } - name: Calculate DirectCommit @@ -64,6 +68,7 @@ jobs: eventName: ${{ github.event_name }} run: | $ErrorActionPreference = "STOP" + Set-StrictMode -version 2.0 $directCommit = $ENV:directCommit Write-Host $ENV:eventName if ($ENV:eventName -eq 'schedule') { @@ -75,15 +80,17 @@ jobs: - name: Update AL-Go system files uses: microsoft/AL-Go-Actions/CheckForUpdates@preview with: + shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} token: ${{ env.ghTokenWorkflow }} Update: Y - templateUrl: ${{ env.TemplateUrl }} + templateUrl: ${{ env.templateUrl }} directCommit: ${{ env.directCommit }} - name: Finalize the workflow if: always() uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview with: + shell: powershell eventId: "DO0098" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/Modules/.AL-Go/localDevEnv.ps1 b/Modules/.AL-Go/localDevEnv.ps1 index 4a4f4f2f63..5c01448540 100644 --- a/Modules/.AL-Go/localDevEnv.ps1 +++ b/Modules/.AL-Go/localDevEnv.ps1 @@ -91,7 +91,7 @@ if (!($dockerProcess)) { } if ($settings.keyVaultName) { if (-not (Get-Module -ListAvailable -Name 'Az.KeyVault')) { - Write-Host -ForegroundColor Red "A keyvault name is defined in Settings, you need to have the Az.KeyVault PowerShell module installed (use Install-Module az) or you can set the keyVaultName to an empty string in the user settings file ($($ENV:UserName).Settings.json)." + Write-Host -ForegroundColor Red "A keyvault name is defined in Settings, you need to have the Az.KeyVault PowerShell module installed (use Install-Module az) or you can set the keyVaultName to an empty string in the user settings file ($($ENV:UserName).settings.json)." } } @@ -154,8 +154,8 @@ CreateDevEnv ` -baseFolder $baseFolder ` -auth $auth ` -credential $credential ` - -LicenseFileUrl $licenseFileUrl ` - -InsiderSasToken $insiderSasToken + -licenseFileUrl $licenseFileUrl ` + -insiderSasToken $insiderSasToken } catch { Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)"