diff --git a/.AL-Go/cloudDevEnv.ps1 b/.AL-Go/cloudDevEnv.ps1 index f146562..4f068a9 100644 --- a/.AL-Go/cloudDevEnv.ps1 +++ b/.AL-Go/cloudDevEnv.ps1 @@ -6,42 +6,54 @@ Param( [string] $environmentName = "", [bool] $reuseExistingEnvironment, - [switch] $fromVSCode + [switch] $fromVSCode, + [switch] $clean ) -$ErrorActionPreference = "stop" -Set-StrictMode -Version 2.0 +$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 -try { -$webClient = New-Object System.Net.WebClient -$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore) -$webClient.Encoding = [System.Text.Encoding]::UTF8 -Write-Host "Downloading GitHub Helper module" -$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" -$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) +function DownloadHelperFile { + param( + [string] $url, + [string] $folder + ) -Import-Module $GitHubHelperPath -. $ALGoHelperPath -local - -$baseFolder = GetBaseFolder -folder $PSScriptRoot -$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot + $prevProgressPreference = $ProgressPreference; $ProgressPreference = 'SilentlyContinue' + $name = [System.IO.Path]::GetFileName($url) + Write-Host "Downloading $name from $url" + $path = Join-Path $folder $name + Invoke-WebRequest -UseBasicParsing -uri $url -OutFile $path + $ProgressPreference = $prevProgressPreference + return $path +} +try { Clear-Host Write-Host Write-Host -ForegroundColor Yellow @' - _____ _ _ _____ ______ - / ____| | | | | __ \ | ____| + _____ _ _ _____ ______ + / ____| | | | | __ \ | ____| | | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __ | | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / / - | |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V / - \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ - + | |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V / + \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ + '@ +$tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) "$([Guid]::NewGuid().ToString())" +New-Item -Path $tmpFolder -ItemType Directory -Force | Out-Null +$GitHubHelperPath = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/Github-Helper.psm1' -folder $tmpFolder +$ALGoHelperPath = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/AL-Go-Helper.ps1' -folder $tmpFolder +DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/Packages.json' -folder $tmpFolder | Out-Null + +Import-Module $GitHubHelperPath +. $ALGoHelperPath -local + +$baseFolder = GetBaseFolder -folder $PSScriptRoot +$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot + Write-Host @' + This script will create a cloud based development environment (Business Central SaaS Sandbox) for your project. All apps and test apps will be compiled and published to the environment in the development scope. The script will also modify launch.json to have a "Cloud Sandbox ()" configuration point to your environment. @@ -52,8 +64,6 @@ if (Test-Path (Join-Path $PSScriptRoot "NewBcContainer.ps1")) { Write-Host -ForegroundColor Red "WARNING: The project has a NewBcContainer override defined. Typically, this means that you cannot run a cloud development environment" } -$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME - Write-Host if (-not $environmentName) { @@ -78,7 +88,8 @@ CreateDevEnv ` -environmentName $environmentName ` -reuseExistingEnvironment:$reuseExistingEnvironment ` -baseFolder $baseFolder ` - -project $project + -project $project ` + -clean:$clean } catch { Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)" diff --git a/.AL-Go/localDevEnv.ps1 b/.AL-Go/localDevEnv.ps1 index 0e804e9..0c73194 100644 --- a/.AL-Go/localDevEnv.ps1 +++ b/.AL-Go/localDevEnv.ps1 @@ -5,46 +5,59 @@ # Param( [string] $containerName = "", + [ValidateSet("UserPassword", "Windows")] [string] $auth = "", [pscredential] $credential = $null, [string] $licenseFileUrl = "", - [string] $insiderSasToken = "", - [switch] $fromVSCode + [switch] $fromVSCode, + [switch] $accept_insiderEula, + [switch] $clean ) -$ErrorActionPreference = "stop" -Set-StrictMode -Version 2.0 +$errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + +function DownloadHelperFile { + param( + [string] $url, + [string] $folder + ) + + $prevProgressPreference = $ProgressPreference; $ProgressPreference = 'SilentlyContinue' + $name = [System.IO.Path]::GetFileName($url) + Write-Host "Downloading $name from $url" + $path = Join-Path $folder $name + Invoke-WebRequest -UseBasicParsing -uri $url -OutFile $path + $ProgressPreference = $prevProgressPreference + return $path +} try { -$webClient = New-Object System.Net.WebClient -$webClient.CachePolicy = New-Object System.Net.Cache.RequestCachePolicy -argumentList ([System.Net.Cache.RequestCacheLevel]::NoCacheNoStore) -$webClient.Encoding = [System.Text.Encoding]::UTF8 -Write-Host "Downloading GitHub Helper module" -$GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" -$ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) - -Import-Module $GitHubHelperPath -. $ALGoHelperPath -local - -$baseFolder = GetBaseFolder -folder $PSScriptRoot -$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot - Clear-Host Write-Host Write-Host -ForegroundColor Yellow @' - _ _ _____ ______ - | | | | | __ \ | ____| + _ _ _____ ______ + | | | | | __ \ | ____| | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / - | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / - |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ - + | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / + |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ + '@ +$tmpFolder = Join-Path ([System.IO.Path]::GetTempPath()) "$([Guid]::NewGuid().ToString())" +New-Item -Path $tmpFolder -ItemType Directory -Force | Out-Null +$GitHubHelperPath = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/Github-Helper.psm1' -folder $tmpFolder +$ALGoHelperPath = DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/AL-Go-Helper.ps1' -folder $tmpFolder +DownloadHelperFile -url 'https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/Packages.json' -folder $tmpFolder | Out-Null + +Import-Module $GitHubHelperPath +. $ALGoHelperPath -local + +$baseFolder = GetBaseFolder -folder $PSScriptRoot +$project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot + Write-Host @' + This script will create a docker based local development environment for your project. NOTE: You need to have Docker installed, configured and be able to create Business Central containers for this to work. @@ -55,7 +68,7 @@ The script will also modify launch.json to have a Local Sandbox configuration po '@ -$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME +$settings = ReadSettings -baseFolder $baseFolder -project $project -userName $env:USERNAME -workflowName 'localDevEnv' Write-Host "Checking System Requirements" $dockerProcess = (Get-Process "dockerd" -ErrorAction Ignore) @@ -102,8 +115,8 @@ if (-not $credential) { if (-not $licenseFileUrl) { if ($settings.type -eq "AppSource App") { - $description = "When developing AppSource Apps, your local development environment needs the developer licensefile with permissions to your AppSource app object IDs" - $default = "" + $description = "When developing AppSource Apps for Business Central versions prior to 22, your local development environment needs the developer licensefile with permissions to your AppSource app object IDs" + $default = "none" } else { $description = "When developing PTEs, you can optionally specify a developer licensefile with permissions to object IDs of your dependant apps" @@ -132,7 +145,8 @@ CreateDevEnv ` -auth $auth ` -credential $credential ` -licenseFileUrl $licenseFileUrl ` - -insiderSasToken $insiderSasToken + -accept_insiderEula:$accept_insiderEula ` + -clean:$clean } catch { Write-Host -ForegroundColor Red "Error: $($_.Exception.Message)`nStacktrace: $($_.scriptStackTrace)" diff --git a/.github/RELEASENOTES.copy.md b/.github/RELEASENOTES.copy.md index 39e5abe..baba7e6 100644 --- a/.github/RELEASENOTES.copy.md +++ b/.github/RELEASENOTES.copy.md @@ -1,6 +1,521 @@ -## Preview +## v7.1 -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 1678 Test summary is showing too many status icons +- Issue 1640 AL1040 error due to app folder within the artifacts cache being incorrectly recognized as an app folder +- Issue 1630 Error when downloading a release, when the destination folder already exists. +- Issue 1540 and 1649 Apps with dependencies to Microsft\_\_EXCLUDE\_ apps fails deployment +- Issue 1547 Dependencies will be installed even if DependencyInstallMode is ignore, but dependencies will never be installed on production environments +- Issue 1654 GithubPackageContext does not work together with private trustedNuGetFeeds +- Issue 1627 AL-Go should throw an error or a warning if you create a release, which is older than the latest release +- Issue 1657 When no files modified on Git, deployment fails +- Issue 1530 Dependency Field Service Integration does not get published in container while Installing apps +- Issue 1644 Support for AppAuth when using a private Template repository from another organization +- Issue 1669 GitHub App authentication to download dependencies from private repositories +- Issue 1478 Rate Limit Exceeded when running Update AL-Go System files + +## v7.0 + +### Issues + +- Issue 1519 Submitting to AppSource WARNING: AuthContext.Scopes is .. should be +- Issue 1521 Dependencies not installed for multi project incremental PR build +- Issue 1522 Strange warnings in Deploy job post update to AL-Go 6.4 +- BcContainerHelper settings were only read from .github/AL-Go-Settings.json, not allowing global settings in ALGoOrgSettings for TrustedNuGetFeeds, MemoryLimit and other things that should be possible to define globally +- Issue 1526 When updating AL-Go system files, the update process (creating a PR or directly pushing to the branch) fails when there is a file or directory in the repo with the same name as the branch that is to be updated +- Legacy code signing stopped working + +### Page Scripting visualizer + +Page scripting tests have been available for AL-Go for GitHub for a while but required manual inspection of the Page scripting artifact to see the results. It is now possible to get a quick overview in the job summary section of a CICD build, similar to how regular and bcpt test results are displayed. + +No new settings are required. Test results will automatically be displayed if tests are enabled via the existing setting [pageScriptingTests](https://aka.ms/algosettings#pageScriptingTests). + +### Support for deploying to sandbox environments from a pull request + +AL-Go for GitHub now supports deploying from a PR. When using the 'Publish To Environment' workflow, it is now possible to input 'PR_X' as the App version, where 'X' is the PR Id. This will deploy the artifacts from the latest PR build to the chosen environment, if that build is completed and successful. + +All apps, which were not built by the PR build will be deployed from the last known good build. You can find a notification on the PR build explaining which build is used as the last known good build. + +> [!NOTE] +> When deploying a PR build to a sandbox environment, the app will get a special version number, which is: major.minor.maxint.run-number. This means that the sandbox environment likely needs to be deleted after the testing has ended. + +## v6.4 + +### Deprecations + +- `alwaysBuildAllProjects` will be removed after October 1st 2025. Please set the `onPull_Request` property of the `incrementalBuilds` setting to false to force full builds in Pull Requests. +- `Schedule` will be removed after October 1st 2025. The old setting, where the setting key was a combination of the workflow name and `Schedule` (dynamic setting key name) is deprecated. Instead you need to use a setting called [workflowSchedule](https://aka.ms/algosettings#workflowSchedule) and either use [Conditional Settings](https://aka.ms/algosettings#conditional-settings) or place the setting in a workflow specific settings file. + +### Issues + +- Issue 1433 Publish to Environment - DependencyInstallMode not found +- Issue 1440 Create Release fails due to recent changes to the AL-Go +- Issue 1330 CompilerFolder doesn't transfer installed Apps to NuGet resolution +- Issue 1268 Do not throw an un-understandable error during nuGet download +- Performance test sample code in 25.4 contains objects with ID 149201 and 149202, which are not renumbered +- Issue 798 Publish To Environment breaks CI/CD pipelines +- Issue 1182 Runs-on setting type is ambiguous - string or array +- Issue 1502 NuGet dependency version is always LatestMatching + +### New Workflow specific settings + +- `workflowSchedule` - can be structure with a property named `cron`, which must be a valid crontab, defining the CRON schedule for when the specified workflow should run. Default is no scheduled runs, only manual triggers. Build your crontab string here: [https://crontab.guru](https://crontab.guru). You need to run the Update AL-Go System Files workflow for the schedule to take effect.
**Note:** If you configure a WorkflowSchedule for the CI/CD workflow, AL-Go will stop triggering CICDs on push unless you have also added CICDPushBranches to your settings.
**Note also:** If you define a schedule for Update AL-Go System Files, it uses direct Commit instead of creating a PR. +- `workflowConcurrency` - is used to control concurrency of workflows. Like with the `workflowSchedule` setting, this setting should be applied in workflow specific settings files or conditional settings. By default, all workflows allows for concurrency, except for the Create Release workflow. If you are using incremental builds in CI/CD it is also recommented to set WorkflowConcurrency to:
`[ "group: ${{ github.workflow }}-${{ github.ref }}", "cancel-in-progress: true" ]`
in order to cancel prior incremental builds on the same branch.
Read more about workflow concurrency [here](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/control-the-concurrency-of-workflows-and-jobs). + +### New Repository Settings + +- `nuGetFeedSelectMode` determines the select mode when finding Business Central app packages from NuGet feeds, based on the dependency version specified in app.json. Options are: `Earliest` for earliest version of the package, `EarliestMatching` for earliest version of the package also compatible with the Business Central version used, `Exact` for the exact version of the package, `Latest` for the latest version of the package, `LatestMatching` for the latest version of the package also compatible with the Business Central version used. +- `deployTo` now has two additional properties: + - `includeTestAppsInSandboxEnvironment`, which deploys test apps and their dependencies to the specified sandbox environment if set to `true`. Deployment will fail if used on a Prod environment or if the test app has a dependency on Tests-TestLibraries. Default value is `false`. + - `excludeAppIds`, which is an array of app ids which will be excluded from deployment. Default value is `[]` +- `incrementalBuilds` - is a structure defining how you want AL-Go to handle incremental builds. When using incremental builds for a build, AL-Go will look for the latest successful build, newer than the defined `retentionDays` and only rebuild projects or apps (based on `mode`) which needs to be rebuilt. Properties in the structure includes: + - `onPush` - set this property to **true** in order to enable incremental builds in CI/CD triggered by a merge/push event. Default is **false**. + - `onPull_Request` - set this property to **false** in order to disable incremental builds in Pull Request workflows. Default is **true**. + - `onSchedule` - set this property to **true** in order to enable incremental builds in CI/CD when running on a schedule. Default is **false**. + - `retentionDays` - number of days a successful build is good (and can be used for incremental builds). Default is **30**. + - `mode` - defines the mode for incremental builds. Currently, two values are supported. Use **modifiedProjects** when you want to rebuild all apps in modified projects and depending projects or **modifiedApps** if you only want to rebuild modified apps and depending apps. + +> [!NOTE] +> The projects mentioned here are AL-Go projects in a multi-project repository. A repository can contain multiple projects and a project can contain multiple apps. + +### Run "Update AL-Go System Files" on multiple branches + +_Update AL-Go System Files_ has a new input to specify a list of branches to be updated in a single workflow run. +When running the workflow on a schedule, you can now also specify `includeBranches` in `workflowSchedule` setting, which allows you to update the specified branches. Read more at https://aka.ms/algosettings#workflowSchedule. + +> [!NOTE] +> When running "Update AL-Go System Files" on multiple branches, the template repository URL will be determined based on the branch the workflow runs on and it will be used for all of the specified branches. + +### Support for incremental builds + +AL-Go for GitHub now supports incremental builds, which means that unchanged projects or apps will be reused from the previous good build. Read [this](https://aka.ms/algosettings#incrementalBuilds) to learn more. + +> [!NOTE] +> When using incremental builds it is recommended to also set `workflowConcurrency` as defined [here](https://aka.ms/algosettings#workflowConcurrency). + +### Support for GitHub App authentication + +AL-Go for GitHub now supports using a GitHub App specification as the GhTokenWorkflow secret for a more secure way of allowing repositories to run Update AL-Go System Files and other workflows which are creating commits and pull requests. See [this description](https://github.com/microsoft/AL-Go/blob/main/Scenarios/GhTokenWorkflow.md) to learn how to use GitHub App authentication. + +### Support for embedded secrets in installApps and installTestApps settings + +If your installApps or installTestApps are secure URL, containing a secret token, you can now use a GitHub secret specification as part of or as the full URL of apps to install. An example could be: + +`"installApps": [ "https://www.dropbox.com/${{SECRETNAME}}&dl=1" ]` + +Which would hide the secret part of your URL instead of exposing it in clear text. + +## v6.3 + +### Deprecations + +- `cleanModePreprocessorSymbols` will be removed after April 1st 2025. Use [Conditional Settings](https://aka.ms/algosettings#conditional-settings) instead, specifying buildModes and the `preprocessorSymbols` setting. Read [this](https://aka.ms/algodeprecations#cleanModePreprocessorSymbols) for more information. + +### Issues + +- It is now possible to skip the modification of dependency version numbers when running the Increment Version number workflow or the Create Release workflow + +### New Repository Settings + +- [`shortLivedArtifactsRetentionDays`](https://aka.ms/algosettings#shortLivedArtifactsRetentionDays) determines the number of days to keep short lived build artifacts (f.ex build artifacts from pull request builds, next minor or next major builds). 1 is default. 0 means use GitHub default. +- [`preProcessorSymbols`](https://aka.ms/algosettings#preProcessorSymbols) is a list of preprocessor symbols to use when building the apps. This setting can be specified in [workflow specific settings files](https://aka.ms/algosettings#where-are-the-settings-located) or in [conditional settings](https://aka.ms/algosettings#conditional-settings). + +### New Versioning Strategy + +Setting versioning strategy to 3 will allow 3 segments of the version number to be defined in app.json and repoVersion. Only the 4th segment (Revision) will be defined by the GitHub [run_number](https://go.microsoft.com/fwlink/?linkid=2217416&clcid=0x409) for the CI/CD workflow. Increment version number and Create Release now also supports the ability to set a third segment to the RepoVersion and appversion in app.json. + +### Change in published artifacts + +When using `useProjectDependencies` in a multi-project repository, AL-Go for GitHub used to generate short lived build artifacts called `thisBuild---...`. This is no longer the case. Instead, normal build artifacts will be published and used by depending projects. The retention period for the short lived artifacts generated are controlled by a settings called [`shortLivedArtifactsRetentionDays`](https://aka.ms/algosettings#shortLivedArtifactsRetentionDays). + +### Preprocessor symbols + +It is now possible to define preprocessor symbols, which will be used when building your apps using the [`preProcessorSymbols`](https://aka.ms/algosettings#preProcessorSymbols) setting. This setting can be specified in workflow specific settings file or it can be used in conditional settings. + +## v6.2 + +### Issues + +- Issue 1296 Make property "appFolders" optional +- Issue 1344 Experimental feature "git submodules" seems to be a breaking change +- Issue 1305 Extra telemetry Property RepositoryOwner and RepositoryName¨ +- Add RunnerEnvironment to Telemetry +- Output a notice, not a warning, when there are no available updates for AL-Go for GitHub + +### New Repository Settings + +- `useGitSubmodules` can be either `true` or `recursive` if you want to enable Git Submodules in your repository. If your Git submodules resides in a private repository, you need to create a secret called `gitSubmodulesToken` containing a PAT with access to the submodule repositories. Like with all other secrets, you can also create a setting called `gitSubmodulesTokenSecretName` and specify the name of another secret, with these permissions (f.ex. ghTokenWorkflow). +- `commitOptions` - is a structure defining how you want AL-Go to handle automated commits or pull requests coming from AL-Go (e.g. for Update AL-Go System Files). The structure contains the following properties + - `messageSuffix` : A string you want to append to the end of commits/pull requests created by AL-Go. This can be useful if you are using the Azure Boards integration (or similar integration) to link commits to workitems. + - `pullRequestAutoMerge` : A boolean defining whether you want AL-Go pull requests to be set to auto-complete. This will auto-complete the pull requests once all checks are green and all required reviewers have approved. + - `pullRequestLabels` : A list of labels to add to the pull request. The labels need to be created in the repository before they can be applied. + +### Support for Git submodules + +In v6.1 we added experimental support for Git submodules - this did however only work if the submodules was in a public repository. In this version, you can use the `useGitSubmodules` setting to control whether you want to use Git Submodules and the `gitSubmodulesToken` secret to allow permission to read these repositories. + +## v6.1 + +### Issues + +- Issue 1241 Increment Version Number might produce wrong app.json +- When auto discovering appFolders, testFolders and bcptTestFolders - if a BCPT Test app has a dependency to a test framework app, it is added to testFolders as well as bcptTestFolders and will cause a failure. + +### New Project Settings + +- `pageScriptingTests` should be an array of page scripting test file specifications, relative to the AL-Go project. Examples of file specifications: `recordings/my*.yml` (for all yaml files in the recordings subfolder matching my\*.yml), `recordings` (for all \*.yml files in the recordings subfolder) or `recordings/test.yml` (for a single yml file) +- `doNotRunPageScriptingTests` can force the pipeline to NOT run the page scripting tests specified in pageScriptingTests. Note this setting can be set in a [workflow specific settings file](#where-are-the-settings-located) to only apply to that workflow +- `restoreDatabases` should be an array of events, indicating when you want to start with clean databases in the container. Possible events are: `BeforeBcpTests`, `BeforePageScriptingTests`, `BeforeEachTestApp`, `BeforeEachBcptTestApp`, `BeforeEachPageScriptingTest` + +### New Repository Settings + +- `trustedSigning` is a structure defining `Account`, `EndPoint` and `CertificateProfile` if you want to use trusted signing. Note that your Azure_Credentials secret (Microsoft Entra ID App or Managed identity) still needs to provide access to your azure subscription and be assigned the `Trusted Signing Certificate Profile Signer` role in the Trusted Signing Account. +- `deployTo` now has an additional property called DependencyInstallMode, which determines how dependencies are deployed if GenerateDependencyArtifact is true. Default value is `install` to install dependencies if not already installed. Other values are `ignore` for ignoring dependencies, `upgrade` for upgrading dependencies if possible and `forceUpgrade` for force upgrading dependencies. + +### Support for Azure Trusted Signing + +Read https://learn.microsoft.com/en-us/azure/trusted-signing/ for more information about Trusted Signing and how to set it up. After setting up your trusted signing account and certificate profile, you need to create a setting called [trustedSigning](https://aka.ms/algosettings#trustedSigning) for AL-Go to sign your apps using Azure Trusted Signing. + +### Support for Page Scripting Tests + +Page Scripting tests are now supported as part of CI/CD. By specifying pageScriptingTests in your project settings file, AL-Go for GitHub will automatically run these page scripting tests as part of your CI/CD workflow, generating the following build artifacts: + +- `PageScriptingTestResults` is a JUnit test results file with all results combined. +- `PageScriptingTestResultDetails` are the detailed test results (including videos) when any of the page scripting tests have failures. If the page scripting tests succeed - the details are not published. + +### Experimental support for Git submodule + +[Git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules) is now supported as part of CI/CD on your project. + +## v6.0 + +### Issues + +- Issue 1184 Publish to Environment fails on 'Permission Denied' +- AL Language extension in 25.0 doesn't contain the linux executable, use dotnet to invoke the dll instead. + +### New Settings + +- `deliverTo` now has an additional property called `ContinuousDelivery`, indicating whether or not to run continuous delivery to this deliveryTarget. Default is true. +- `trustMicrosoftNuGetFeeds` Unless this setting is set to false, AL-Go for GitHub will trust the NuGet feeds provided by Microsoft. The feeds provided by Microsoft contains all Microsoft apps, all Microsoft symbols and symbols for all AppSource apps. +- `trustedNuGetFeeds` - can be an array of NuGet feed specifications, which AL-Go for GitHub will use for dependency resolution. Every feed specification must include a URL property and can optionally include a few other properties: + - url - The URL of the feed (examples: https://pkgs.dev.azure.com/myorg/apps/\_packaging/myrepo/nuget/v3/index.json or https://nuget.pkg.github.com/mygithuborg/index.json"). + - patterns - AL-Go for GitHub will only trust packages, where the ID matches this pattern. Default is all packages (\*). + - fingerprints - If specified, AL-Go for GitHub will only trust packages signed with a certificate with a fingerprint matching one of the fingerprints in this array. + - authTokenSecret - If the NuGet feed specified by URL is private, the authTokenSecret must be the name of a secret containing the authentication token with permissions to search and read packages from the NuGet feed. + +### Support for delivering to GitHub Packages and NuGet + +With this release the implementation for delivering to NuGet packages (by adding the NuGetContext secret), is similar to the functionality behind delivering to GitHub packages and the implementation is no longer in preview. + +### Allow GitHubRunner and GitHubRunnerShell as project settings + +Previously, AL-Go required the GitHubRunner and GitHubRunnerShell settings to be set on repository level. This has now been changed such that they can be set on project level. + +## v5.3 + +### Issues + +- Issue 1105 Increment Version Number - repoVersion in .github/AL-Go-Settings.json is not updated +- Issue 1073 Publish to AppSource - Automated validation: failure +- Issue 980 Allow Scope to be PTE in continuousDeployment for PTE extensions in Sandbox (enhancement request) +- Issue 1079 AppSource App deployment failes with PerTenantExtensionCop Error PTE0001 and PTE0002 +- Issue 866 Accessing GitHub Environment Variables in DeployToCustom Scenarios for PowerShell Scripts +- Issue 1083 SyncMode for custom deployments? +- Issue 1109 Why filter deployment settings? +- Fix issue with github ref when running reusable workflows +- Issue 1098 Support for specifying the name of the AZURE_CREDENTIALS secret by adding a AZURE_CREDENTIALSSecretName setting +- Fix placeholder syntax for git ref in PullRequestHandler.yaml +- Issue 1164 Getting secrets from Azure key vault fails in Preview + +### Dependencies to PowerShell modules + +AL-Go for GitHub relies on specific PowerShell modules, and the minimum versions required for these modules are tracked in [Packages.json](https://raw.githubusercontent.com/microsoft/AL-Go/main/Actions/Packages.json) file. Should the installed modules on the GitHub runner not meet these minimum requirements, the necessary modules will be installed as needed. + +### Support managed identities and federated credentials + +All authentication context secrets now supports managed identities and federated credentials. See more [here](Scenarios/secrets.md). Furthermore, you can now use https://aka.ms/algosecrets#authcontext to learn more about the formatting of that secret. + +### Business Central Performance Toolkit Test Result Viewer + +In the summary after a Test Run, you now also have the result of performance tests. + +### Support Ubuntu runners for all AL-Go workflows + +Previously, the workflows "Update AL-Go System Files" and "TroubleShooting" were hardcoded to always run on `windows-latest` to prevent deadlocks and security issues. +From now on, `ubuntu-latest` will also be allowed for these mission critical workflows, when changing the `runs-on` setting. Additionally, only the value `pwsh` for `shell` setting is allowed when using `ubuntu-latest` runners. + +### Updated AL-Go telemetry + +AL-Go for GitHub now includes a new telemetry module. For detailed information on how to enable or disable telemetry and to see what data AL-Go logs, check out [this article](https://github.com/microsoft/AL-Go/blob/main/Scenarios/EnablingTelemetry.md). + +### New Settings + +- `deployTo`: is not really new, but has a new property: + + - **Scope** = specifies the scope of the deployment: Dev, PTE. If not specified, AL-Go for GitHub will always use the Dev Scope for AppSource Apps, but also for PTEs when deploying to sandbox environments when impersonation (refreshtoken) is used for authentication. + - **BuildMode** = specifies which buildMode to use for the deployment. Default is to use the Default buildMode. + - **\** = custom properties are now supported and will be transferred to a custom deployment script in the hashtable. + +- `bcptThresholds` is a JSON object with properties for the default thresholds for the Business Central Performance Toolkit + + - **DurationWarning** - a warning is issued if the duration of a bcpt test degrades more than this percentage (default 10) + - **DurationError** - an error is issued if the duration of a bcpt test degrades more than this percentage (default 25) + - **NumberOfSqlStmtsWarning** - a warning is issued if the number of SQL statements from a bcpt test increases more than this percentage (default 5) + - **NumberOfSqlStmtsError** - an error is issued if the number of SQL statements from a bcpt test increases more than this percentage (default 10) + +> [!NOTE] +> Duration thresholds are subject to varying results depending on the performance of the agent running the tests. Number of SQL statements executed by a test is often the most reliable indicator of performance degredation. + +## v5.2 + +### Issues + +- Issue 1084 Automatic updates for AL-Go are failing when main branch requires Pull Request + +### New Settings + +- `PowerPlatformSolutionFolder`: Contains the name of the folder containing a PowerPlatform Solution (only one) +- `DeployTo` now has two additional properties `companyId` is the Company Id from Business Central (for PowerPlatform connection) and `ppEnvironmentUrl` is the Url of the PowerPlatform environment to deploy to. + +### New Actions + +- `BuildPowerPlatform`: to build a PowerPlatform Solution +- `DeployPowerPlatform`: to deploy a PowerPlatform Solution +- `PullPowerPlatformChanges`: to pull changes made in PowerPlatform studio into the repository +- `ReadPowerPlatformSettings`: to read settings and secrets for PowerPlatform deployment +- `GetArtifactsForDeployment`: originally code from deploy.ps1 to retrieve artifacts for releases or builds - now as an action to read apps into a folder. + +### New Workflows + +- **Pull PowerPlatform Changes** for pulling changes from your PowerPlatform development environment into your AL-Go for GitHub repository +- **Push PowerPlatform Changes** for pushing changes from your AL-Go for GitHub repository to your PowerPlatform development environment + +> [!NOTE] +> PowerPlatform workflows are only available in the PTE template and will be removed if no PowerPlatformSolutionFolder is defined in settings. + +### New Scenarios (Documentation) + +- [Connect your GitHub repository to Power Platform](https://github.com/microsoft/AL-Go/blob/main/Scenarios/SetupPowerPlatform.md) +- [How to set up Service Principal for Power Platform](https://github.com/microsoft/AL-Go/blob/main/Scenarios/SetupServicePrincipalForPowerPlatform.md) +- [Try one of the Business Central and Power Platform samples](https://github.com/microsoft/AL-Go/blob/main/Scenarios/TryPowerPlatformSamples.md) +- [Publish To AppSource](https://github.com/microsoft/AL-Go/blob/main/Scenarios/PublishToAppSource.md) + +> [!NOTE] +> PowerPlatform functionality are only available in the PTE template. + +## v5.1 + +### Issues + +- Issue 1019 CI/CD Workflow still being scheduled after it was disabled +- Issue 1021 Error during Create Online Development Environment action +- Issue 1022 Error querying artifacts: No such host is known. (bcartifacts-exdbf9fwegejdqak.blob.core.windows.net:443) +- Issue 922 Deploy Reference Documentation (ALDoc) failed with custom +- ContainerName used during build was invalid if project names contained special characters +- Issue 1009 by adding a includeDependencies property in DeliverToAppSource +- Issue 997 'Deliver to AppSource' action fails for projects containing a space +- Issue 987 Resource not accessible by integration when creating release from specific version +- Issue 979 Publish to AppSource Documentation +- Issue 1018 Artifact setting - possibility to read version from app.json +- Issue 1008 Allow PullRequestHandler to use ubuntu or self hosted runners for all jobs except for pregateCheck +- Issue 962 Finer control of "shell"-property +- Issue 1041 Harden the version comparison when incrementing version number +- Issue 1042 Downloading artifacts from GitHub doesn't work with branch names which include forward slashes + +### Better artifact selection + +The artifact setting in your project settings file can now contain a `*` instead of the version number. This means that AL-Go for GitHub will determine the application dependency for your projects together with the `applicationDependency` setting and determine which Business Central version is needed for the project. + +- `"artifact": "//*//latest"` will give you the latest Business Central version, higher than your application dependency and with the same major.minor as your application dependency. +- `"artifact": "//*//first"` will give you the first Business Central version, higher than your application dependency and with the same major.minor as your application dependency. + +### New Settings + +- `deliverToAppSource`: a JSON object containing the following properties + - **productId** must be the product Id from partner Center. + - **mainAppFolder** specifies the appFolder of the main app if you have multiple apps in the same project. + - **continuousDelivery** can be set to true to enable continuous delivery of every successful build to AppSource Validation. Note that the app will only be in preview in AppSource and you will need to manually press GO LIVE in order for the app to be promoted to production. + - **includeDependencies** can be set to an array of file names (incl. wildcards) which are the names of the dependencies to include in the AppSource submission. Note that you need to set `generateDependencyArtifact` in the project settings file to true in order to include dependencies. +- Add `shell` as a property under `DeployTo` structure + +### Deprecated Settings + +- `appSourceContinuousDelivery` is moved to the `deliverToAppSource` structure +- `appSourceMainAppFolder` is moved to the `deliverToAppSource` structure +- `appSourceProductId` is moved to the `deliverToAppSource` structure + +### New parameter -clean on localdevenv and clouddevenv + +Adding -clean when running localdevenv or clouddevenv will create a clean development environment without compiling and publishing your apps. + +## v5.0 + +### Issues + +- Issue 940 Publish to Environment is broken when specifying projects to publish +- Issue 994 CI/CD ignores Deploy to GitHub Pages in private repositories + +### New Settings + +- `UpdateALGoSystemFilesEnvironment`: The name of the environment that is referenced in job `UpdateALGoSystemFiles` in the _Update AL-Go System Files_ workflow. See [jobs.\.environment](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idenvironment) for more information. Currently, only setting the environment name is supported. + +### Issues + +- Support release branches that start with releases/ +- Issue 870 Improve Error Handling when CLI is missing +- Issue 889 CreateRelease and IncrementVersionNumber workflow did not handle wild characters in `appFolders`, `testFolders` or `bcptTestFolders` settings. +- Issue 973 Prerelease is not used for deployment + +### Build modes + +AL-Go ships with Default, Translated and Clean mode out of the box. Now you can also define custom build modes in addition to the ones shipped with AL-Go. This allows you to define your own build modes, which can be used to build your apps in different ways. By default, a custom build mode will build the apps similarly to the Default mode but this behavior can be overridden in e.g. script overrides in your repository. + +## v4.1 + +### New Settings + +- `templateSha`: The SHA of the version of AL-Go currently used + +### New Actions + +- `DumpWorkflowInfo`: Dump information about running workflow +- `Troubleshooting` : Run troubleshooting for repository + +### Update AL-Go System Files + +Add another parameter when running Update AL-Go System Files, called downloadLatest, used to indicate whether to download latest version from template repository. Default value is true. +If false, the templateSha repository setting is used to download specific AL-Go System Files when calculating new files. + +### Issues + +- Issue 782 Exclude '.altestrunner/' from template .gitignore +- Issue 823 Dependencies from prior build jobs are not included when using useProjectDependencies +- 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 + +### New Settings + +- `alDoc` : JSON object with properties for the ALDoc reference document generation + - **continuousDeployment** = Determines if reference documentation will be deployed continuously as part of CI/CD. You can run the **Deploy Reference Documentation** workflow to deploy manually or on a schedule. (Default false) + - **deployToGitHubPages** = Determines whether or not the reference documentation site should be deployed to GitHub Pages for the repository. In order to deploy to GitHub Pages, GitHub Pages must be enabled and set to GitHub Actions. (Default true) + - **maxReleases** = Maximum number of releases to include in the reference documentation. (Default 3) + - **groupByProject** = Determines whether projects in multi-project repositories are used as folders in reference documentation + - **includeProjects** = An array of projects to include in the reference documentation. (Default all) + - **excludeProjects** = An array of projects to exclude in the reference documentation. (Default none)- + - **header** = Header for the documentation site. (Default: Documentation for...) + - **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}* + +### 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. +- **Troubleshooting** is a workflow, which you can invoke manually to run troubleshooting on the repository and check for settings or secrets, containing illegal values. When creating issues on https://github.com/microsoft/AL-Go/issues, we might ask you to run the troubleshooter to help identify common problems. + +### Support for ALDoc reference documentation tool + +ALDoc reference documentation tool is now supported for generating and deploying reference documentation for your projects either continuously or manually/scheduled. + +## v4.0 + +### Removal of the InsiderSasToken + +As of October 1st 2023, Business Central insider builds are now publicly available. When creating local containers with the insider builds, you will have to accept the insider EULA (https://go.microsoft.com/fwlink/?linkid=2245051) in order to continue. + +AL-Go for GitHub allows you to build and test using insider builds without any explicit approval, but please note that the insider artifacts contains the insider Eula and you automatically accept this when using the builds. + +### Issues + +- Issue 730 Support for external rulesets. +- Issue 739 Workflow specific KeyVault settings doesn't work for localDevEnv +- Using self-hosted runners while using Azure KeyVault for secrets or signing might fail with C:\\Modules doesn't exist +- PullRequestHandler wasn't triggered if only .md files where changes. This lead to PRs which couldn't be merged if a PR status check was mandatory. +- Artifacts names for PR Builds were using the merge branch instead of the head branch. + +### New Settings + +- `enableExternalRulesets`: set this setting to true if you want to allow AL-Go to automatically download external references in rulesets. +- `deliverTo`: is not really new, but has new properties and wasn't documented. The complete list of properties is here (note that some properties are deliveryTarget specific): + - **Branches** = an array of branch patterns, which are allowed to deliver to this deliveryTarget. (Default [ "main" ]) + - **CreateContainerIfNotExist** = *[Only for DeliverToStorage]* Create Blob Storage Container if it doesn't already exist. (Default false) + +### Deployment + +Environment URL is now displayed underneath the environment being deployed to in the build summary. For Custom Deployment, the script can set the GitHub Output variable `environmentUrl` in order to show a custom URL. + +## v3.3 + +### Issues + +- Issue 227 Feature request: Allow deployments with "Schema Sync Mode" = Force +- Issue 519 Deploying to onprem environment +- Issue 520 Automatic deployment to environment with annotation +- Issue 592 Internal Server Error when publishing +- Issue 557 Deployment step fails when retried +- After configuring deployment branches for an environment in GitHub and setting Deployment Branch Policy to **Protected Branches**, AL-Go for GitHub would fail during initialization (trying to get environments for deployment) +- The DetermineDeploymentEnvironments doesn't work in private repositories (needs the GITHUB_TOKEN) +- Issue 683 Settings from GitHub variables ALGoRepoSettings and ALGoOrgSettings are not applied during build pipeline +- Issue 708 Inconsistent AuthTokenSecret Behavior in Multiple Projects: 'Secrets are not available' + +### Breaking changes + +Earlier, you could specify a mapping to an environment name in an environment secret called `_EnvironmentName`, `-EnvironmentName` or just `EnvironmentName`. You could also specify the projects you want to deploy to an environment as an environment secret called `Projects`. + +This mechanism is no longer supported and you will get an error if your repository has these secrets. Instead you should use the `DeployTo` setting described below. + +Earlier, you could also specify the projects you want to deploy to an environment in a setting called `_Projects` or `-Projects`. This is also no longer supported. Instead use the `DeployTo` and remove the old settings. + +### New Actions + +- `DetermineDeliveryTargets`: Determine which delivery targets should be used for delivering artifacts from the build job. +- `DetermineDeploymentEnvironments`: Determine which deployment environments should be used for the workflow. + +### New Settings + +- `projectName`: project setting used as friendly name for an AL-Go project, to be used in the UI for various workflows, e.g. CICD, Pull Request Build. +- `fullBuildPatterns`: used by `DetermineProjectsToBuild` action to specify changes in which files and folders would trigger a full build (building all AL-Go projects). +- `excludeEnvironments`: used by `DetermineDeploymentEnvironments` action to exclude environments from the list of environments considered for deployment. +- `deployTo`: is not really new, but has new properties. The complete list of properties is here: + - **EnvironmentType** = specifies the type of environment. The environment type can be used to invoke a custom deployment. (Default SaaS) + - **EnvironmentName** = specifies the "real" name of the environment if it differs from the GitHub environment + - **Branches** = an array of branch patterns, which are allowed to deploy to this environment. (Default [ "main" ]) + - **Projects** = In multi-project repositories, this property can be a comma separated list of project patterns to deploy to this environment. (Default \*) + - **SyncMode** = ForceSync if deployment to this environment should happen with ForceSync, else Add. If deploying to the development endpoint you can also specify Development or Clean. (Default Add) + - **ContinuousDeployment** = true if this environment should be used for continuous deployment, else false. (Default: AL-Go will continuously deploy to sandbox environments or environments, which doesn't end in (PROD) or (FAT) + - **runs-on** = specifies which GitHub runner to use when deploying to this environment. (Default is settings.runs-on) + +### Custom Deployment + +By specifying a custom EnvironmentType in the DeployTo structure for an environment, you can now add a script in the .github folder called `DeployTo.ps1`. This script will be executed instead of the standard deployment mechanism with the following parameters in a HashTable: + +| Parameter | Description | Example | +| --------- | :--- | :--- | +| `$parameters.type` | Type of delivery (CD or Release) | CD | +| `$parameters.apps` | Apps to deploy | /home/runner/.../GHP-Common-main-Apps-2.0.33.0.zip | +| `$parameters.EnvironmentType` | Environment type | SaaS | +| `$parameters.EnvironmentName` | Environment name | Production | +| `$parameters.Branches` | Branches which should deploy to this environment (from settings) | main,dev | +| `$parameters.AuthContext` | AuthContext in a compressed Json structure | {"refreshToken":"mytoken"} | +| `$parameters.BranchesFromPolicy` | Branches which should deploy to this environment (from GitHub environments) | main | +| `$parameters.Projects` | Projects to deploy to this environment | | +| `$parameters.ContinuousDeployment` | Is this environment setup for continuous deployment | false | +| `$parameters."runs-on"` | GitHub runner to be used to run the deployment script | windows-latest | + +### Status Checks in Pull Requests + +AL-Go for GitHub now adds status checks to Pull Requests Builds. In your GitHub branch protection rules, you can set up "Pull Request Status Check" to be a required status check to ensure Pull Request Builds succeed before merging. + +### Secrets in AL-Go for GitHub + +In v3.2 of AL-Go for GitHub, all secrets requested by AL-Go for GitHub were available to all steps in a job one compressed JSON structure in env:Secrets. +With this update, only the steps that actually requires secrets will have the secrets available. + +## v3.2 ### Issues @@ -9,9 +524,42 @@ Issue 558 CI/CD attempts to deploy from feature branch Issue 559 Changelog includes wrong commits Publish to AppSource fails if publisher name or app name contains national or special characters Issue 598 Cleanup during flush if build pipeline doesn't cleanup properly +Issue 608 When creating a release, throw error if no new artifacts have been added +Issue 528 Give better error messages when uploading to storage accounts +Create Online Development environment workflow failed in AppSource template unless AppSourceCopMandatoryAffixes is defined in repository settings file +Create Online Development environment workflow didn't have a project parameter and only worked for single project repositories +Create Online Development environment workflow didn't work if runs-on was set to Linux +Special characters are not supported in RepoName, Project names or other settings - Use UTF8 encoding to handle special characters in GITHUB_OUTPUT and GITHUB_ENV + +### Issue 555 + +AL-Go contains several workflows, which create a Pull Request or pushes code directly. +All (except Update AL-Go System Files) earlier used the GITHUB_TOKEN to create the PR or commit. +The problem using GITHUB_TOKEN is that is doesn't trigger a pull request build or a commit build. +This is by design: https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow +Now, you can set the checkbox called Use GhTokenWorkflow to allowing you to use the GhTokenWorkflow instead of the GITHUB_TOKEN - making sure that workflows are triggered ### New Settings -- `keyVaultCodesignCertificateName`: With this setting you can delegate the codesigning to an Azure Key Vault. This can be useful if your certificate has to be stored in a Hardware Security Module + +- `keyVaultCodesignCertificateName`: With this setting you can delegate the codesigning to an Azure Key Vault. This can be useful if your certificate has to be stored in a Hardware Security Module +- `PullRequestTrigger`: With this setting you can set which trigger to use for Pull Request Builds. By default AL-Go will use pull_request_target. + +### New Actions + +- `DownloadProjectDependencies`: Downloads the dependency apps for a given project and build mode. + +### Settings and Secrets in AL-Go for GitHub + +In earlier versions of AL-Go for GitHub, all settings were available as individual environment variables to scripts and overrides, this is no longer the case. +Settings were also available as one compressed JSON structure in env:Settings, this is still the case. +Settings can no longer contain line breaks. It might have been possible to use line breaks earlier, but it would likely have unwanted consequences. +Use `$settings = $ENV:Settings | ConvertFrom-Json` to get all settings in PowerShell. + +In earlier versions of AL-Go for GitHub, all secrets requested by AL-Go for GitHub were available as individual environment variables to scripts and overrides, this is no longer the case. +As described in bug 647, all secrets available to the workflow were also available in env:\_Secrets, this is no longer the case. +All requested secrets were also available (base64 encoded) as one compressed JSON structure in env:Secrets, this is still the case. +Use `$secrets = $ENV:Secrets | ConvertFrom-Json` to get all requested secrets in PowerShell. +You cannot get to any secrets that weren't requested by AL-Go for GitHub. ## v3.1 @@ -22,7 +570,6 @@ Issue #453 DeliverToStorage - override fails reading secrets Issue #434 Use gh auth token to get authentication token instead of gh auth status Issue #501 The Create New App action will now use 22.0.0.0 as default application reference and include NoImplicitwith feature. - ### New behavior The following workflows: @@ -38,13 +585,13 @@ All these actions now uses the selected branch in the **Run workflow** dialog as ### New Settings -- `UseCompilerFolder`: Setting useCompilerFolder to true causes your pipelines to use containerless compiling. Unless you also set `doNotPublishApps` to true, setting useCompilerFolder to true won't give you any performance advantage, since AL-Go for GitHub will still need to create a container in order to publish and test the apps. In the future, publishing and testing will be split from building and there will be other options for getting an instance of Business Central for publishing and testing. +- `UseCompilerFolder`: Setting useCompilerFolder to true causes your pipelines to use containerless compiling. Unless you also set `doNotPublishApps` to true, setting useCompilerFolder to true won't give you any performance advantage, since AL-Go for GitHub will still need to create a container in order to publish and test the apps. In the future, publishing and testing will be split from building and there will be other options for getting an instance of Business Central for publishing and testing. - `vsixFile`: vsixFile should be a direct download URL to the version of the AL Language extension you want to use for building the project or repo. By default, AL-Go will use the AL Language extension that comes with the Business Central Artifacts. ### New Workflows -- **_BuildALGoProject** is a reusable workflow that unites the steps for building an AL-Go projects. It has been reused in the following workflows: _CI/CD_, _Pull Request Build_, _NextMinor_, _NextMajor_ and _Current_. -The workflow appears under the _Actions_ tab in GitHub, but it is not actionable in any way. +- **\_BuildALGoProject** is a reusable workflow that unites the steps for building an AL-Go projects. It has been reused in the following workflows: _CI/CD_, _Pull Request Build_, _NextMinor_, _NextMajor_ and _Current_. + The workflow appears under the _Actions_ tab in GitHub, but it is not actionable in any way. ### New Actions @@ -58,29 +605,36 @@ Obviously, if you build and test your app for Business Central versions prior to ## v3.0 ### **NOTE:** When upgrading to this version + When upgrading to this version form earlier versions of AL-Go for GitHub, you will need to run the _Update AL-Go System Files_ workflow twice if you have the `useProjectDependencies` setting set to _true_. ### Publish to unknown environment + You can now run the **Publish To Environment** workflow without creating the environment in GitHub or settings up-front, just by specifying the name of a single environment in the Environment Name when running the workflow. Subsequently, if an AuthContext secret hasn't been created for this environment, the Device Code flow authentication will be initiated from the Publish To Environment workflow and you can publish to the new environment without ever creating a secret. Open Workflow details to get the device Code for authentication in the job summary for the initialize job. ### Create Online Dev. Environment + When running the **Create Online Dev. Environment** workflow without having the _adminCenterApiCredentials_ secret created, the workflow will intiate the deviceCode flow and allow you to authenticate to the Business Central Admin Center. Open Workflow details to get the device Code for authentication in the job summary for the initialize job. ### Issues + - Issue #391 Create release action - CreateReleaseBranch error - Issue 434 Building local DevEnv, downloading dependencies: Authentication fails when using "gh auth status" ### Changes to Pull Request Process + In v2.4 and earlier, the PullRequestHandler would trigger the CI/CD workflow to run the PR build. Now, the PullRequestHandler will perform the build and the CI/CD workflow is only run on push (or manual dispatch) and will perform a complete build. ### Build modes per project + Build modes can now be specified per project ### New Actions + - **DetermineProjectsToBuild** is used to determine which projects to build in PullRequestHandler, CI/CD, Current, NextMinor and NextMajor workflows. - **CalculateArtifactNames** is used to calculate artifact names in PullRequestHandler, CI/CD, Current, NextMinor and NextMajor workflows. - **VerifyPRChanges** is used to verify whether a PR contains changes, which are not allowed from a fork. @@ -88,6 +642,7 @@ Build modes can now be specified per project ## v2.4 ### Issues + - Issue #171 create a workspace file when creating a project - Issue #356 Publish to AppSource fails in multi project repo - Issue #358 Publish To Environment Action stopped working in v2.3 @@ -97,9 +652,11 @@ Build modes can now be specified per project - Issue #376 CICD jobs that are triggered by the pull request trigger run directly to an error if title contains quotes ### Release Branches + **NOTE:** Release Branches are now only named after major.minor if the patch value is 0 in the release tag (which must be semver compatible) This version contains a number of bug fixes to release branches, to ensure that the recommended branching strategy is fully supported. Bugs fixed includes: + - Release branches was named after the full tag (1.0.0), even though subsequent hotfixes released from this branch would be 1.0.x - Release branches named 1.0 wasn't picked up as a release branch - Release notes contained the wrong changelog @@ -112,9 +669,11 @@ Recommended branching strategy: ![Branching Strategy](https://raw.githubusercontent.com/microsoft/AL-Go/main/Scenarios/images/branchingstrategy.png) ### New Settings + New Project setting: EnableTaskScheduler in container executing tests and when setting up local development environment ### Support for GitHub variables: ALGoOrgSettings and ALGoRepoSettings + Recently, GitHub added support for variables, which you can define on your organization or your repository. AL-Go now supports that you can define a GitHub variable called ALGoOrgSettings, which will work for all repositories (with access to the variable) Org Settings will be applied before Repo settings and local repository settings files will override values in the org settings @@ -123,11 +682,13 @@ Example for usage could be setup of branching strategies, versioning or an appDe appDependencyProbingPaths from settings variables are merged together with appDependencyProbingPaths defined in repositories ### Refactoring and tests + ReadSettings has been refactored to allow organization wide settings to be added as well. CI Tests have been added to cover ReadSettings. ## v2.3 ### Issues + - Issue #312 Branching enhancements - Issue #229 Create Release action tags wrong commit - Issue #283 Create Release workflow uses deprecated actions @@ -137,73 +698,89 @@ ReadSettings has been refactored to allow organization wide settings to be added - Issue #345 LocalDevEnv.ps1 can't Dowload the file license file ### New Settings + New Project setting: AssignPremiumPlan on user in container executing tests and when setting up local development environment New Repo setting: unusedALGoSystemFiles is an array of AL-Go System Files, which won't be updated during Update AL-Go System Files. They will instead be removed. Use with care, as this can break the AL-Go for GitHub functionality and potentially leave your repo no longer functional. ### 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). ### LocalDevEnv / CloudDevEnv + With the support for PowerShell 7 in BcContainerHelper, the scripts LocalDevEnv and CloudDevEnv (placed in the .AL-Go folder) for creating development environments have been modified to run inside VS Code instead of spawning a new powershell 5.1 session. ### 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 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. + +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. ### AL-Go Tests + Some unit tests have been added and AL-Go unit tests can now be run directly from VS Code. Another set of end to end tests have also been added and in the documentation on contributing to AL-Go, you can see how to run these in a local fork or from VS Code. ### LF, UTF8 and JSON + GitHub natively uses LF as line seperator in source files. In earlier versions of AL-Go for GitHub, many scripts and actions would use CRLF and convert back and forth. Some files were written with UTF8 BOM (Byte Order Mark), other files without and JSON formatting was done using PowerShell 5.1 (which is different from PowerShell 7). In the latest version, we always use LF as line seperator, UTF8 without BOM and JSON files are written using PowerShell 7. If you have self-hosted runners, you need to ensure that PS7 is installed to make this work. ### 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 +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 #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 + - Issue #233 AL-Go for GitHub causes GitHub to issue warnings - Issue #244 Give error if AZURE_CREDENTIALS contains line breaks ### Changes + - New workflow: PullRequestHandler to handle all Pull Requests and pass control safely to CI/CD - Changes to yaml files, PowerShell scripts and codeowners files are not permitted from fork Pull Requests - Test Results summary (and failed tests) are now displayed directly in the CI/CD workflow and in the Pull Request Check ### Continuous Delivery + - Proof Of Concept Delivery to GitHub Packages and Nuget ## v2.0 ### Issues + - Issue #143 Commit Message for **Increment Version Number** workflow - Issue #160 Create local DevEnv aith appDependencyProbingPaths - Issue #156 Versioningstrategy 2 doesn't use 24h format @@ -217,15 +794,18 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat - Special characters wasn't supported in parameters to GitHub actions (Create New App etc.) ### Continuous Delivery + - Added new GitHub Action "Deliver" to deliver build output to Storage or AppSource - Refactor CI/CD and Release workflows to use new deliver action -- Custom delivery supported by creating scripts with the naming convention DeliverTo*.ps1 in the .github folder +- Custom delivery supported by creating scripts with the naming convention DeliverTo\*.ps1 in the .github folder ### AppSource Apps + - New workflow: Publish to AppSource - Continuous Delivery to AppSource validation supported ### Settings + - New Repo setting: CICDPushBranches can be specified as an array of branches, which triggers a CI/CD workflow on commit. Default is main', release/\*, feature/\* - New Repo setting: CICDPullRequestBranches can be specified as an array of branches, which triggers a CI/CD workflow on pull request. Default is main - New Repo setting: CICDSchedule can specify a CRONTab on when you want to run CI/CD on a schedule. Note that this will disable Push and Pull Request triggers unless specified specifically using CICDPushBranches or CICDPullRequestBranches @@ -236,16 +816,19 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat - New project Setting: AppSourceMainAppFolder. If you have multiple appFolders, this is the folder name of the main app to submit to AppSource. ### All workflows -- Support 2 folder levels projects (apps\w1, apps\dk etc.) + +- Support 2 folder levels projects (apps\\w1, apps\\dk etc.) - Better error messages for if an error occurs within an action - Special characters are now supported in secrets - Initial support for agents running inside containers on a host - Optimized workflows to have fewer jobs ### Update AL-Go System Files Workflow + - workflow now displays the currently used template URL when selecting the Run Workflow action ### CI/CD workflow + - Better detection of changed projects - appDependencyProbingPaths did not support multiple projects in the same repository for latestBuild dependencies - appDependencyProbingPaths with release=latestBuild only considered the last 30 artifacts @@ -254,49 +837,60 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat - Continue on error with Deploy and Deliver ### CI/CD and Publish To New Environment + - Base functionality for selecting a specific GitHub runner for an environment -- Include dependencies artifacts when deploying (if generateDependencyArtifacts is true) +- Include dependencies artifacts when deploying (if generateDependencyArtifact is true) ### localDevEnv.ps1 and cloudDevEnv.ps1 + - Display clear error message if something goes wrong ## v1.5 ### Issues + - Issue #100 - Add more resilience to localDevEnv.ps1 and cloudDevEnv.ps1 - Issue #131 - Special characters are not allowed in secrets ### All workflows + - During initialize, all AL-Go settings files are now checked for validity and reported correctly - During initialize, the version number of AL-Go for GitHub is printed in large letters (incl. preview or dev.) ### New workflow: Create new Performance Test App + - Create BCPT Test app and add to bcptTestFolders to run bcpt Tests in workflows (set doNotRunBcptTests in workflow settings for workflows where you do NOT want this) ### Update AL-Go System Files Workflow + - Include release notes of new version in the description of the PR (and in the workflow output) ### CI/CD workflow + - Apps are not signed when the workflow is running as a Pull Request validation - if a secret called applicationInsightsConnectionString exists, then the value of that will be used as ApplicationInsightsConnectionString for the app ### Increment Version Number Workflow + - Bugfix: increment all apps using f.ex. +0.1 would fail. ### Environments -- Add suport for EnvironmentName redirection by adding an Environment Secret under the environment or a repo secret called \_EnvironmentName with the actual environment name. + +- Add suport for EnvironmentName redirection by adding an Environment Secret under the environment or a repo secret called \\_EnvironmentName with the actual environment name. - No default environment name on Publish To Environment -- For multi-project repositories, you can specify an environment secret called Projects or a repo setting called \_Projects, containing the projects you want to deploy to this environment. +- For multi-project repositories, you can specify an environment secret called Projects or a repo setting called \\_Projects, containing the projects you want to deploy to this environment. ### Settings + - New setting: **runs-on** to allow modifying runs-on for all jobs (requires Update AL-Go System files after changing the setting) - New setting: **DoNotSignApps** - setting this to true causes signing of the app to be skipped - New setting: **DoNotPublishApps** - setting this to true causes the workflow to skip publishing, upgrading and testing the app to improve performance. - New setting: **ConditionalSettings** to allow to use different settings for specific branches. Example: + ``` "ConditionalSettings": [ { - "branches": [ + "branches": [ "feature/*" ], "settings": { @@ -306,6 +900,7 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat } ] ``` + - Default **BcContainerHelperVersion** is now based on AL-Go version. Preview AL-Go selects preview bcContainerHelper, normal selects latest. - New Setting: **bcptTestFolders** contains folders with BCPT tests, which will run in all build workflows - New Setting: set **doNotRunBcptTest** to true (in workflow specific settings file?) to avoid running BCPT tests @@ -314,54 +909,64 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat ## v1.4 ### All workflows + - Add requested permissions to avoid dependency on user/org defaults being too permissive ### Update AL-Go System Files Workflow + - Default host to https://github.com/ (you can enter **myaccount/AL-Go-PTE@main** to change template) -- Support for "just" changing branch (ex. **\@Preview**) to shift to the preview version +- Support for "just" changing branch (ex. **@Preview**) to shift to the preview version ### CI/CD Workflow + - Support for feature branches (naming **feature/\***) - CI/CD workflow will run, but not generate artifacts nor deploy to QA ### Create Release Workflow + - Support for release branches - Force Semver format on release tags - Add support for creating release branches on release (naming release/\*) - Add support for incrementing main branch after release ### Increment version number workflow + - Add support for incremental (and absolute) version number change ### Environments + - Support environmentName redirection in CI/CD and Publish To Environments workflows - If the name in Environments or environments settings doesn't match the actual environment name, -- You can add a secret called EnvironmentName under the environment (or \_ENVIRONMENTNAME globally) - +- You can add a secret called EnvironmentName under the environment (or \\_ENVIRONMENTNAME globally) ## v1.3 ### Issues -- Issue #90 - Environments did not work. Secrets for environments specified in settings can now be **\_AUTHCONTEXT** + +- Issue #90 - Environments did not work. Secrets for environments specified in settings can now be **\\_AUTHCONTEXT** ### CI/CD Workflow + - Give warning instead of error If no artifacts are found in **appDependencyProbingPaths** ## v1.2 ### Issues + - Issue #90 - Environments did not work. Environments (even if only defined in the settings file) did not work for private repositories if you didn't have a premium subscription. ### Local scripts -- **LocalDevEnv.ps1** and ***CloudDevEnv.ps1** will now spawn a new PowerShell window as admin instead of running inside VS Code. Normally people doesn't run VS Code as administrator, and they shouldn't have to. Furthermore, I have seen a some people having problems when running these scripts inside VS Code. +- **LocalDevEnv.ps1** and \***CloudDevEnv.ps1** will now spawn a new PowerShell window as admin instead of running inside VS Code. Normally people doesn't run VS Code as administrator, and they shouldn't have to. Furthermore, I have seen a some people having problems when running these scripts inside VS Code. ## v1.1 ### Settings + - New Repo Setting: **GenerateDependencyArtifact** (default **false**). When true, CI/CD pipeline generates an artifact with the external dependencies used for building the apps in this repo. - New Repo Setting: **UpdateDependencies** (default **false**). When true, the default artifact for building the apps in this repo is not the latest available artifacts for this country, but instead the first compatible version (after calculating application dependencies). It is recommended to run Test Current, Test NextMinor and Test NextMajor in order to test your app against current and future builds. ### CI/CD Workflow + - New Artifact: BuildOutput.txt. All compiler warnings and errors are emitted to this file to make it easier to investigate compiler errors and build a better UI for build errors and test results going forward. - TestResults artifact name to include repo version number and workflow name (for Current, NextMinor and NextMajor) - Default dependency version in appDependencyProbingPaths setting used is now latest Release instead of LatestBuild diff --git a/.github/workflows/AddExistingAppOrTestApp.yaml b/.github/workflows/AddExistingAppOrTestApp.yaml index e9492e7..545dfd1 100644 --- a/.github/workflows/AddExistingAppOrTestApp.yaml +++ b/.github/workflows/AddExistingAppOrTestApp.yaml @@ -13,12 +13,18 @@ on: description: Direct Download Url of .app or .zip file required: true directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: + actions: read contents: write + id-token: write pull-requests: write defaults: @@ -31,31 +37,52 @@ env: jobs: AddExistingAppOrTestApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 + with: + shell: powershell + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - eventId: "DO0090" + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Add existing app - uses: microsoft/AL-Go-Actions/AddExistingApp@preview + uses: microsoft/AL-Go-Actions/AddExistingApp@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} project: ${{ github.event.inputs.project }} url: ${{ github.event.inputs.url }} directCommit: ${{ github.event.inputs.directCommit }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0090" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml index 47a51c3..229edeb 100644 --- a/.github/workflows/CICD.yaml +++ b/.github/workflows/CICD.yaml @@ -14,8 +14,10 @@ defaults: shell: powershell permissions: - contents: read actions: read + contents: read + id-token: write + pages: read env: workflowDepth: 1 @@ -24,155 +26,151 @@ env: jobs: Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - environments: ${{ steps.ReadSettings.outputs.EnvironmentsJson }} - environmentCount: ${{ steps.ReadSettings.outputs.EnvironmentCount }} - deliveryTargets: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} - deliveryTargetCount: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetCount }} + environmentsMatrixJson: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentsMatrixJson }} + environmentCount: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentCount }} + deploymentEnvironmentsJson: ${{ steps.DetermineDeploymentEnvironments.outputs.DeploymentEnvironmentsJson }} + generateALDocArtifact: ${{ steps.DetermineDeploymentEnvironments.outputs.GenerateALDocArtifact }} + deployALDocArtifact: ${{ steps.DetermineDeploymentEnvironments.outputs.DeployALDocArtifact }} + deliveryTargetsJson: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} - checkRunId: ${{ steps.CreateCheckRun.outputs.checkRunId }} projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} + skippedProjects: ${{ steps.determineProjectsToBuild.outputs.SkippedProjectsJson }} projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} + baselineWorkflowRunId: ${{ steps.determineProjectsToBuild.outputs.BaselineWorkflowRunId }} + baselineWorkflowSHA: ${{ steps.determineProjectsToBuild.outputs.BaselineWorkflowSHA }} workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} + powerPlatformSolutionFolder: ${{ steps.DeterminePowerPlatformSolutionFolder.outputs.powerPlatformSolutionFolder }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0091" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getEnvironments: '*' + get: type,powerPlatformSolutionFolder,useGitSubmodules + + - name: Read submodules token + id: ReadSubmodulesToken + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '-gitSubmodulesToken' + + - name: Checkout Submodules + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + lfs: true + submodules: ${{ env.useGitSubmodules }} + token: '${{ fromJson(steps.ReadSubmodulesToken.outputs.Secrets).gitSubmodulesToken }}' - name: Determine Workflow Depth id: DetermineWorkflowDepth run: | - Add-Content -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" - + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" + - name: Determine Projects To Build id: determineProjectsToBuild - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v7.1 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} + - name: Determine PowerPlatform Solution Folder + id: DeterminePowerPlatformSolutionFolder + if: env.type == 'PTE' + run: | + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "powerPlatformSolutionFolder=$($env:powerPlatformSolutionFolder)" + - 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 ',')" + uses: microsoft/AL-Go-Actions/DetermineDeliveryTargets@v7.1 + with: + shell: powershell + projectsJson: '${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' + checkContextSecrets: 'false' - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - settingsJson: ${{ env.Settings }} - secrets: ${{ steps.DetermineDeliveryTargetSecrets.outputs.Secrets }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: ${{ steps.DetermineDeliveryTargetSecrets.outputs.ContextSecrets }} - name: Determine Delivery Targets id: DetermineDeliveryTargets - run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $deliveryTargets = @('GitHubPackages','NuGet','Storage') - if ($env:type -eq "AppSource App") { - $continuousDelivery = $false - # For multi-project repositories, we will add deliveryTarget AppSource if any project has AppSourceContinuousDelivery set to true - ('${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' | ConvertFrom-Json) | where-Object { $_ } | ForEach-Object { - $projectSettings = Get-Content (Join-Path $_ '.AL-Go/settings.json') -encoding UTF8 -raw | ConvertFrom-Json - if ($projectSettings.PSObject.Properties.Name -eq 'AppSourceContinuousDelivery' -and $projectSettings.AppSourceContinuousDelivery) { - Write-Host "Project $_ is setup for Continuous Delivery" - $continuousDelivery = $true - } - } - if ($continuousDelivery) { - $deliveryTargets += @("AppSource") - } - } - $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 | 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" - Write-Host "DeliveryTargetsJson=$deliveryTargetsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "DeliveryTargetCount=$($deliveryTargets.Count)" - Write-Host "DeliveryTargetCount=$($deliveryTargets.Count)" - Add-Content -Path $env:GITHUB_ENV -Value "DeliveryTargets=$deliveryTargetsJson" + uses: microsoft/AL-Go-Actions/DetermineDeliveryTargets@v7.1 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + projectsJson: '${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' + checkContextSecrets: 'true' + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go-Actions/DetermineDeploymentEnvironments@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + shell: powershell + getEnvironments: '*' + type: 'CD' CheckForUpdates: - runs-on: [ windows-latest ] needs: [ Initialization ] + runs-on: [ windows-latest ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} get: templateUrl + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'ghTokenWorkflow' + - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@preview + uses: microsoft/AL-Go-Actions/CheckForUpdates@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} templateUrl: ${{ env.templateUrl }} + token: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).ghTokenWorkflow }} + downloadLatest: true Build: needs: [ Initialization ] @@ -181,192 +179,170 @@ jobs: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} + name: Build ${{ matrix.projectName }} (${{ matrix.buildMode }}) uses: ./.github/workflows/_BuildALGoProject.yaml secrets: inherit with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - runsOn: ${{ needs.Initialization.outputs.githubRunner }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: ${{ matrix.githubRunnerShell }} + runsOn: ${{ matrix.githubRunner }} project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} buildMode: ${{ matrix.buildMode }} + skippedProjectsJson: ${{ needs.Initialization.outputs.skippedProjects }} projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,storageContext,gitHubPackagesContext' - publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} - publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 }} + baselineWorkflowRunId: ${{ needs.Initialization.outputs.baselineWorkflowRunId }} + baselineWorkflowSHA: ${{ needs.Initialization.outputs.baselineWorkflowSHA }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' signArtifacts: true useArtifactCache: true + DeployALDoc: + needs: [ Initialization, Build ] + if: (!cancelled()) && needs.Build.result == 'Success' && needs.Initialization.outputs.generateALDocArtifact == 1 && github.ref_name == 'main' + runs-on: [ windows-latest ] + name: Deploy Reference Documentation + permissions: + contents: read + actions: read + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Download artifacts + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + path: '.artifacts' + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Setup Pages + if: needs.Initialization.outputs.deployALDocArtifact == 1 + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + + - name: Build Reference Documentation + uses: microsoft/AL-Go-Actions/BuildReferenceDocumentation@v7.1 + with: + shell: powershell + artifacts: '.artifacts' + + - name: Upload pages artifact + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + with: + path: ".aldoc/_site/" + + - name: Deploy to GitHub Pages + if: needs.Initialization.outputs.deployALDocArtifact == 1 + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 + Deploy: needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.environmentCount > 0 - strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} + if: (!cancelled()) && (needs.Build.result == 'success' || needs.Build.result == 'skipped') && needs.Initialization.outputs.environmentCount > 0 + strategy: ${{ fromJson(needs.Initialization.outputs.environmentsMatrixJson) }} runs-on: ${{ fromJson(matrix.os) }} name: Deploy to ${{ matrix.environment }} + defaults: + run: + shell: ${{ matrix.shell }} environment: name: ${{ matrix.environment }} + url: ${{ steps.Deploy.outputs.environmentUrl }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: path: '.artifacts' + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: ${{ matrix.shell }} + get: type,powerPlatformSolutionFolder + - name: EnvName id: envName run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 $envName = '${{ matrix.environment }}'.split(' ')[0] - Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: - shell: powershell + shell: ${{ matrix.shell }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext' - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview + - name: Deploy to Business Central + id: Deploy + uses: microsoft/AL-Go-Actions/Deploy@v7.1 env: - secrets: ${{ toJson(secrets) }} + Secrets: '${{ steps.ReadSecrets.outputs.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' + shell: ${{ matrix.shell }} + environmentName: ${{ matrix.environment }} + artifactsFolder: '.artifacts' + type: 'CD' + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} - - 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 as AuthContext" - } - } - } - if (!($authContext)) { - Write-Host "::Error::No AuthContext provided" - exit 1 - } - if (("$deployToSetting" -ne "") -and $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())) - - if (("$deployToSetting" -ne "") -and $deployToSetting.PSObject.Properties.name -eq "projects") { - $projects = $deployToSetting.projects - } - else { - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") - if (-not $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 '' -or $projects -eq '*') { - $projects = '*' - } - else { - $buildProjects = '${{ needs.Initialization.outputs.projects }}' | ConvertFrom-Json - $projects = ($projects.Split(',') | Where-Object { $buildProjects -contains $_ }) -join ',' - } - - 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=$([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 + - name: Deploy to Power Platform + if: env.type == 'PTE' && env.powerPlatformSolutionFolder != '' + uses: microsoft/AL-Go-Actions/DeployPowerPlatform@v7.1 env: - AuthContext: ${{ steps.authContext.outputs.authContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell - type: 'CD' - projects: ${{ steps.authContext.outputs.projects }} - environmentName: ${{ steps.authContext.outputs.environmentName }} - artifacts: '.artifacts' + environmentName: ${{ matrix.environment }} + artifactsFolder: '.artifacts' + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} Deliver: needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.deliveryTargetCount > 0 + if: (!cancelled()) && (needs.Build.result == 'success' || needs.Build.result == 'skipped') && needs.Initialization.outputs.deliveryTargetsJson != '[]' strategy: matrix: - deliveryTarget: ${{ fromJson(needs.Initialization.outputs.deliveryTargets) }} + deliveryTarget: ${{ fromJson(needs.Initialization.outputs.deliveryTargetsJson) }} fail-fast: false runs-on: [ windows-latest ] name: Deliver to ${{ matrix.deliveryTarget }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: path: '.artifacts' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - settingsJson: ${{ env.Settings }} - secrets: '${{ matrix.deliveryTarget }}Context' - - - name: DeliveryContext - 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" - Write-Host "deliveryContext=$deliveryContext" + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ matrix.deliveryTarget }}Context' - name: Deliver - uses: microsoft/AL-Go-Actions/Deliver@preview + uses: microsoft/AL-Go-Actions/Deliver@v7.1 env: - deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell type: 'CD' @@ -375,17 +351,19 @@ jobs: artifacts: '.artifacts' PostProcess: + needs: [ Initialization, Build, Deploy, Deliver, DeployALDoc ] if: (!cancelled()) runs-on: [ windows-latest ] - needs: [ Initialization, Build, Deploy, Deliver ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0091" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/CreateApp.yaml b/.github/workflows/CreateApp.yaml index 7b91659..d60798d 100644 --- a/.github/workflows/CreateApp.yaml +++ b/.github/workflows/CreateApp.yaml @@ -11,7 +11,7 @@ on: default: '.' name: description: Name - required: true + required: true publisher: description: Publisher required: true @@ -19,16 +19,22 @@ on: description: ID range (from..to) required: true sampleCode: - description: Include Sample code (Y/N) - required: false - default: 'Y' + description: Include Sample code? + type: boolean + default: true directCommit: - description: Direct COMMIT (Y/N) - required: false - default: "N" + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: + actions: read contents: write + id-token: write pull-requests: write defaults: @@ -41,30 +47,43 @@ env: jobs: CreateApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0092" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} get: type + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Creating a new app - uses: microsoft/AL-Go-Actions/CreateApp@preview + uses: microsoft/AL-Go-Actions/CreateApp@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} project: ${{ github.event.inputs.project }} type: ${{ env.type }} name: ${{ github.event.inputs.name }} @@ -75,8 +94,10 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0092" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml index 902dba1..fb998f2 100644 --- a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml +++ b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml @@ -1,24 +1,34 @@ name: ' Create Online Dev. Environment' -run-name: "Create Online Dev. Environment for [${{ github.ref_name }}]" +run-name: "Create Online Dev. Environment for [${{ github.ref_name }} / ${{ github.event.inputs.project }}]" on: workflow_dispatch: inputs: + project: + description: Project name if the repository is setup for multiple projects + required: false + default: '.' environmentName: description: Name of the online environment required: true reUseExistingEnvironment: - description: Reuse environment if it exists - required: false - default: 'N' + description: Reuse environment if it exists? + type: boolean + default: false directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: + actions: read contents: write + id-token: write pull-requests: write defaults: @@ -30,108 +40,119 @@ env: ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: - Initialize: + Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: deviceCode: ${{ steps.authenticate.outputs.deviceCode }} + githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0093" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'adminCenterApiCredentials' + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'adminCenterApiCredentials' - name: Check AdminCenterApiCredentials / Initiate Device Login (open to see code) id: authenticate 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 in secret $($ENV:adminCenterApiCredentialsSecretName)!" - Set-Content -Path $ENV:GITHUB_STEP_SUMMARY -value "Admin Center Api Credentials was provided in a secret called $($ENV:adminCenterApiCredentialsSecretName). Using this information for authentication." + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $settings = $env:Settings | ConvertFrom-Json + if ('${{ fromJson(steps.ReadSecrets.outputs.Secrets).adminCenterApiCredentials }}') { + Write-Host "AdminCenterApiCredentials provided in secret $($settings.adminCenterApiCredentialsSecretName)!" + Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "Admin Center Api Credentials was provided in a secret called $($settings.adminCenterApiCredentialsSecretName). Using this information for authentication." } else { Write-Host "AdminCenterApiCredentials not provided, initiating Device Code flow" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" $webClient = New-Object System.Net.WebClient - $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/AL-Go-Helper.ps1', $ALGoHelperPath) . $ALGoHelperPath - $BcContainerHelperPath = DownloadAndImportBcContainerHelper -baseFolder $ENV:GITHUB_WORKSPACE + DownloadAndImportBcContainerHelper $authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0)) - CleanupAfterBcContainerHelper -bcContainerHelperPath $bcContainerHelperPath - Set-Content -Path $ENV:GITHUB_STEP_SUMMARY -value "AL-Go needs access to the Business Central Admin Center Api and could not locate a secret called $($ENV:adminCenterApiCredentialsSecretName) (https://aka.ms/ALGoSettings#AdminCenterApiCredentialsSecretName)`n`n$($authContext.message)" - Add-Content -Path $env:GITHUB_OUTPUT -Value "deviceCode=$($authContext.deviceCode)" + Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "AL-Go needs access to the Business Central Admin Center Api and could not locate a secret called $($settings.adminCenterApiCredentialsSecretName) (https://aka.ms/ALGoSettings#AdminCenterApiCredentialsSecretName)`n`n$($authContext.message)" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "deviceCode=$($authContext.deviceCode)" } CreateDevelopmentEnvironment: - runs-on: [ windows-latest ] + needs: [ Initialization ] + runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} name: Create Development Environment - needs: [ Initialize ] env: - deviceCode: ${{ needs.Initialize.outputs.deviceCode }} + deviceCode: ${{ needs.Initialization.outputs.deviceCode }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'adminCenterApiCredentials' + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'adminCenterApiCredentials,TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Set AdminCenterApiCredentials + id: SetAdminCenterApiCredentials run: | if ($env:deviceCode) { $adminCenterApiCredentials = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("{""deviceCode"":""$($env:deviceCode)""}")) - Add-Content -path $env:GITHUB_ENV -value "adminCenterApiCredentials=$adminCenterApiCredentials" } + else { + $adminCenterApiCredentials = '${{ fromJson(steps.ReadSecrets.outputs.Secrets).adminCenterApiCredentials }}' + } + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -value "adminCenterApiCredentials=$adminCenterApiCredentials" - name: Create Development Environment - uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@preview + uses: microsoft/AL-Go-Actions/CreateDevelopmentEnvironment@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} environmentName: ${{ github.event.inputs.environmentName }} + project: ${{ github.event.inputs.project }} reUseExistingEnvironment: ${{ github.event.inputs.reUseExistingEnvironment }} directCommit: ${{ github.event.inputs.directCommit }} - adminCenterApiCredentials: ${{ env.adminCenterApiCredentials }} + adminCenterApiCredentials: ${{ steps.SetAdminCenterApiCredentials.outputs.adminCenterApiCredentials }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0093" - telemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/CreatePerformanceTestApp.yaml b/.github/workflows/CreatePerformanceTestApp.yaml index a7b127d..fe38b8d 100644 --- a/.github/workflows/CreatePerformanceTestApp.yaml +++ b/.github/workflows/CreatePerformanceTestApp.yaml @@ -12,29 +12,35 @@ on: name: description: Name required: true - default: '.PerformanceTest' + default: '.PerformanceTest' publisher: description: Publisher required: true idrange: description: ID range required: true - default: '50000..99999' + default: '50000..99999' sampleCode: - description: Include Sample code (Y/N) - required: false - default: 'Y' + description: Include Sample code? + type: boolean + default: true sampleSuite: - description: Include Sample BCPT Suite (Y/N) - required: false - default: 'Y' + description: Include Sample BCPT Suite? + type: boolean + default: true directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: + actions: read contents: write + id-token: write pull-requests: write defaults: @@ -47,23 +53,42 @@ env: jobs: CreatePerformanceTestApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 + with: + shell: powershell + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - eventId: "DO0102" + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@preview + uses: microsoft/AL-Go-Actions/CreateApp@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} project: ${{ github.event.inputs.project }} type: 'Performance Test App' name: ${{ github.event.inputs.name }} @@ -75,8 +100,10 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0102" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/CreateRelease.yaml b/.github/workflows/CreateRelease.yaml index eb14024..1cd3bf1 100644 --- a/.github/workflows/CreateRelease.yaml +++ b/.github/workflows/CreateRelease.yaml @@ -1,10 +1,14 @@ name: ' Create release' +run-name: "Create release - Version ${{ inputs.tag }}" + +concurrency: + group: ${{ github.workflow }} on: workflow_dispatch: inputs: - appVersion: - description: App version to promote to release (default is latest) + buildVersion: + description: Build version to promote to release (default is latest) required: false default: 'latest' name: @@ -15,33 +19,44 @@ on: description: Tag of this release (needs to be semantic version string https://semver.org, ex. 1.0.0) required: true default: '' - prerelease: - description: Prerelease (Y/N) - required: false - default: 'N' - draft: - description: Draft (Y/N) - required: false - default: 'N' + releaseType: + description: Release, prerelease or draft? + type: choice + options: + - Release + - Prerelease + - Draft + default: Release createReleaseBranch: - description: Create Release Branch (Y/N) - required: false - default: 'N' + 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. + description: New Version Number in main branch. Use Major.Minor (optionally add .Build for versioningstrategy 3) for absolute change, or +1, +0.1 (or +0.0.1 for versioningstrategy 3) incremental change. required: false default: '' + skipUpdatingDependencies: + description: Skip updating dependency version numbers in all apps. + type: boolean + default: false directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: + actions: read contents: write + id-token: write pull-requests: write - actions: read - -concurrency: release defaults: run: @@ -53,63 +68,84 @@ env: jobs: CreateRelease: + needs: [ ] runs-on: [ windows-latest ] outputs: - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} 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 }} + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0094" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + get: templateUrl,repoName,type,powerPlatformSolutionFolder + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - get: templateUrl,repoName + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush,ghTokenWorkflow' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Determine Projects id: determineProjects - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v7.1 with: shell: powershell - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@preview + uses: microsoft/AL-Go-Actions/CheckForUpdates@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} templateUrl: ${{ env.templateUrl }} + token: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).ghTokenWorkflow }} + downloadLatest: true - name: Analyze Artifacts id: analyzeartifacts + env: + _buildVersion: ${{ github.event.inputs.buildVersion }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 $projects = '${{ steps.determineProjects.outputs.ProjectsJson }}' | ConvertFrom-Json Write-Host "projects:" $projects | ForEach-Object { Write-Host "- $_" } + if ($env:type -eq "PTE" -and $env:powerPlatformSolutionFolder -ne "") { + Write-Host "PowerPlatformSolution:" + Write-Host "- $($env:powerPlatformSolutionFolder)" + $projects += @($env:powerPlatformSolutionFolder) + } $include = @() $sha = '' $allArtifacts = @() $page = 1 - $headers = @{ + $headers = @{ "Authorization" = "token ${{ github.token }}" - "Accept" = "application/json" + "X-GitHub-Api-Version" = "2022-11-28" + "Accept" = "application/vnd.github+json; charset=utf-8" } 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 + $repoArtifacts = Invoke-RestMethod -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts?per_page=100&page=$page" $allArtifacts += $repoArtifacts.Artifacts | Where-Object { !$_.expired } $page++ } @@ -126,17 +162,18 @@ jobs: } $refname = "$ENV:GITHUB_REF_NAME".Replace('/','_') Write-Host "Analyzing artifacts for project $project" - $appVersion = '${{ github.event.inputs.appVersion }}' - if ($appVersion -eq "latest") { + $buildVersion = "$env:_buildVersion" + if ($buildVersion -eq "latest") { Write-Host "Grab latest" - $artifact = $allArtifacts | Where-Object { $_.name -like "$project-$refname-Apps-*" } | Select-Object -First 1 + $artifact = $allArtifacts | Where-Object { $_.name -like "$project-$refname-Apps-*.*.*.*" -or $_.name -like "$project-$refname-PowerPlatformSolution-*.*.*.*" } | 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 + Write-Host "Search for $project-$refname-Apps-$buildVersion or $project-$refname-PowerPlatformSolution-$buildVersion" + $artifact = $allArtifacts | Where-Object { $_.name -eq "$project-$refname-Apps-$buildVersion"-or $_.name -eq "$project-$refname-PowerPlatformSolution-$buildVersion" } | Select-Object -First 1 } if ($artifact) { - $artifactsVersion = $artifact.name.SubString($artifact.name.LastIndexOf('-Apps-')+6) + $startIndex = $artifact.name.LastIndexOf('-') + 1 + $artifactsVersion = $artifact.name.SubString($startIndex) } else { Write-Host "::Error::No artifacts found for this project" @@ -152,39 +189,40 @@ jobs: $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 { + Write-host "Looking for $project-$refname-Apps-$artifactsVersion or $project-$refname-TestApps-$artifactsVersion or $project-$refname-Dependencies-$artifactsVersion or $project-$refname-PowerPlatformSolution-$artifactsVersion" + $allArtifacts | Where-Object { ($_.name -like "$project-$refname-Apps-$artifactsVersion" -or $_.name -like "$project-$refname-TestApps-$artifactsVersion" -or $_.name -like "$project-$refname-Dependencies-$artifactsVersion" -or $_.name -like "$project-$refname-PowerPlatformSolution-$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 } ) } if ($include.Count -eq 0) { - Write-Host "::Error::No artifacts found" + Write-Host "::Error::No artifacts found for version $artifactsVersion" exit 1 } } $artifacts = @{ "include" = $include } $artifactsJson = $artifacts | ConvertTo-Json -compress - Add-Content -Path $env:GITHUB_OUTPUT -Value "artifacts=$artifactsJson" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "artifacts=$artifactsJson" Write-Host "artifacts=$artifactsJson" - Add-Content -Path $env:GITHUB_OUTPUT -Value "commitish=$sha" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "commitish=$sha" Write-Host "commitish=$sha" - name: Prepare release notes id: createreleasenotes - uses: microsoft/AL-Go-Actions/CreateReleaseNotes@preview + uses: microsoft/AL-Go-Actions/CreateReleaseNotes@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + buildVersion: ${{ github.event.inputs.buildVersion }} tag_name: ${{ github.event.inputs.tag }} target_commitish: ${{ steps.analyzeartifacts.outputs.commitish }} - name: Create release - uses: actions/github-script@v6 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 id: createrelease env: bodyMD: ${{ steps.createreleasenotes.outputs.releaseNotes }} with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ steps.ReadSecrets.outputs.TokenForPush }} script: | var bodyMD = process.env.bodyMD const createReleaseResponse = await github.rest.repos.createRelease({ @@ -193,8 +231,8 @@ jobs: tag_name: '${{ github.event.inputs.tag }}', name: '${{ github.event.inputs.name }}', body: bodyMD.replaceAll('\\n','\n').replaceAll('%0A','\n').replaceAll('%0D','\n').replaceAll('%25','%'), - draft: ${{ github.event.inputs.draft=='Y' }}, - prerelease: ${{ github.event.inputs.prerelease=='Y' }}, + draft: ${{ github.event.inputs.releaseType=='Draft' }}, + prerelease: ${{ github.event.inputs.releaseType=='Prerelease' }}, make_latest: 'legacy', target_commitish: '${{ steps.analyzeartifacts.outputs.commitish }}' }); @@ -204,52 +242,50 @@ jobs: core.setOutput('releaseId', releaseId); UploadArtifacts: - runs-on: [ windows-latest ] needs: [ CreateRelease ] + runs-on: [ windows-latest ] strategy: matrix: ${{ fromJson(needs.CreateRelease.outputs.artifacts) }} fail-fast: true steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'nuGetContext,storageContext' + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'nuGetContext,storageContext,TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Download artifact run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 Write-Host "Downloading artifact ${{ matrix.name}}" - $headers = @{ - "Authorization" = "token ${{ github.token }}" - "Accept" = "application/vnd.github.v3+json" + $headers = @{ + "Authorization" = "token ${{ github.token }}" + "X-GitHub-Api-Version" = "2022-11-28" + "Accept" = "application/vnd.github+json" } Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri '${{ matrix.url }}' -OutFile '${{ matrix.name }}.zip' - name: Upload release artifacts - uses: actions/github-script@v6 + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 env: releaseId: ${{ needs.createrelease.outputs.releaseId }} with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ steps.ReadSecrets.outputs.TokenForPush }} script: | const releaseId = process.env.releaseId const assetPath = '${{ matrix.name }}.zip' - const assetName = '${{ matrix.name }}.zip' + const assetName = encodeURIComponent('${{ matrix.name }}.zip'.replaceAll(' ','.')).replaceAll('%','') const fs = require('fs'); const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({ owner: context.repo.owner, @@ -259,101 +295,100 @@ jobs: data: fs.readFileSync(assetPath) }); - - name: nuGetContext - id: 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'))) - } - Add-Content -Path $env:GITHUB_OUTPUT -Value "nuGetContext=$nuGetContext" - - name: Deliver to NuGet - uses: microsoft/AL-Go-Actions/Deliver@preview - if: ${{ steps.nuGetContext.outputs.nuGetContext }} + uses: microsoft/AL-Go-Actions/Deliver@v7.1 + if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).nuGetContext != '' }} env: - deliveryContext: ${{ steps.nuGetContext.outputs.nuGetContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'NuGet' - artifacts: ${{ github.event.inputs.appVersion }} + artifacts: ${{ github.event.inputs.buildVersion }} atypes: 'Apps,TestApps' - - name: storageContext - id: 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'))) - } - Add-Content -Path $env:GITHUB_OUTPUT -Value "storageContext=$storageContext" - - name: Deliver to Storage - uses: microsoft/AL-Go-Actions/Deliver@preview - if: ${{ steps.storageContext.outputs.storageContext }} + uses: microsoft/AL-Go-Actions/Deliver@v7.1 + if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).storageContext != '' }} env: - deliveryContext: ${{ steps.storageContext.outputs.storageContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell type: 'Release' projects: ${{ matrix.project }} deliveryTarget: 'Storage' - artifacts: ${{ github.event.inputs.appVersion }} + artifacts: ${{ github.event.inputs.buildVersion }} atypes: 'Apps,TestApps,Dependencies' CreateReleaseBranch: - if: ${{ github.event.inputs.createReleaseBranch=='Y' }} - runs-on: [ windows-latest ] needs: [ CreateRelease, UploadArtifacts ] + if: ${{ github.event.inputs.createReleaseBranch=='true' }} + runs-on: [ windows-latest ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: ref: '${{ needs.createRelease.outputs.commitish }}' - name: Create Release Branch + env: + releaseBranchPrefix: ${{ github.event.inputs.releaseBranchPrefix }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - git checkout -b ${{ needs.CreateRelease.outputs.releaseBranch }} + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $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 ] if: ${{ github.event.inputs.updateVersionNumber!='' }} runs-on: [ windows-latest ] - needs: [ CreateRelease, UploadArtifacts ] steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Update Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@preview + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} versionNumber: ${{ github.event.inputs.updateVersionNumber }} + skipUpdatingDependencies: ${{ github.event.inputs.skipUpdatingDependencies }} directCommit: ${{ github.event.inputs.directCommit }} PostProcess: + needs: [ CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] if: always() runs-on: [ windows-latest ] - needs: [ CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0094" telemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/CreateTestApp.yaml b/.github/workflows/CreateTestApp.yaml index a78670a..699bdaa 100644 --- a/.github/workflows/CreateTestApp.yaml +++ b/.github/workflows/CreateTestApp.yaml @@ -12,25 +12,31 @@ on: name: description: Name required: true - default: '.Test' + default: '.Test' publisher: description: Publisher required: true idrange: description: ID range required: true - default: '50000..99999' + default: '50000..99999' sampleCode: - description: Include Sample code (Y/N) - required: false - default: 'Y' + description: Include Sample code? + type: boolean + default: true directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: + actions: read contents: write + id-token: write pull-requests: write defaults: @@ -43,23 +49,42 @@ env: jobs: CreateTestApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 + with: + shell: powershell + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - eventId: "DO0095" + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@preview + uses: microsoft/AL-Go-Actions/CreateApp@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} project: ${{ github.event.inputs.project }} type: 'Test App' name: ${{ github.event.inputs.name }} @@ -70,8 +95,10 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0095" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/Current.yaml b/.github/workflows/Current.yaml index 6222a3f..6e33d54 100644 --- a/.github/workflows/Current.yaml +++ b/.github/workflows/Current.yaml @@ -4,7 +4,9 @@ on: workflow_dispatch: permissions: + actions: read contents: read + id-token: write defaults: run: @@ -17,44 +19,65 @@ env: jobs: Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} + artifactsRetentionDays: ${{ steps.DetermineWorkflowDepth.outputs.ArtifactsRetentionDays }} + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0101" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + get: useGitSubmodules,shortLivedArtifactsRetentionDays + + - name: Read submodules token + id: ReadSubmodulesToken + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '-gitSubmodulesToken' + + - name: Checkout Submodules + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + lfs: true + submodules: ${{ env.useGitSubmodules }} + token: '${{ fromJson(steps.ReadSubmodulesToken.outputs.Secrets).gitSubmodulesToken }}' - name: Determine Workflow Depth id: DetermineWorkflowDepth run: | - Add-Content -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" - + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "ArtifactsRetentionDays=$($env:shortLivedArtifactsRetentionDays)" + - name: Determine Projects To Build id: determineProjectsToBuild - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v7.1 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -66,32 +89,34 @@ jobs: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} + name: Build ${{ matrix.projectName }} (${{ matrix.buildMode }}) uses: ./.github/workflows/_BuildALGoProject.yaml secrets: inherit with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - runsOn: ${{ needs.Initialization.outputs.githubRunner }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: ${{ matrix.githubRunnerShell }} + runsOn: ${{ matrix.githubRunner }} project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} buildMode: ${{ matrix.buildMode }} projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + artifactsRetentionDays: ${{ fromJson(needs.Initialization.outputs.artifactsRetentionDays) }} artifactsNameSuffix: 'Current' PostProcess: + needs: [ Initialization, Build ] if: always() runs-on: [ windows-latest ] - needs: [ Initialization, Build ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0101" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/DeployReferenceDocumentation.yaml b/.github/workflows/DeployReferenceDocumentation.yaml new file mode 100644 index 0000000..3dbd138 --- /dev/null +++ b/.github/workflows/DeployReferenceDocumentation.yaml @@ -0,0 +1,80 @@ +name: ' Deploy Reference Documentation' + +on: + workflow_dispatch: + +permissions: + actions: read + contents: read + id-token: write + pages: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + DeployALDoc: + runs-on: [ windows-latest ] + name: Deploy Reference Documentation + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 + with: + shell: powershell + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go-Actions/DetermineDeploymentEnvironments@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + shell: powershell + getEnvironments: 'github-pages' + type: 'Publish' + + - name: Setup Pages + if: steps.DetermineDeploymentEnvironments.outputs.deployALDocArtifact == 1 + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0 + + - name: Build Reference Documentation + uses: microsoft/AL-Go-Actions/BuildReferenceDocumentation@v7.1 + with: + shell: powershell + artifacts: 'latest' + + - name: Upload pages artifact + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + with: + path: ".aldoc/_site/" + + - name: Deploy to GitHub Pages + if: steps.DetermineDeploymentEnvironments.outputs.deployALDocArtifact == 1 + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + shell: powershell + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/IncrementVersionNumber.yaml b/.github/workflows/IncrementVersionNumber.yaml index d633050..21997f3 100644 --- a/.github/workflows/IncrementVersionNumber.yaml +++ b/.github/workflows/IncrementVersionNumber.yaml @@ -5,21 +5,26 @@ run-name: "Increment Version Number in [${{ github.ref_name }}]" on: workflow_dispatch: inputs: - project: - description: Project name if the repository is setup for multiple projects (* for all projects) + projects: + description: Comma-separated list of project name patterns if the repository is setup for multiple projects (default is * for all projects) required: false default: '*' versionNumber: - description: Updated Version Number. Use Major.Minor for absolute change, use +Major.Minor for incremental change. - required: true - directCommit: - description: Direct COMMIT (Y/N) + description: New Version Number in main branch. Use Major.Minor (optionally add .Build for versioningstrategy 3) for absolute change, or +1, +0.1 (or +0.0.1 for versioningstrategy 3) incremental change. required: false - default: 'N' - -permissions: - contents: write - pull-requests: write + default: '' + skipUpdatingDependencies: + description: Skip updating dependency version numbers in all apps. + type: boolean + default: false + directCommit: + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false defaults: run: @@ -31,31 +36,58 @@ env: jobs: IncrementVersionNumber: + needs: [ ] runs-on: [ windows-latest ] + permissions: + actions: read + contents: write + id-token: write + pull-requests: write steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0096" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' - name: Increment Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@preview + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - project: ${{ github.event.inputs.project }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + projects: ${{ github.event.inputs.projects }} versionNumber: ${{ github.event.inputs.versionNumber }} + skipUpdatingDependencies: ${{ github.event.inputs.skipUpdatingDependencies }} directCommit: ${{ github.event.inputs.directCommit }} - + - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0096" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/NextMajor.yaml b/.github/workflows/NextMajor.yaml index 6fa776e..0078c08 100644 --- a/.github/workflows/NextMajor.yaml +++ b/.github/workflows/NextMajor.yaml @@ -4,7 +4,9 @@ on: workflow_dispatch: permissions: + actions: read contents: read + id-token: write defaults: run: @@ -17,44 +19,65 @@ env: jobs: Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} + artifactsRetentionDays: ${{ steps.DetermineWorkflowDepth.outputs.ArtifactsRetentionDays }} + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0099" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + get: useGitSubmodules,shortLivedArtifactsRetentionDays + + - name: Read submodules token + id: ReadSubmodulesToken + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '-gitSubmodulesToken' + + - name: Checkout Submodules + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + lfs: true + submodules: ${{ env.useGitSubmodules }} + token: '${{ fromJson(steps.ReadSubmodulesToken.outputs.Secrets).gitSubmodulesToken }}' - name: Determine Workflow Depth id: DetermineWorkflowDepth run: | - Add-Content -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" - + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "ArtifactsRetentionDays=$($env:shortLivedArtifactsRetentionDays)" + - name: Determine Projects To Build id: determineProjectsToBuild - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v7.1 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -66,32 +89,34 @@ jobs: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} + name: Build ${{ matrix.projectName }} (${{ matrix.buildMode }}) uses: ./.github/workflows/_BuildALGoProject.yaml secrets: inherit with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - runsOn: ${{ needs.Initialization.outputs.githubRunner }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: ${{ matrix.githubRunnerShell }} + runsOn: ${{ matrix.githubRunner }} project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} buildMode: ${{ matrix.buildMode }} projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + artifactsRetentionDays: ${{ fromJson(needs.Initialization.outputs.artifactsRetentionDays) }} artifactsNameSuffix: 'NextMajor' PostProcess: + needs: [ Initialization, Build ] if: always() runs-on: [ windows-latest ] - needs: [ Initialization, Build ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0099" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/NextMinor.yaml b/.github/workflows/NextMinor.yaml index 63d99a1..d52ddea 100644 --- a/.github/workflows/NextMinor.yaml +++ b/.github/workflows/NextMinor.yaml @@ -4,7 +4,9 @@ on: workflow_dispatch: permissions: + actions: read contents: read + id-token: write defaults: run: @@ -17,44 +19,65 @@ env: jobs: Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} + artifactsRetentionDays: ${{ steps.DetermineWorkflowDepth.outputs.ArtifactsRetentionDays }} + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0100" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + get: useGitSubmodules,shortLivedArtifactsRetentionDays + + - name: Read submodules token + id: ReadSubmodulesToken + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '-gitSubmodulesToken' + + - name: Checkout Submodules + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + lfs: true + submodules: ${{ env.useGitSubmodules }} + token: '${{ fromJson(steps.ReadSubmodulesToken.outputs.Secrets).gitSubmodulesToken }}' - name: Determine Workflow Depth id: DetermineWorkflowDepth run: | - Add-Content -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" - + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "ArtifactsRetentionDays=$($env:shortLivedArtifactsRetentionDays)" + - name: Determine Projects To Build id: determineProjectsToBuild - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v7.1 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -66,32 +89,34 @@ jobs: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} + name: Build ${{ matrix.projectName }} (${{ matrix.buildMode }}) uses: ./.github/workflows/_BuildALGoProject.yaml secrets: inherit with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - runsOn: ${{ needs.Initialization.outputs.githubRunner }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: ${{ matrix.githubRunnerShell }} + runsOn: ${{ matrix.githubRunner }} project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} buildMode: ${{ matrix.buildMode }} projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + artifactsRetentionDays: ${{ fromJson(needs.Initialization.outputs.artifactsRetentionDays) }} artifactsNameSuffix: 'NextMinor' PostProcess: + needs: [ Initialization, Build ] if: always() runs-on: [ windows-latest ] - needs: [ Initialization, Build ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0100" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/PublishToAppSource.yaml b/.github/workflows/PublishToAppSource.yaml index 9d5fb57..348bb09 100644 --- a/.github/workflows/PublishToAppSource.yaml +++ b/.github/workflows/PublishToAppSource.yaml @@ -1,4 +1,5 @@ name: ' Publish To AppSource' +run-name: 'Publish To AppSource - Version ${{ inputs.appVersion }}, Projects ${{ inputs.projects }}' on: workflow_dispatch: @@ -12,13 +13,14 @@ on: required: false default: '*' GoLive: - description: Promote AppSource App to go live if it passes technical validation? (Y/N) - required: false - default: 'N' + description: Promote AppSource App to go live if it passes technical validation? + type: boolean + default: false permissions: - contents: read actions: read + contents: read + id-token: write defaults: run: @@ -30,19 +32,24 @@ env: jobs: Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0103" Deliver: needs: [ Initialization ] @@ -50,40 +57,27 @@ jobs: name: Deliver to AppSource steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - settingsJson: ${{ env.Settings }} - secrets: 'appSourceContext' - - - name: DeliveryContext - id: deliveryContext - run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $contextName = 'appSourceContext' - $deliveryContext = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String([System.Environment]::GetEnvironmentVariable($contextName))) - Add-Content -Path $env:GITHUB_OUTPUT -Value "deliveryContext=$deliveryContext" - Write-Host "deliveryContext=$deliveryContext" + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'appSourceContext' - name: Deliver - uses: microsoft/AL-Go-Actions/Deliver@preview + uses: microsoft/AL-Go-Actions/Deliver@v7.1 env: - deliveryContext: '${{ steps.deliveryContext.outputs.deliveryContext }}' + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} type: 'Release' projects: ${{ github.event.inputs.projects }} deliveryTarget: 'AppSource' @@ -91,17 +85,19 @@ jobs: goLive: ${{ github.event.inputs.goLive }} PostProcess: + needs: [ Initialization, Deliver ] if: always() runs-on: [ windows-latest ] - needs: [ Initialization, Deliver ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0103" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/PublishToEnvironment.yaml b/.github/workflows/PublishToEnvironment.yaml index b3712d1..840178d 100644 --- a/.github/workflows/PublishToEnvironment.yaml +++ b/.github/workflows/PublishToEnvironment.yaml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: appVersion: - description: App version to deploy to environment(s) (current, prerelease, draft, latest or version number) + description: App version to deploy to environment(s) (current, prerelease, draft, latest, version number or PR_) required: false default: 'current' environmentName: @@ -12,8 +12,9 @@ on: required: true permissions: - contents: read actions: read + contents: read + id-token: write defaults: run: @@ -25,221 +26,179 @@ env: jobs: Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - environments: ${{ steps.ReadSettings.outputs.EnvironmentsJson }} - environmentCount: ${{ steps.ReadSettings.outputs.EnvironmentCount }} - unknownEnvironment: ${{ steps.ReadSettings.outputs.UnknownEnvironment }} + environmentsMatrixJson: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentsMatrixJson }} + environmentCount: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentCount }} + deploymentEnvironmentsJson: ${{ steps.DetermineDeploymentEnvironments.outputs.DeploymentEnvironmentsJson }} deviceCode: ${{ steps.Authenticate.outputs.deviceCode }} + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0097" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go-Actions/DetermineDeploymentEnvironments@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} getEnvironments: ${{ github.event.inputs.environmentName }} - includeProduction: 'Y' + type: 'Publish' - name: EnvName id: envName - if: steps.ReadSettings.outputs.UnknownEnvironment == 1 + if: steps.DetermineDeploymentEnvironments.outputs.UnknownEnvironment == 1 run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $envName = '${{ fromJson(steps.ReadSettings.outputs.environmentsJson).matrix.include[0].environment }}'.split(' ')[0] - Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $envName = '${{ fromJson(steps.DetermineDeploymentEnvironments.outputs.environmentsMatrixJson).matrix.include[0].environment }}'.split(' ')[0] + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - if: steps.ReadSettings.outputs.UnknownEnvironment == 1 - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + if: steps.DetermineDeploymentEnvironments.outputs.UnknownEnvironment == 1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext' + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext' - name: Authenticate id: Authenticate - if: steps.ReadSettings.outputs.UnknownEnvironment == 1 + if: steps.DetermineDeploymentEnvironments.outputs.UnknownEnvironment == 1 run: | $envName = '${{ steps.envName.outputs.envName }}' $secretName = '' + $secrets = '${{ steps.ReadSecrets.outputs.Secrets }}' | ConvertFrom-Json $authContext = $null "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { if (!($authContext)) { - $authContext = [System.Environment]::GetEnvironmentVariable($_) - if ($authContext) { + if ($secrets."$_") { Write-Host "Using $_ secret as AuthContext" + $authContext = $secrets."$_" $secretName = $_ } - } + } } if ($authContext) { Write-Host "AuthContext provided in secret $secretName!" - Set-Content -Path $ENV:GITHUB_STEP_SUMMARY -value "AuthContext was provided in a secret called $secretName. Using this information for authentication." + Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "AuthContext was provided in a secret called $secretName. Using this information for authentication." } else { Write-Host "No AuthContext provided for $envName, initiating Device Code flow" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" $webClient = New-Object System.Net.WebClient - $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/preview/AL-Go-Helper.ps1', $ALGoHelperPath) + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v7.1/AL-Go-Helper.ps1', $ALGoHelperPath) . $ALGoHelperPath - $BcContainerHelperPath = DownloadAndImportBcContainerHelper -baseFolder $ENV:GITHUB_WORKSPACE + DownloadAndImportBcContainerHelper $authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0)) - CleanupAfterBcContainerHelper -bcContainerHelperPath $bcContainerHelperPath - Set-Content -Path $ENV:GITHUB_STEP_SUMMARY -value "AL-Go needs access to the Business Central Environment $('${{ steps.envName.outputs.envName }}'.Split(' ')[0]) and could not locate a secret called ${{ steps.envName.outputs.envName }}_AuthContext`n`n$($authContext.message)" - Add-Content -Path $env:GITHUB_OUTPUT -Value "deviceCode=$($authContext.deviceCode)" + Add-Content -Encoding UTF8 -path $ENV:GITHUB_STEP_SUMMARY -value "AL-Go needs access to the Business Central Environment $('${{ steps.envName.outputs.envName }}'.Split(' ')[0]) and could not locate a secret called ${{ steps.envName.outputs.envName }}_AuthContext`n`n$($authContext.message)" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "deviceCode=$($authContext.deviceCode)" } Deploy: needs: [ Initialization ] if: needs.Initialization.outputs.environmentCount > 0 - strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} + strategy: ${{ fromJson(needs.Initialization.outputs.environmentsMatrixJson) }} runs-on: ${{ fromJson(matrix.os) }} name: Deploy to ${{ matrix.environment }} + defaults: + run: + shell: ${{ matrix.shell }} environment: name: ${{ matrix.environment }} + url: ${{ steps.Deploy.outputs.environmentUrl }} env: deviceCode: ${{ needs.Initialization.outputs.deviceCode }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: EnvName id: envName run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 $envName = '${{ matrix.environment }}'.split(' ')[0] - Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: - shell: powershell + shell: ${{ matrix.shell }} + get: type,powerPlatformSolutionFolder - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 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' + shell: ${{ matrix.shell }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext' - - 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 - if ($env:deviceCode) { - $authContext = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("{""deviceCode"":""$($env:deviceCode)""}")) - } - "$($envName)-AuthContext", "$($envName)_AuthContext", "AuthContext" | ForEach-Object { - if (!($authContext)) { - $authContext = [System.Environment]::GetEnvironmentVariable($_) - if ($authContext) { - Write-Host "Using $_ secret as AuthContext" - } - } - } - if (!($authContext)) { - Write-Host "::Error::No AuthContext provided" - exit 1 - } - if (("$deployToSetting" -ne "") -and $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())) - if (("$deployToSetting" -ne "") -and $deployToSetting.PSObject.Properties.name -eq "projects") { - $projects = $deployToSetting.projects - } - else { - $projects = [System.Environment]::GetEnvironmentVariable("$($envName)-projects") - if (-not $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 '') { - $projects = '*' - } - elseif ($projects -ne '*') { - $buildProjects = '${{ needs.Initialization.outputs.projects }}' | ConvertFrom-Json - $projects = ($projects.Split(',') | Where-Object { $buildProjects -contains $_ }) -join ',' - } - Add-Content -Path $env:GITHUB_OUTPUT -Value "authContext=$authContext" - Add-Content -Path $env:GITHUB_OUTPUT -Value "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 + - name: Get Artifacts for deployment + uses: microsoft/AL-Go-Actions/GetArtifactsForDeployment@v7.1 + with: + shell: ${{ matrix.shell }} + artifactsVersion: ${{ github.event.inputs.appVersion }} + artifactsFolder: '.artifacts' + + - name: Deploy to Business Central + id: Deploy + uses: microsoft/AL-Go-Actions/Deploy@v7.1 env: - AuthContext: ${{ steps.authContext.outputs.authContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: - shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: ${{ matrix.shell }} + environmentName: ${{ matrix.environment }} + artifactsFolder: '.artifacts' type: 'Publish' - projects: ${{ steps.authContext.outputs.projects }} - environmentName: ${{ steps.authContext.outputs.environmentName }} - artifacts: ${{ github.event.inputs.appVersion }} + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} + artifactsVersion: ${{ github.event.inputs.appVersion }} + + - name: Deploy to Power Platform + if: env.type == 'PTE' && env.powerPlatformSolutionFolder != '' + uses: microsoft/AL-Go-Actions/DeployPowerPlatform@v7.1 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: ${{ matrix.shell }} + environmentName: ${{ matrix.environment }} + artifactsFolder: '.artifacts' + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} PostProcess: + needs: [ Initialization, Deploy ] if: always() runs-on: [ windows-latest ] - needs: [ Initialization, Deploy ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0097" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/PullRequestHandler.yaml b/.github/workflows/PullRequestHandler.yaml index c9be6f4..e2c9378 100644 --- a/.github/workflows/PullRequestHandler.yaml +++ b/.github/workflows/PullRequestHandler.yaml @@ -2,8 +2,6 @@ name: 'Pull Request Build' on: pull_request_target: - paths-ignore: - - '**.md' branches: [ 'main' ] concurrency: @@ -15,8 +13,9 @@ defaults: shell: powershell permissions: - contents: read actions: read + contents: read + id-token: write pull-requests: read env: @@ -26,63 +25,58 @@ env: jobs: PregateCheck: - if: github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name - runs-on: [ windows-latest ] + if: (github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name) && (github.event_name != 'pull_request') + runs-on: windows-latest steps: - - uses: actions/checkout@v3 - with: - lfs: true - ref: refs/pull/${{ github.event.number }}/merge - - - uses: microsoft/AL-Go-Actions/VerifyPRChanges@preview - with: - baseSHA: ${{ github.event.pull_request.base.sha }} - headSHA: ${{ github.event.pull_request.head.sha }} - prbaseRepository: ${{ github.event.pull_request.base.repo.full_name }} + - uses: microsoft/AL-Go-Actions/VerifyPRChanges@v7.1 Initialization: needs: [ PregateCheck ] if: (!failure() && !cancelled()) runs-on: [ windows-latest ] outputs: - telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settings: ${{ steps.ReadSettings.outputs.SettingsJson }} - githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} - githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} projects: ${{ steps.determineProjectsToBuild.outputs.ProjectsJson }} projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} + baselineWorkflowRunId: ${{ steps.determineProjectsToBuild.outputs.BaselineWorkflowRunId }} + baselineWorkflowSHA: ${{ steps.determineProjectsToBuild.outputs.BaselineWorkflowSHA }} workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} + artifactsRetentionDays: ${{ steps.DetermineWorkflowDepth.outputs.ArtifactsRetentionDays }} + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 with: lfs: true - ref: refs/pull/${{ github.event.number }}/merge + ref: ${{ github.event_name == 'pull_request' && github.sha || format('refs/pull/{0}/merge', github.event.pull_request.number) }} - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0104" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getEnvironments: '*' - + get: shortLivedArtifactsRetentionDays + - name: Determine Workflow Depth id: DetermineWorkflowDepth run: | - Add-Content -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" - + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "WorkflowDepth=$($env:workflowDepth)" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "ArtifactsRetentionDays=$($env:shortLivedArtifactsRetentionDays)" + - name: Determine Projects To Build id: determineProjectsToBuild - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@preview + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v7.1 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -94,35 +88,45 @@ jobs: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} + name: Build ${{ matrix.projectName }} (${{ matrix.buildMode }}) uses: ./.github/workflows/_BuildALGoProject.yaml secrets: inherit with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - runsOn: ${{ needs.Initialization.outputs.githubRunner }} - checkoutRef: refs/pull/${{ github.event.number }}/merge - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + shell: ${{ matrix.githubRunnerShell }} + runsOn: ${{ matrix.githubRunner }} + checkoutRef: ${{ github.event_name == 'pull_request' && github.sha || format('refs/pull/{0}/merge', github.event.pull_request.number) }} project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} buildMode: ${{ matrix.buildMode }} projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - secrets: 'licenseFileUrl,insiderSasToken,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + baselineWorkflowRunId: ${{ needs.Initialization.outputs.baselineWorkflowRunId }} + baselineWorkflowSHA: ${{ needs.Initialization.outputs.baselineWorkflowSHA }} + secrets: 'licenseFileUrl,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + artifactsRetentionDays: ${{ fromJson(needs.Initialization.outputs.artifactsRetentionDays) }} + artifactsNameSuffix: 'PR${{ github.event.number }}' + useArtifactCache: true - PostProcess: - runs-on: [ windows-latest ] + StatusCheck: needs: [ Initialization, Build ] if: (!cancelled()) + runs-on: [ windows-latest ] + name: Pull Request Status Check steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Pull Request Status Check + id: PullRequestStatusCheck + uses: microsoft/AL-Go-Actions/PullRequestStatusCheck@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: - lfs: true - ref: refs/pull/${{ github.event.number }}/merge + shell: powershell - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + if: success() || failure() + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0104" telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/Troubleshooting.yaml b/.github/workflows/Troubleshooting.yaml new file mode 100644 index 0000000..8e13731 --- /dev/null +++ b/.github/workflows/Troubleshooting.yaml @@ -0,0 +1,37 @@ +name: 'Troubleshooting' + +on: + workflow_dispatch: + inputs: + displayNameOfSecrets: + description: Display the name (not the value) of secrets available to the repository + type: boolean + default: false + +permissions: + actions: read + contents: read + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Troubleshooting: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + lfs: true + + - name: Troubleshooting + uses: microsoft/AL-Go-Actions/Troubleshooting@v7.1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + displayNameOfSecrets: ${{ github.event.inputs.displayNameOfSecrets }} diff --git a/.github/workflows/UpdateGitHubGoSystemFiles.yaml b/.github/workflows/UpdateGitHubGoSystemFiles.yaml index 426df81..4db8362 100644 --- a/.github/workflows/UpdateGitHubGoSystemFiles.yaml +++ b/.github/workflows/UpdateGitHubGoSystemFiles.yaml @@ -7,13 +7,23 @@ on: description: Template Repository URL (current is https://github.com/microsoft/AL-Go-AppSource@preview) required: false default: '' + downloadLatest: + description: Download latest from template repository + type: boolean + default: true directCommit: - description: Direct COMMIT (Y/N) + description: Direct Commit? + type: boolean + default: false + includeBranches: + description: Specify a comma-separated list of branches to update. Wildcards are supported. The AL-Go settings will be read for every branch. Leave empty to update the current branch only. required: false - default: 'N' + default: '' permissions: + actions: read contents: read + id-token: write defaults: run: @@ -24,77 +34,122 @@ env: ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: + Initialize: + runs-on: windows-latest + name: Initialize + outputs: + UpdateBranches: ${{ steps.GetBranches.outputs.Result }} + TemplateUrl: ${{ steps.DetermineTemplateUrl.outputs.TemplateUrl }} + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: powershell + get: templateUrl + + - name: Get Workflow Multi-Run Branches + id: GetBranches + uses: microsoft/AL-Go-Actions/GetWorkflowMultiRunBranches@v7.1 + with: + shell: powershell + includeBranches: ${{ github.event.inputs.includeBranches }} + + - name: Determine Template URL + id: DetermineTemplateUrl + env: + TemplateUrlAsInput: '${{ github.event.inputs.templateUrl }}' + run: | + $templateUrl = $env:templateUrl # Available from ReadSettings step + if ($ENV:TemplateUrlAsInput) { + # Use the input value if it is provided + $templateUrl = $ENV:TemplateUrlAsInput + } + Write-Host "Using template URL: $templateUrl" + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "TemplateUrl=$templateUrl" + UpdateALGoSystemFiles: + name: "[${{ matrix.branch }}] Update AL-Go System Files" + needs: [ Initialize ] runs-on: [ windows-latest ] + strategy: + matrix: + branch: ${{ fromJson(needs.Initialize.outputs.UpdateBranches).branches }} + fail-fast: false + steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go-Actions/DumpWorkflowInfo@v7.1 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ matrix.branch }} - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@preview + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v7.1 with: shell: powershell - eventId: "DO0098" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - get: keyVaultName,ghTokenWorkflowSecretName,templateUrl + get: commitOptions - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'ghTokenWorkflow=${{ env.GHTOKENWORKFLOWSECRETNAME }}' + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'ghTokenWorkflow' - - name: Override templateUrl + - name: Calculate Commit Options env: - templateUrl: ${{ github.event.inputs.templateUrl }} + directCommit: '${{ github.event.inputs.directCommit }}' + downloadLatest: '${{ github.event.inputs.downloadLatest }}' 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" + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + if('${{ github.event_name }}' -eq 'workflow_dispatch') { + Write-Host "Using inputs from workflow_dispatch event" + $directCommit = $env:directCommit + $downloadLatest = $env:downloadLatest } - - - name: Calculate DirectCommit - env: - directCommit: ${{ github.event.inputs.directCommit }} - eventName: ${{ github.event_name }} - run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $directCommit = $ENV:directCommit - Write-Host $ENV:eventName - if ($ENV:eventName -eq 'schedule') { - Write-Host "Running Update AL-Go System Files on a schedule. Setting DirectCommit = Y" - $directCommit = 'Y' + else { + Write-Host "Using inputs from commitOptions setting" + $commitOptions = $env:commitOptions | ConvertFrom-Json # Available from ReadSettings step + $directCommit=$(-not $commitOptions.createPullRequest) + $downloadLatest=$true } - Add-Content -Path $env:GITHUB_ENV -Value "DirectCommit=$directCommit" + Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "directCommit=$directCommit" + Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "downloadLatest=$downloadLatest" - name: Update AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@preview + uses: microsoft/AL-Go-Actions/CheckForUpdates@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - token: ${{ env.ghTokenWorkflow }} - Update: Y - templateUrl: ${{ env.templateUrl }} + token: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).ghTokenWorkflow }} + downloadLatest: ${{ env.downloadLatest }} + update: 'Y' + templateUrl: ${{ needs.Initialize.outputs.TemplateUrl }} directCommit: ${{ env.directCommit }} + updateBranch: ${{ matrix.branch }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@preview + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v7.1 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0098" telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + currentJobContext: ${{ toJson(job) }} diff --git a/.github/workflows/_BuildALGoProject.yaml b/.github/workflows/_BuildALGoProject.yaml index f5ee08a..538baa5 100644 --- a/.github/workflows/_BuildALGoProject.yaml +++ b/.github/workflows/_BuildALGoProject.yaml @@ -1,6 +1,6 @@ -name: '_Build AL-GO project' +name: '_Build AL-Go project' -run-name: 'Build project ${{ inputs.project }}' +run-name: 'Build ${{ inputs.project }}' on: workflow_call: @@ -10,19 +10,28 @@ on: required: false default: powershell type: string - runsOn: - description: JSON-formatted string og the types of machine to run the build job on + runsOn: + description: JSON-formatted string of the types of machine to run the build job on required: true type: string checkoutRef: description: Ref to checkout required: false - default: ${{ github.ref }} + default: ${{ github.sha }} type: string project: description: Name of the built project required: true type: string + projectName: + description: Friendly name of the built project + required: true + type: string + skippedProjectsJson: + description: An array of AL-Go projects to skip in compressed JSON format + required: false + default: '[]' + type: string projectDependenciesJson: description: Dependencies of the built project in compressed Json format required: false @@ -32,21 +41,25 @@ on: description: Build mode used when building the artifacts required: true type: string + baselineWorkflowRunId: + description: ID of the baseline workflow run, from where to download the current project dependencies, in case they are not built in the current workflow run + required: false + default: '0' + type: string + baselineWorkflowSHA: + description: SHA of the baseline workflow run + required: false + default: '' + type: string secrets: description: A comma-separated string with the names of the secrets, required for the workflow. required: false default: '' type: string - publishThisBuildArtifacts: - description: Flag indicating whether this build artifacts should be published - required: false - default: false - type: boolean - publishArtifacts: - description: Flag indicating whether the artifacts should be published - required: false - default: false - type: boolean + artifactsRetentionDays: + description: Number of days to keep the artifacts + type: number + default: 0 artifactsNameSuffix: description: Suffix to add to the artifacts names required: false @@ -54,193 +67,240 @@ on: type: string signArtifacts: description: Flag indicating whether the apps should be signed - required: false - default: false type: boolean + default: false useArtifactCache: description: Flag determining whether to use the Artifacts Cache - required: false - default: false type: boolean - parentTelemetryScopeJson: - description: Specifies the telemetry scope for the telemetry signal - required: false - type: string + default: false + +permissions: + actions: read + contents: read + id-token: write + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + jobs: BuildALGoProject: + needs: [ ] runs-on: ${{ fromJson(inputs.runsOn) }} - name: ${{ inputs.project }} - ${{ inputs.buildMode }} + defaults: + run: + shell: ${{ inputs.shell }} + name: ${{ inputs.projectName }} (${{ inputs.buildMode }}) steps: - - name: Checkout - uses: actions/checkout@v3 - with: - ref: ${{ inputs.checkoutRef }} - lfs: true - - - name: Download thisbuild artifacts - if: inputs.publishThisBuildArtifacts - uses: actions/download-artifact@v3 - with: - path: '.dependencies' - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@preview - with: - shell: ${{ inputs.shell }} - parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} - project: ${{ inputs.project }} - - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@preview - env: - secrets: ${{ toJson(secrets) }} - with: - shell: ${{ inputs.shell }} - parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: ${{ inputs.secrets }} - - - name: Determine ArtifactUrl - uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@preview - id: determineArtifactUrl - with: - shell: ${{ inputs.shell }} - parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} - project: ${{ inputs.project }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - - - name: Cache Business Central Artifacts - if: env.useCompilerFolder == 'True' && inputs.useArtifactCache && steps.determineArtifactUrl.outputs.ArtifactCacheKey - uses: actions/cache@v3 - with: - path: .artifactcache - key: ${{ steps.determineArtifactUrl.outputs.ArtifactCacheKey }} - - - name: Run pipeline - id: RunPipeline - uses: microsoft/AL-Go-Actions/RunPipeline@preview - env: - BuildMode: ${{ inputs.buildMode }} - with: - shell: ${{ inputs.shell }} - parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} - project: ${{ inputs.project }} - projectDependenciesJson: ${{ inputs.projectDependenciesJson }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - buildMode: ${{ inputs.buildMode }} - - - name: Sign - if: inputs.signArtifacts && env.doNotSignApps == 'False' && env.keyVaultCodesignCertificateName != '' - id: sign - uses: microsoft/AL-Go-Actions/Sign@preview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - azureCredentialsJson: ${{ secrets.AZURE_CREDENTIALS }} - settingsJson: ${{ env.Settings }} - pathToFiles: '${{ inputs.project }}/.buildartifacts/Apps/*.app' - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - - - name: Calculate Artifact names - id: calculateArtifactsNames - uses: microsoft/AL-Go-Actions/CalculateArtifactNames@preview - if: success() || failure() - with: - shell: ${{ inputs.shell }} - settingsJson: ${{ env.Settings }} - project: ${{ inputs.project }} - buildMode: ${{ inputs.buildMode }} - branchName: ${{ github.ref_name }} - suffix: ${{ inputs.artifactsNameSuffix }} - - - name: Upload thisbuild artifacts - apps - if: inputs.publishThisBuildArtifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} - path: '${{ inputs.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: inputs.publishThisBuildArtifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} - path: '${{ inputs.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Publish artifacts - apps - uses: actions/upload-artifact@v3 - if: inputs.publishArtifacts - with: - name: ${{ env.AppsArtifactsName }} - path: '${{ inputs.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - - - name: Publish artifacts - dependencies - uses: actions/upload-artifact@v3 - if: inputs.publishArtifacts - with: - name: ${{ env.DependenciesArtifactsName }} - path: '${{ inputs.project }}/.buildartifacts/Dependencies/' - if-no-files-found: ignore - - - name: Publish artifacts - test apps - uses: actions/upload-artifact@v3 - if: inputs.publishArtifacts - with: - name: ${{ env.TestAppsArtifactsName }} - path: '${{ inputs.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - - - name: Publish artifacts - build output - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',inputs.project)) != '') - with: - name: ${{ env.BuildOutputArtifactsName }} - path: '${{ inputs.project }}/BuildOutput.txt' - if-no-files-found: ignore - - - name: Publish artifacts - container event log - uses: actions/upload-artifact@v3 - if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',inputs.project)) != '') - with: - name: ${{ env.ContainerEventLogArtifactsName }} - path: '${{ inputs.project }}/ContainerEventLog.evtx' - if-no-files-found: ignore - - - name: Publish artifacts - test results - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',inputs.project)) != '') - with: - name: ${{ env.TestResultsArtifactsName }} - path: '${{ inputs.project }}/TestResults.xml' - if-no-files-found: ignore - - - name: Publish artifacts - bcpt test results - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',inputs.project)) != '') - with: - name: ${{ env.BcptTestResultsArtifactsName }} - path: '${{ inputs.project }}/bcptTestResults.json' - if-no-files-found: ignore - - - name: Analyze Test Results - id: analyzeTestResults - if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@preview - with: - shell: ${{ inputs.shell }} - parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} - Project: ${{ inputs.project }} - - - name: Cleanup - if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@preview - with: - shell: ${{ inputs.shell }} - parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} - Project: ${{ inputs.project }} + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ inputs.checkoutRef }} + lfs: true + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v7.1 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,doNotRunTests,doNotRunBcptTests,doNotRunpageScriptingTests,artifact,generateDependencyArtifact,trustedSigning,useGitSubmodules + + - name: Determine whether to build project + id: DetermineBuildProject + uses: microsoft/AL-Go-Actions/DetermineBuildProject@v7.1 + with: + shell: ${{ inputs.shell }} + skippedProjectsJson: ${{ inputs.skippedProjectsJson }} + project: ${{ inputs.project }} + baselineWorkflowRunId: ${{ inputs.baselineWorkflowRunId }} + + - name: Read secrets + id: ReadSecrets + if: steps.DetermineBuildProject.outputs.BuildIt == 'True' && github.event_name != 'pull_request' + uses: microsoft/AL-Go-Actions/ReadSecrets@v7.1 + with: + shell: ${{ inputs.shell }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ inputs.secrets }},appDependencySecrets,AZURE_CREDENTIALS,-gitSubmodulesToken' + + - name: Checkout Submodules + if: env.useGitSubmodules != 'false' && env.useGitSubmodules != '' + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: ${{ inputs.checkoutRef }} + lfs: true + submodules: ${{ env.useGitSubmodules }} + token: '${{ fromJson(steps.ReadSecrets.outputs.Secrets).gitSubmodulesToken }}' + + - name: Determine ArtifactUrl + id: determineArtifactUrl + if: steps.DetermineBuildProject.outputs.BuildIt == 'True' + uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@v7.1 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + + - name: Cache Business Central Artifacts + if: steps.DetermineBuildProject.outputs.BuildIt == 'True' && env.useCompilerFolder == 'True' && inputs.useArtifactCache && env.artifactCacheKey + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: ${{ runner.temp }}/.artifactcache + key: ${{ env.artifactCacheKey }} + + - name: Download Project Dependencies + id: DownloadProjectDependencies + if: steps.DetermineBuildProject.outputs.BuildIt == 'True' + uses: microsoft/AL-Go-Actions/DownloadProjectDependencies@v7.1 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + projectDependenciesJson: ${{ inputs.projectDependenciesJson }} + baselineWorkflowRunId: ${{ inputs.baselineWorkflowRunId }} + + - name: Build + uses: microsoft/AL-Go-Actions/RunPipeline@v7.1 + if: steps.DetermineBuildProject.outputs.BuildIt == 'True' + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + BuildMode: ${{ inputs.buildMode }} + with: + shell: ${{ inputs.shell }} + artifact: ${{ env.artifact }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + installAppsJson: ${{ steps.DownloadProjectDependencies.outputs.DownloadedApps }} + installTestAppsJson: ${{ steps.DownloadProjectDependencies.outputs.DownloadedTestApps }} + baselineWorkflowRunId: ${{ inputs.baselineWorkflowRunId }} + baselineWorkflowSHA: ${{ inputs.baselineWorkflowSHA }} + + - name: Sign + id: sign + if: steps.DetermineBuildProject.outputs.BuildIt == 'True' && inputs.signArtifacts && env.doNotSignApps == 'False' && (env.keyVaultCodesignCertificateName != '' || (fromJson(env.trustedSigning).Endpoint != '' && fromJson(env.trustedSigning).Account != '' && fromJson(env.trustedSigning).CertificateProfile != '')) + uses: microsoft/AL-Go-Actions/Sign@v7.1 + with: + shell: ${{ inputs.shell }} + azureCredentialsJson: '${{ fromJson(steps.ReadSecrets.outputs.Secrets).AZURE_CREDENTIALS }}' + pathToFiles: '${{ inputs.project }}/.buildartifacts/Apps/*.app' + + - name: Calculate Artifact names + id: calculateArtifactsNames + uses: microsoft/AL-Go-Actions/CalculateArtifactNames@v7.1 + if: success() || failure() + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + suffix: ${{ inputs.artifactsNameSuffix }} + + - name: Publish artifacts - apps + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: inputs.artifactsRetentionDays >= 0 && (hashFiles(format('{0}/.buildartifacts/Apps/*',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.AppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: ${{ inputs.artifactsRetentionDays }} + + - name: Publish artifacts - dependencies + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: inputs.artifactsRetentionDays >= 0 && env.generateDependencyArtifact == 'True' && (hashFiles(format('{0}/.buildartifacts/Dependencies/*',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.DependenciesArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Dependencies/' + if-no-files-found: ignore + retention-days: ${{ inputs.artifactsRetentionDays }} + + - name: Publish artifacts - test apps + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: inputs.artifactsRetentionDays >= 0 && (hashFiles(format('{0}/.buildartifacts/TestApps/*',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.TestAppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: ${{ inputs.artifactsRetentionDays }} + + - name: Publish artifacts - build output + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.BuildOutputArtifactsName }} + path: '${{ inputs.project }}/BuildOutput.txt' + if-no-files-found: ignore + + - name: Publish artifacts - container event log + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.ContainerEventLogArtifactsName }} + path: '${{ inputs.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + + - name: Publish artifacts - test results + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: (success() || failure()) && (hashFiles(format('{0}/.buildartifacts/TestResults.xml',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.TestResultsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/TestResults.xml' + if-no-files-found: ignore + + - name: Publish artifacts - bcpt test results + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: (success() || failure()) && (hashFiles(format('{0}/.buildartifacts/bcptTestResults.json',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.BcptTestResultsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/bcptTestResults.json' + if-no-files-found: ignore + + - name: Publish artifacts - page scripting test results + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: (success() || failure()) && (hashFiles(format('{0}/.buildartifacts/PageScriptingTestResults.xml',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.PageScriptingTestResultsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/PageScriptingTestResults.xml' + if-no-files-found: ignore + + - name: Publish artifacts - page scripting test result details + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + if: (success() || failure()) && (hashFiles(format('{0}/.buildartifacts/PageScriptingTestResultDetails/*',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.PageScriptingTestResultDetailsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/PageScriptingTestResultDetails/' + if-no-files-found: ignore + + - name: Analyze Test Results + id: analyzeTestResults + if: (success() || failure()) && env.doNotRunTests == 'False' && ((hashFiles(format('{0}/.buildartifacts/TestResults.xml',inputs.project)) != '') || (hashFiles(format('{0}/.buildartifacts/bcptTestResults.json',inputs.project)) != '')) + uses: microsoft/AL-Go-Actions/AnalyzeTests@v7.1 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + testType: "normal" + + - name: Analyze BCPT Test Results + id: analyzeTestResultsBCPT + if: (success() || failure()) && env.doNotRunBcptTests == 'False' + uses: microsoft/AL-Go-Actions/AnalyzeTests@v7.1 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + testType: "bcpt" + + - name: Analyze Page Scripting Test Results + id: analyzeTestResultsPageScripting + if: (success() || failure()) && env.doNotRunpageScriptingTests == 'False' + uses: microsoft/AL-Go-Actions/AnalyzeTests@v7.1 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + testType: "pageScripting" + + - name: Cleanup + if: always() && steps.DetermineBuildProject.outputs.BuildIt == 'True' + uses: microsoft/AL-Go-Actions/PipelineCleanup@v7.1 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }}