diff --git a/.AL-Go/cloudDevEnv.ps1 b/.AL-Go/cloudDevEnv.ps1 index a85ac33..0fd9843 100644 --- a/.AL-Go/cloudDevEnv.ps1 +++ b/.AL-Go/cloudDevEnv.ps1 @@ -6,42 +6,45 @@ 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 { +Clear-Host +Write-Host +Write-Host -ForegroundColor Yellow @' + _____ _ _ _____ ______ + / ____| | | | | __ \ | ____| + | | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __ + | | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / / + | |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V / + \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ + +'@ + $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" +$GitHubHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/Github-Helper.psm1' +Write-Host "Downloading GitHub Helper module from $GitHubHelperUrl" $GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" +$webClient.DownloadFile($GitHubHelperUrl, $GitHubHelperPath) +$ALGoHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/AL-Go-Helper.ps1' +Write-Host "Downloading AL-Go Helper script from $ALGoHelperUrl" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/AL-Go-Helper.ps1', $ALGoHelperPath) +$webClient.DownloadFile($ALGoHelperUrl, $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 / - \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ - -'@ - 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 +55,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 +79,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 4c1a68b..d771670 100644 --- a/.AL-Go/localDevEnv.ps1 +++ b/.AL-Go/localDevEnv.ps1 @@ -5,26 +5,41 @@ # 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 try { +Clear-Host +Write-Host +Write-Host -ForegroundColor Yellow @' + _ _ _____ ______ + | | | | | __ \ | ____| + | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ + | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / + | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / + |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ + +'@ + $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" +$GitHubHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/Github-Helper.psm1' +Write-Host "Downloading GitHub Helper module from $GitHubHelperUrl" $GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" +$webClient.DownloadFile($GitHubHelperUrl, $GitHubHelperPath) +$ALGoHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/AL-Go-Helper.ps1' +Write-Host "Downloading AL-Go Helper script from $ALGoHelperUrl" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/AL-Go-Helper.ps1', $ALGoHelperPath) +$webClient.DownloadFile($ALGoHelperUrl, $ALGoHelperPath) Import-Module $GitHubHelperPath . $ALGoHelperPath -local @@ -32,19 +47,8 @@ Import-Module $GitHubHelperPath $baseFolder = GetBaseFolder -folder $PSScriptRoot $project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot -Clear-Host -Write-Host -Write-Host -ForegroundColor Yellow @' - _ _ _____ ______ - | | | | | __ \ | ____| - | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ - | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / - | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / - |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ - -'@ - 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 +59,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) @@ -132,7 +136,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/AL-Go-Settings.json b/.github/AL-Go-Settings.json index ca57d36..bff3c2b 100644 --- a/.github/AL-Go-Settings.json +++ b/.github/AL-Go-Settings.json @@ -1,13 +1,13 @@ { "type": "PTE", - "templateUrl": "https://github.com/microsoft/AL-Go-PTE@PPPreview", + "templateUrl": "https://github.com/Microsoft/al-go-pte@preview", "powerPlatformSolutionFolder": "TakeOrder", "environments": [ "Staging" ], - "DeployToStaging": { - "environmentName": "Sandbox", - "companyId": "f1678e37-e50b-ef11-9f8e-6045bdc8c192", - "ppEnvironmentUrl": "https://orgf287aea1.crm.dynamics.com/" - } -} + "DeployToStaging": { + "environmentName": "Sandbox", + "companyId": "f1678e37-e50b-ef11-9f8e-6045bdc8c192", + "ppEnvironmentUrl": "https://orgf287aea1.crm.dynamics.com/" + } +} \ No newline at end of file diff --git a/.github/RELEASENOTES.copy.md b/.github/RELEASENOTES.copy.md index 09b8ba8..bf38a4d 100644 --- a/.github/RELEASENOTES.copy.md +++ b/.github/RELEASENOTES.copy.md @@ -1,6 +1,273 @@ -## Preview +## preview -Note that when using the preview version of AL-Go for GitHub, you need to Update your AL-Go system files, as soon as possible when told to do so. +Note that when using the preview version of AL-Go for GitHub, we recommend you Update your AL-Go system files, as soon as possible when informed that an update is available. + +### 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 + +Issue 542 Deploy Workflow fails +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 +- `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 ### Issues @@ -25,9 +292,14 @@ 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. + ### New Actions - **DetermineArtifactUrl** is used to determine which artifacts to use for building a project in CI/CD, PullRequestHandler, Current, NextMinor and NextMajor workflows. @@ -163,7 +435,7 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat - 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 @@ -278,7 +550,7 @@ Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Updat ``` "ConditionalSettings": [ { - "branches": [ + "branches": [ "feature/*" ], "settings": { diff --git a/.github/workflows/AddExistingAppOrTestApp.yaml b/.github/workflows/AddExistingAppOrTestApp.yaml index 5f0e6ca..4da2892 100644 --- a/.github/workflows/AddExistingAppOrTestApp.yaml +++ b/.github/workflows/AddExistingAppOrTestApp.yaml @@ -13,9 +13,13 @@ 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: contents: write @@ -31,22 +35,43 @@ env: jobs: AddExistingAppOrTestApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0090" + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Add existing app - uses: microsoft/AL-Go-Actions/AddExistingApp@PPPreview + uses: microsoft/AL-Go/Actions/AddExistingApp@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} url: ${{ github.event.inputs.url }} @@ -54,7 +79,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0090" diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml index c506f78..c090231 100644 --- a/.github/workflows/CICD.yaml +++ b/.github/workflows/CICD.yaml @@ -16,6 +16,7 @@ defaults: permissions: contents: read actions: read + pages: read env: workflowDepth: 1 @@ -24,547 +25,307 @@ 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 }} projectDependenciesJson: ${{ steps.determineProjectsToBuild.outputs.ProjectDependenciesJson }} buildOrderJson: ${{ steps.determineProjectsToBuild.outputs.BuildOrderJson }} + powerPlatformSolutionFolder: ${{ steps.DeterminePowerPlatformSolutionFolder.outputs.powerPlatformSolutionFolder }} + workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0091" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getEnvironments: '*' - + get: type, powerPlatformSolutionFolder + + - name: Determine Workflow Depth + id: DetermineWorkflowDepth + run: | + 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@PPPreview + uses: microsoft/AL-Go/Actions/DetermineProjectsToBuild@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + projectsJson: '${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' + checkContextSecrets: 'false' - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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') -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@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + 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@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + 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@v4 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} get: templateUrl - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@PPPreview + uses: microsoft/AL-Go/Actions/CheckForUpdates@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} templateUrl: ${{ env.templateUrl }} + downloadLatest: true Build: needs: [ Initialization ] if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 - runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} - defaults: - run: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} - outputs: - AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} - TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} - TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} - BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} - BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} + 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 }} + project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} + buildMode: ${{ matrix.buildMode }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || startswith(github.ref_name, 'releases/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} + signArtifacts: true + useArtifactCache: true + + BuildPP: + needs: [ Initialization ] + if: (!failure()) && (!cancelled()) && needs.Initialization.outputs.powerPlatformSolutionFolder != '' + name: Build PowerPlatform Solution + uses: ./.github/workflows/_BuildPowerPlatformSolution.yaml + secrets: inherit + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + runsOn: ${{ needs.Initialization.outputs.githubRunner }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + project: ${{ needs.Initialization.outputs.powerPlatformSolutionFolder }} + projectName: ${{ needs.Initialization.outputs.powerPlatformSolutionFolder }} + publishArtifacts: ${{ github.ref_name == 'main' || startswith(github.ref_name, 'release/') || startswith(github.ref_name, 'releases/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} + + 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@v3 - with: - lfs: true - - - name: Download thisbuild artifacts - if: env.workflowDepth > 1 - uses: actions/download-artifact@v3 - with: - path: '.dependencies' - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,storageContext,gitHubPackagesContext' - - - name: Determine ArtifactUrl - uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@PPPreview - id: determineArtifactUrl - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - - - name: Cache Business Central Artifacts - if: env.useCompilerFolder == 'True' && steps.determineArtifactUrl.outputs.ArtifactUrl && !contains(env.artifact,'INSIDERSASTOKEN') - uses: actions/cache@v3 - with: - path: .artifactcache - key: ${{ steps.determineArtifactUrl.outputs.ArtifactUrl }} + uses: actions/checkout@v4 - - name: Build AL Project - id: RunPipeline - if: matrix.project != env.powerPlatformSolutionFolder - uses: microsoft/AL-Go-Actions/RunPipeline@PPPreview - env: - BuildMode: ${{ matrix.buildMode }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - buildMode: ${{ matrix.buildMode }} - - - name: Build PowerPlatform Solution - id: BuildPowerPlatform - if: matrix.project == env.powerPlatformSolutionFolder && matrix.buildMode == 'default' - uses: microsoft/AL-Go-Actions/BuildPowerPlatform@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - solutionFolder: ${{ matrix.project }} - outputFolder: ${{ matrix.project }}/.buildartifacts/PowerPlatformSolution/ - outputFileName: ${{ matrix.project }} - appRevision: ${{ env.appRevision }} - appBuild: ${{ env.appBuild }} - - - name: Calculate Artifact names - id: calculateArtifactsNames - uses: microsoft/AL-Go-Actions/CalculateArtifactNames@PPPreview - if: success() || failure() - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - settingsJson: ${{ env.Settings }} - project: ${{ matrix.project }} - buildMode: ${{ matrix.buildMode }} - branchName: ${{ github.ref_name }} - - - name: Upload thisbuild artifacts - apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Publish artifacts - apps - uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 - with: - name: ${{ env.AppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - - - name: Publish artifacts - dependencies - uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 - with: - name: ${{ env.DependenciesArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Dependencies/' - if-no-files-found: ignore - - - name: Publish artifacts - test apps - uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 - with: - name: ${{ env.TestAppsArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') + - name: Download artifacts + uses: actions/download-artifact@v4 with: - name: ${{ env.BuildOutputArtifactsName }} - path: '${{ matrix.project }}/BuildOutput.txt' - if-no-files-found: ignore + path: '.artifacts' - - name: Publish artifacts - container event log - uses: actions/upload-artifact@v3 - if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',matrix.project)) != '') + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: - name: ${{ env.ContainerEventLogArtifactsName }} - path: '${{ matrix.project }}/ContainerEventLog.evtx' - if-no-files-found: ignore + shell: powershell - - name: Publish artifacts - test results - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',matrix.project)) != '') - with: - name: ${{ env.TestResultsArtifactsName }} - path: '${{ matrix.project }}/TestResults.xml' - if-no-files-found: ignore + - name: Setup Pages + if: needs.Initialization.outputs.deployALDocArtifact == 1 + uses: actions/configure-pages@v5 - - name: Publish artifacts - bcpt test results - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',matrix.project)) != '') + - name: Build Reference Documentation + uses: microsoft/AL-Go/Actions/BuildReferenceDocumentation@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: - name: ${{ env.BcptTestResultsArtifactsName }} - path: '${{ matrix.project }}/bcptTestResults.json' - if-no-files-found: ignore + shell: powershell + artifacts: '.artifacts' - - name: Publish artifacts - Power Platform Solution - uses: actions/upload-artifact@v3 - if: github.ref_name == 'main' || startswith(github.ref_name, 'release/') || needs.Initialization.outputs.deliveryTargetCount > 0 || needs.Initialization.outputs.environmentCount > 0 + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v3 with: - name: ${{ env.PowerPlatformSolutionArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/PowerPlatformSolution/' - if-no-files-found: ignore - - - name: Analyze Test Results - id: analyzeTestResults - if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} + path: ".aldoc/_site/" - - name: Cleanup - if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} + - name: Deploy to GitHub Pages + if: needs.Initialization.outputs.deployALDocArtifact == 1 + id: deployment + uses: actions/deploy-pages@v4 Deploy: - needs: [ Initialization, Build ] - if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.environmentCount > 0 - strategy: ${{ fromJson(needs.Initialization.outputs.environments) }} + needs: [ Initialization, Build, BuildPP ] + if: (!cancelled()) && (needs.Build.result == 'success' || needs.Build.result == 'skipped') && (needs.BuildPP.result == 'success' || needs.BuildPP.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@v4 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: '.artifacts' + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + 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" - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview - with: - shell: powershell + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "envName=$envName" - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' - - name: AuthContext - id: authContext - run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $envName = '${{ steps.envName.outputs.envName }}' - $deployToSettingStr = [System.Environment]::GetEnvironmentVariable("DeployTo$envName") - if ($deployToSettingStr) { - $deployToSettings = $deployToSettingStr | ConvertFrom-Json - } - else { - $deployToSettings = [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 (("$deployToSettings" -ne "") -and $deployToSettings.PSObject.Properties.name -eq "EnvironmentName") { - $environmentName = $deployToSettings.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 }}' - } - $deployToSettings | Add-Member -MemberType NoteProperty -name 'environmentName' -value $environmentName - } - $environmentName = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($environmentName + '${{ matrix.environment }}'.SubString($envName.Length)).ToUpperInvariant())) - if (("$deployToSettings" -ne "") -and $deployToSettings.PSObject.Properties.name -eq "projects") { - $projects = $deployToSettings.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'))) - } - } - $deployToSettings | Add-Member -MemberType NoteProperty -Name 'projects' -Value $projects - } - $powerPlatformSolutionFolder = [System.Environment]::GetEnvironmentVariable('PowerPlatformSolutionFolder') - $deployPP = $false - if ($projects -eq '' -or $projects -eq '*') { - $projects = '*' - $deployPP = ("$powerPlatformSolutionFolder" -ne "") - } - else { - $buildProjects = '${{ needs.Initialization.outputs.projects }}' | ConvertFrom-Json - $projects = ($projects.Split(',') | Where-Object { - $deployALProject = $buildProjects -contains $_ - if ($_ -eq $powerPlatformSolutionFolder) { - $deployPP = $true - $deployALProject = $false - } - $deployALProject - }) -join ',' - } - - Add-Content -Path $env:GITHUB_OUTPUT -Value "authContext=$authContext" - Write-Host "authContext=$authContext" - Add-Content -Path $env:GITHUB_OUTPUT -Value "deployTo=$($deployToSettings | ConvertTo-Json -depth 99 -compress)" - 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" - Add-Content -Path $env:GITHUB_OUTPUT -Value "deployPP=$deployPP" - Write-Host "deployPP=$deployPP" - - - name: Deploy AL - uses: microsoft/AL-Go-Actions/Deploy@PPPreview - if: ${{ steps.authContext.outputs.projects }} + - name: Deploy to Business Central + id: Deploy + uses: microsoft/AL-Go/Actions/Deploy@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 env: - AuthContext: ${{ steps.authContext.outputs.authContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: - shell: powershell + shell: ${{ matrix.shell }} + environmentName: ${{ matrix.environment }} + artifactsFolder: '.artifacts' type: 'CD' - projects: ${{ steps.authContext.outputs.projects }} - environmentName: ${{ steps.authContext.outputs.environmentName }} - artifacts: '.artifacts' + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} - - name: Deploy PowerPlatform - if: ${{ steps.authContext.outputs.deployPP == 'true' }} - uses: microsoft/AL-Go-Actions/DeployPowerPlatform@PPPreview + - name: Deploy to Power Platform + if: env.type == 'PTE' && env.powerPlatformSolutionFolder != '' + uses: microsoft/AL-Go/Actions/DeployPowerPlatform@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - artifactPath: '.artifacts' - deploySettings: ${{ steps.authContext.outputs.deployTo }} - authSettings: ${{ steps.authContext.outputs.authContext }} + shell: powershell + 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 + needs: [ Initialization, Build, BuildPP ] + if: (!cancelled()) && (needs.Build.result == 'success' || needs.Build.result == 'skipped') && (needs.BuildPP.result == 'success' || needs.BuildPP.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@v4 - name: Download artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: path: '.artifacts' - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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@PPPreview + uses: microsoft/AL-Go/Actions/Deliver@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 env: - deliveryContext: ${{ steps.deliveryContext.outputs.deliveryContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell type: 'CD' @@ -573,16 +334,16 @@ jobs: artifacts: '.artifacts' PostProcess: + needs: [ Initialization, Build, BuildPP, Deploy, Deliver, DeployALDoc ] if: (!cancelled()) runs-on: [ windows-latest ] - needs: [ Initialization, Build, Deploy, Deliver ] steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0091" diff --git a/.github/workflows/CreateApp.yaml b/.github/workflows/CreateApp.yaml index 635b61e..23c9cd5 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,13 +19,17 @@ 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: contents: write @@ -41,29 +45,44 @@ env: jobs: CreateApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0092" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} get: type + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Creating a new app - uses: microsoft/AL-Go-Actions/CreateApp@PPPreview + uses: microsoft/AL-Go/Actions/CreateApp@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: ${{ env.type }} @@ -75,7 +94,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0092" diff --git a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml index 1950ddb..9a26a12 100644 --- a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml +++ b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml @@ -1,21 +1,29 @@ 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: contents: write @@ -30,108 +38,119 @@ env: ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} jobs: - Initialize: + Initialization: + needs: [ ] runs-on: [ windows-latest ] outputs: deviceCode: ${{ steps.authenticate.outputs.deviceCode }} telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }} + githubRunnerShell: ${{ steps.ReadSettings.outputs.GitHubRunnerShell }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0093" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + id: ReadSettings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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)!" + Set-Content -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/PPPreview/AL-Go-Helper.ps1', $ALGoHelperPath) + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/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)" + 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 $($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@v4 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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@PPPreview + uses: microsoft/AL-Go/Actions/CreateDevelopmentEnvironment@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} 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@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0093" - telemetryScopeJson: ${{ needs.Initialize.outputs.telemetryScopeJson }} + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreatePerformanceTestApp.yaml b/.github/workflows/CreatePerformanceTestApp.yaml index 9c121fa..4a50b53 100644 --- a/.github/workflows/CreatePerformanceTestApp.yaml +++ b/.github/workflows/CreatePerformanceTestApp.yaml @@ -12,26 +12,30 @@ 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: contents: write @@ -47,22 +51,43 @@ env: jobs: CreatePerformanceTestApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0102" + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@PPPreview + uses: microsoft/AL-Go/Actions/CreateApp@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: 'Performance Test App' @@ -75,7 +100,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0102" diff --git a/.github/workflows/CreateRelease.yaml b/.github/workflows/CreateRelease.yaml index bb878b7..2062ea1 100644 --- a/.github/workflows/CreateRelease.yaml +++ b/.github/workflows/CreateRelease.yaml @@ -1,4 +1,5 @@ name: ' Create release' +run-name: "Create release - Version ${{ inputs.tag }}" on: workflow_dispatch: @@ -16,25 +17,33 @@ on: required: true default: '' prerelease: - description: Prerelease (Y/N) - required: false - default: 'N' + description: Prerelease? + type: boolean + default: false draft: - description: Draft (Y/N) - required: false - default: 'N' + description: Draft? + type: boolean + default: false 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. required: false default: '' 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: contents: write @@ -53,66 +62,85 @@ 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 }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0094" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - get: templateUrl,repoName + get: templateUrl,repoName,type,powerPlatformSolutionFolder + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Determine Projects id: determineProjects - uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@PPPreview + uses: microsoft/AL-Go/Actions/DetermineProjectsToBuild@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - name: Check for updates to AL-Go system files - uses: microsoft/AL-Go-Actions/CheckForUpdates@PPPreview + uses: microsoft/AL-Go/Actions/CheckForUpdates@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} templateUrl: ${{ env.templateUrl }} + downloadLatest: true - name: Analyze Artifacts id: analyzeartifacts env: _appVersion: ${{ github.event.inputs.appVersion }} 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 - $allArtifacts += $repoArtifacts.Artifacts + $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++ } while ($repoArtifacts.Artifacts.Count -gt 0) @@ -128,16 +156,15 @@ jobs: } $refname = "$ENV:GITHUB_REF_NAME".Replace('/','_') Write-Host "Analyzing artifacts for project $project" - $appVersion = "$ENV:_appVersion" + $appVersion = "$env:_appVersion" if ($appVersion -eq "latest") { Write-Host "Grab latest" $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 or $project-$refname-PowerPlatformSolution-$appVersion" - $artifact = $allArtifacts | Where-Object { $_.name -eq "$project-$refname-Apps-$appVersion" -or $_.name -eq "$project-$refname-PowerPlatformSolution-$appVersion" } | Select-Object -First 1 + $artifact = $allArtifacts | Where-Object { $_.name -eq "$project-$refname-Apps-$appVersion"-or $_.name -eq "$project-$refname-PowerPlatformSolution-$appVersion" } | Select-Object -First 1 } - if ($artifact) { $startIndex = $artifact.name.LastIndexOf('-') + 1 $artifactsVersion = $artifact.name.SubString($startIndex) @@ -156,13 +183,12 @@ jobs: $sha = $artifact.workflow_run.head_sha } - write-host "looking for $project-$refname-Apps-$artifactsVersion or $project-$refname-TestApps-$artifactsVersion or $project-$refname-Dependencies-$artifactsVersion or $project-$refname-PowerPlatformSolution-$artifactsVersion" + 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 for version $artifactsVersion" exit 1 @@ -170,26 +196,27 @@ jobs: } $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@PPPreview + uses: microsoft/AL-Go/Actions/CreateReleaseNotes@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} tag_name: ${{ github.event.inputs.tag }} + target_commitish: ${{ steps.analyzeartifacts.outputs.commitish }} - name: Create release - uses: actions/github-script@v6 + uses: actions/github-script@v7 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({ @@ -198,8 +225,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.draft=='true' }}, + prerelease: ${{ github.event.inputs.prerelease=='true' }}, make_latest: 'legacy', target_commitish: '${{ steps.analyzeartifacts.outputs.commitish }}' }); @@ -209,52 +236,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@v4 - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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@v7 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, @@ -264,23 +289,11 @@ 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@PPPreview - if: ${{ steps.nuGetContext.outputs.nuGetContext }} + uses: microsoft/AL-Go/Actions/Deliver@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).nuGetContext != '' }} env: - deliveryContext: ${{ steps.nuGetContext.outputs.nuGetContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell type: 'Release' @@ -289,23 +302,11 @@ jobs: artifacts: ${{ github.event.inputs.appVersion }} 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@PPPreview - if: ${{ steps.storageContext.outputs.storageContext }} + uses: microsoft/AL-Go/Actions/Deliver@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).storageContext != '' }} env: - deliveryContext: ${{ steps.storageContext.outputs.storageContext }} + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell type: 'Release' @@ -315,49 +316,70 @@ jobs: 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@v4 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@v4 + + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Update Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@PPPreview + uses: microsoft/AL-Go/Actions/IncrementVersionNumber@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} versionNumber: ${{ github.event.inputs.updateVersionNumber }} 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@v4 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0094" diff --git a/.github/workflows/CreateTestApp.yaml b/.github/workflows/CreateTestApp.yaml index d3810fe..d6d21eb 100644 --- a/.github/workflows/CreateTestApp.yaml +++ b/.github/workflows/CreateTestApp.yaml @@ -12,22 +12,26 @@ 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: contents: write @@ -43,22 +47,43 @@ env: jobs: CreateTestApp: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0095" + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Creating a new test app - uses: microsoft/AL-Go-Actions/CreateApp@PPPreview + uses: microsoft/AL-Go/Actions/CreateApp@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} project: ${{ github.event.inputs.project }} type: 'Test App' @@ -70,7 +95,7 @@ jobs: - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0095" diff --git a/.github/workflows/Current.yaml b/.github/workflows/Current.yaml index d5f7974..c747ada 100644 --- a/.github/workflows/Current.yaml +++ b/.github/workflows/Current.yaml @@ -5,6 +5,7 @@ on: permissions: contents: read + actions: read defaults: run: @@ -17,38 +18,48 @@ 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 }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0101" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - + + - name: Determine Workflow Depth + id: DetermineWorkflowDepth + run: | + 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@PPPreview + uses: microsoft/AL-Go/Actions/DetermineProjectsToBuild@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -56,161 +67,36 @@ jobs: Build: needs: [ Initialization ] if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 - runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} - defaults: - run: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} - outputs: - TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} - BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} - BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - lfs: true - - - name: Download thisbuild artifacts - if: env.workflowDepth > 1 - uses: actions/download-artifact@v3 - with: - path: '${{ github.workspace }}\.dependencies' - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - - - name: Determine ArtifactUrl - uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@PPPreview - id: determineArtifactUrl - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - - - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@PPPreview - env: - BuildMode: ${{ matrix.buildMode }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - buildMode: ${{ matrix.buildMode }} - - - name: Calculate Artifact names - id: calculateArtifactsNames - uses: microsoft/AL-Go-Actions/CalculateArtifactNames@PPPreview - if: success() || failure() - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - settingsJson: ${{ env.Settings }} - project: ${{ matrix.project }} - buildMode: ${{ matrix.buildMode }} - branchName: ${{ github.ref_name }} - suffix: 'Current' - - - name: Upload thisbuild artifacts - apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Publish artifacts - build output - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') - with: - name: ${{ env.buildOutputArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.ContainerEventLogArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.TestResultsArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.BcptTestResultsArtifactsName }} - path: '${{ matrix.project }}/bcptTestResults.json' - if-no-files-found: ignore - - - name: Analyze Test Results - id: analyzeTestResults - if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - - - name: Cleanup - if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} + 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 }} + project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} + buildMode: ${{ matrix.buildMode }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + 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@v4 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0101" diff --git a/.github/workflows/DeployReferenceDocumentation.yaml b/.github/workflows/DeployReferenceDocumentation.yaml new file mode 100644 index 0000000..bd15ec4 --- /dev/null +++ b/.github/workflows/DeployReferenceDocumentation.yaml @@ -0,0 +1,71 @@ +name: ' Deploy Reference Documentation' + +on: + workflow_dispatch: + +permissions: + contents: read + actions: read + pages: write + id-token: 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@v4 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + eventId: "DO0097" + + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go/Actions/DetermineDeploymentEnvironments@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + 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@v5 + + - name: Build Reference Documentation + uses: microsoft/AL-Go/Actions/BuildReferenceDocumentation@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + artifacts: 'latest' + + - name: Upload pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ".aldoc/_site/" + + - name: Deploy to GitHub Pages + if: steps.DetermineDeploymentEnvironments.outputs.deployALDocArtifact == 1 + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/IncrementVersionNumber.yaml b/.github/workflows/IncrementVersionNumber.yaml index 1d98065..d81fddb 100644 --- a/.github/workflows/IncrementVersionNumber.yaml +++ b/.github/workflows/IncrementVersionNumber.yaml @@ -5,17 +5,21 @@ 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) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: contents: write @@ -31,30 +35,51 @@ env: jobs: IncrementVersionNumber: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0096" + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + - name: Increment Version Number - uses: microsoft/AL-Go-Actions/IncrementVersionNumber@PPPreview + uses: microsoft/AL-Go/Actions/IncrementVersionNumber@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - project: ${{ github.event.inputs.project }} + projects: ${{ github.event.inputs.projects }} versionNumber: ${{ github.event.inputs.versionNumber }} directCommit: ${{ github.event.inputs.directCommit }} - + - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0096" diff --git a/.github/workflows/NextMajor.yaml b/.github/workflows/NextMajor.yaml index d78c836..0e1ff57 100644 --- a/.github/workflows/NextMajor.yaml +++ b/.github/workflows/NextMajor.yaml @@ -5,6 +5,7 @@ on: permissions: contents: read + actions: read defaults: run: @@ -17,38 +18,48 @@ 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 }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0099" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - + + - name: Determine Workflow Depth + id: DetermineWorkflowDepth + run: | + 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@PPPreview + uses: microsoft/AL-Go/Actions/DetermineProjectsToBuild@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -56,161 +67,36 @@ jobs: Build: needs: [ Initialization ] if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 - runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} - defaults: - run: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} - outputs: - TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} - BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} - BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - lfs: true - - - name: Download thisbuild artifacts - if: env.workflowDepth > 1 - uses: actions/download-artifact@v3 - with: - path: '${{ github.workspace }}\.dependencies' - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - - - name: Determine ArtifactUrl - uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@PPPreview - id: determineArtifactUrl - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - - - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@PPPreview - env: - BuildMode: ${{ matrix.buildMode }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - buildMode: ${{ matrix.buildMode }} - - - name: Calculate Artifact names - id: calculateArtifactsNames - uses: microsoft/AL-Go-Actions/CalculateArtifactNames@PPPreview - if: success() || failure() - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - settingsJson: ${{ env.Settings }} - project: ${{ matrix.project }} - buildMode: ${{ matrix.buildMode }} - branchName: ${{ github.ref_name }} - suffix: 'NextMajor' - - - name: Upload thisbuild artifacts - apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Publish artifacts - build output - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') - with: - name: ${{ env.buildOutputArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.ContainerEventLogArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.TestResultsArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.BcptTestResultsArtifactsName }} - path: '${{ matrix.project }}/bcptTestResults.json' - if-no-files-found: ignore - - - name: Analyze Test Results - id: analyzeTestResults - if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - - - name: Cleanup - if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} + 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 }} + project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} + buildMode: ${{ matrix.buildMode }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + 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@v4 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0099" diff --git a/.github/workflows/NextMinor.yaml b/.github/workflows/NextMinor.yaml index e99e790..3e31548 100644 --- a/.github/workflows/NextMinor.yaml +++ b/.github/workflows/NextMinor.yaml @@ -5,6 +5,7 @@ on: permissions: contents: read + actions: read defaults: run: @@ -17,38 +18,48 @@ 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 }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0100" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - + + - name: Determine Workflow Depth + id: DetermineWorkflowDepth + run: | + 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@PPPreview + uses: microsoft/AL-Go/Actions/DetermineProjectsToBuild@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -56,161 +67,36 @@ jobs: Build: needs: [ Initialization ] if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 - runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} - defaults: - run: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} - outputs: - TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} - BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} - BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - lfs: true - - - name: Download thisbuild artifacts - if: env.workflowDepth > 1 - uses: actions/download-artifact@v3 - with: - path: '${{ github.workspace }}\.dependencies' - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,codeSignCertificateUrl,codeSignCertificatePassword,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - - - name: Determine ArtifactUrl - uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@PPPreview - id: determineArtifactUrl - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - - - name: Run pipeline - uses: microsoft/AL-Go-Actions/RunPipeline@PPPreview - env: - BuildMode: ${{ matrix.buildMode }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - buildMode: ${{ matrix.buildMode }} - - - name: Calculate Artifact names - id: calculateArtifactsNames - uses: microsoft/AL-Go-Actions/CalculateArtifactNames@PPPreview - if: success() || failure() - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - settingsJson: ${{ env.Settings }} - project: ${{ matrix.project }} - buildMode: ${{ matrix.buildMode }} - branchName: ${{ github.ref_name }} - suffix: 'NextMinor' - - - name: Upload thisbuild artifacts - apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Publish artifacts - build output - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') - with: - name: ${{ env.buildOutputArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.ContainerEventLogArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.TestResultsArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.BcptTestResultsArtifactsName }} - path: '${{ matrix.project }}/bcptTestResults.json' - if-no-files-found: ignore - - - name: Analyze Test Results - id: analyzeTestResults - if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - - - name: Cleanup - if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} + 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 }} + project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} + buildMode: ${{ matrix.buildMode }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + secrets: 'licenseFileUrl,codeSignCertificateUrl,*codeSignCertificatePassword,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + 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@v4 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0100" diff --git a/.github/workflows/PublishToEnvironment.yaml b/.github/workflows/PublishToEnvironment.yaml index 2fa19ff..a55c3e3 100644 --- a/.github/workflows/PublishToEnvironment.yaml +++ b/.github/workflows/PublishToEnvironment.yaml @@ -25,69 +25,79 @@ 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 }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0097" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go/Actions/DetermineDeploymentEnvironments@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + 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@PPPreview - if: steps.ReadSettings.outputs.UnknownEnvironment == 1 - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + 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!" @@ -97,98 +107,94 @@ jobs: 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/PPPreview/AL-Go-Helper.ps1', $ALGoHelperPath) + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/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_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@v4 - 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@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: - shell: powershell + shell: ${{ matrix.shell }} + get: type,powerPlatformSolutionFolder - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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,${{ steps.envName.outputs.envName }}-EnvironmentName,${{ steps.envName.outputs.envName }}_EnvironmentName,EnvironmentName,projects' - - name: Get Auth context - uses: microsoft/AL-Go-Actions/ReadAuthContext@PPPreview - with: + - name: Get Artifacts for deployment + uses: microsoft/AL-Go/Actions/GetArtifactsForDeployment@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: shell: powershell - envName: ${{ steps.envName.outputs.envName }} - environment: ${{ steps.envName.outputs.envName }} + artifactsVersion: ${{ github.event.inputs.appVersion }} + artifactsFolder: '.artifacts' - - name: Deploy AL - uses: microsoft/AL-Go-Actions/Deploy@PPPreview + - name: Deploy to Business Central + id: Deploy + uses: microsoft/AL-Go/Actions/Deploy@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 env: - AuthContext: ${{ env.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: ${{ env.projects }} - environmentName: ${{ env.environmentName }} - artifacts: ${{ github.event.inputs.appVersion }} - - - name: Get Artifacts - uses: microsoft/AL-Go-Actions/GetArtifacts@PPPreview - with: - shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - artifactVersion: ${{ github.event.inputs.appVersion }} + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} - - name: Deploy PowerPlatform - if: ${{ env.deployPP == 'true' }} - uses: microsoft/AL-Go-Actions/DeployPowerPlatform@PPPreview + - name: Deploy to Power Platform + if: env.type == 'PTE' && env.powerPlatformSolutionFolder != '' + uses: microsoft/AL-Go/Actions/DeployPowerPlatform@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - artifactPath: '.artifacts' - deploySettings: ${{ env.deployTo }} - authSettings: ${{ env.authContext }} + 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@v4 - name: Finalize the workflow id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0097" diff --git a/.github/workflows/PullPowerPlatformChanges.yaml b/.github/workflows/PullPowerPlatformChanges.yaml index b7479a9..de721cd 100644 --- a/.github/workflows/PullPowerPlatformChanges.yaml +++ b/.github/workflows/PullPowerPlatformChanges.yaml @@ -1,19 +1,22 @@ -name: " Pull Power Platform changes" +name: ' Pull Power Platform changes' on: workflow_dispatch: inputs: - solutionName: - description: "Name of the Power Platform solution. (* takes the name from Al-go-settings.json)" - required: true - default: "*" environment: - description: "Environment" + description: Environment to pull changes from required: true - directCommit: - description: Direct COMMIT (Y/N) + solutionFolder: + description: Folder name of the Power Platform solution (leave empty to use AL-Go setting) required: false - default: "N" + directCommit: + description: Direct Commit? + type: boolean + default: false + useGhTokenWorkflow: + description: Use GhTokenWorkflow for PR/Commit? + type: boolean + default: false permissions: contents: write @@ -29,74 +32,76 @@ jobs: name: Pull changes from ${{ inputs.environment }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0103" - name: EnvName - id: envName - shell: powershell + env: + _environment: ${{ inputs.environment }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $envName = '${{ inputs.environment }}' - Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $envName = "$env:_environment".Split(' ')[0] + Add-Content -encoding utf8 -Path $env:GITHUB_ENV -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + get: powerPlatformSolutionFolder - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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" - - - name: read auth context - id: authContext - uses: microsoft/AL-Go-Actions/ReadAuthContext@PPPreview + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ env.envName }}-AuthContext,${{ env.envName }}_AuthContext,AuthContext,TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go/Actions/DetermineDeploymentEnvironments@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - envName: ${{ steps.envName.outputs.envName }} - environment: ${{ steps.envName.outputs.envName }} + getEnvironments: ${{ inputs.environment }} + type: 'All' - - name: Set Power Platform solution name - id: solutionName - shell: powershell - env: - _inputSolutionName: ${{ inputs.solutionName }} + - name: Set Power Platform solution folder + env: + _solutionFolder: ${{ inputs.solutionFolder }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $solutionName = $env:_inputSolutionName - if ($solutionName -eq "*") { - write-host "Solution name is not provided. Taking the name from Al-go-settings.json" - $solutionName = $env:powerPlatformSolutionFolder + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $solutionFolder = $env:_solutionFolder + if ($solutionFolder -eq '') { + Write-Host "Solution folder is not provided. Taking the folder from AL-Go settings" + $solutionFolder = $env:powerPlatformSolutionFolder } - write-host "Solution name: $solutionName" - Add-Content -Path $env:GITHUB_ENV -Value "powerPlatformSolutionFolder=$solutionName" + Write-Host "Solution folder: $solutionFolder" + Add-Content -encoding utf8 -Path $env:GITHUB_ENV -Value "solutionFolder=$solutionFolder" - - name: Export changes from Power Platform - uses: microsoft/AL-Go-Actions/PullPowerPlatformChanges@PPPreview - with: + - name: Pull changes from Power Platform environment + uses: microsoft/AL-Go/Actions/PullPowerPlatformChanges@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: shell: powershell - solutionName: ${{ env.powerPlatformSolutionFolder }} - directCommit: ${{ inputs.directCommit == 'Y' }} - deploySettings: ${{ env.deployTo }} - authSettings: ${{ env.authContext }} + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + directCommit: ${{ inputs.directCommit }} + environmentName: ${{ inputs.environment }} + solutionFolder: ${{ env.solutionFolder }} + deploymentEnvironmentsJson: ${{ steps.DetermineDeploymentEnvironments.outputs.deploymentEnvironmentsJson }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0103" diff --git a/.github/workflows/PullRequestHandler.yaml b/.github/workflows/PullRequestHandler.yaml index 514b07a..541ef9b 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: @@ -26,19 +24,10 @@ 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@PPPreview - 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@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 Initialization: needs: [ PregateCheck ] @@ -46,37 +35,46 @@ jobs: 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 }} + workflowDepth: ${{ steps.DetermineWorkflowDepth.outputs.WorkflowDepth }} steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: lfs: true ref: refs/pull/${{ github.event.number }}/merge - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0104" - name: Read settings id: ReadSettings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - getEnvironments: '*' - + + - name: Determine Workflow Depth + id: DetermineWorkflowDepth + run: | + 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@PPPreview + uses: microsoft/AL-Go/Actions/DetermineProjectsToBuild@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell maxBuildDepth: ${{ env.workflowDepth }} @@ -84,175 +82,37 @@ jobs: Build: needs: [ Initialization ] if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 - runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} - defaults: - run: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} strategy: matrix: include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} fail-fast: false - name: Build ${{ matrix.project }} - ${{ matrix.buildMode }} - outputs: - AppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.AppsArtifactsName }} - TestAppsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestAppsArtifactsName }} - TestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.TestResultsArtifactsName }} - BcptTestResultsArtifactsName: ${{ steps.calculateArtifactNames.outputs.BcptTestResultsArtifactsName }} - BuildOutputArtifactsName: ${{ steps.calculateArtifactNames.outputs.BuildOutputArtifactsName }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - lfs: true - ref: refs/pull/${{ github.event.number }}/merge - - - name: Download thisbuild artifacts - if: env.workflowDepth > 1 - uses: actions/download-artifact@v3 - with: - path: '.dependencies' - - - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - - - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'licenseFileUrl,insiderSasToken,keyVaultCertificateUrl,keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext' - - - name: Determine ArtifactUrl - uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@PPPreview - id: determineArtifactUrl - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - - - name: Cache Business Central Artifacts - if: env.useCompilerFolder == 'True' && steps.determineArtifactUrl.outputs.ArtifactUrl && !contains(env.artifact,'INSIDERSASTOKEN') - uses: actions/cache@v3 - with: - path: .artifactcache - key: ${{ steps.determineArtifactUrl.outputs.ArtifactUrl }} - - - name: Run pipeline - id: RunPipeline - uses: microsoft/AL-Go-Actions/RunPipeline@PPPreview - env: - BuildMode: ${{ matrix.buildMode }} - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - project: ${{ matrix.project }} - projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} - settingsJson: ${{ env.Settings }} - secretsJson: ${{ env.RepoSecrets }} - buildMode: ${{ matrix.buildMode }} - - - name: Calculate Artifact names - id: calculateArtifactsNames - uses: microsoft/AL-Go-Actions/CalculateArtifactNames@PPPreview - if: success() || failure() - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - settingsJson: ${{ env.Settings }} - project: ${{ matrix.project }} - buildMode: ${{ matrix.buildMode }} - branchName: ${{ github.ref_name }} - - - name: Upload thisbuild artifacts - apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/Apps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Upload thisbuild artifacts - test apps - if: env.workflowDepth > 1 - uses: actions/upload-artifact@v3 - with: - name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} - path: '${{ matrix.project }}/.buildartifacts/TestApps/' - if-no-files-found: ignore - retention-days: 1 - - - name: Publish artifacts - build output - uses: actions/upload-artifact@v3 - if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',matrix.project)) != '') - with: - name: ${{ env.BuildOutputArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.ContainerEventLogArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.TestResultsArtifactsName }} - path: '${{ matrix.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',matrix.project)) != '') - with: - name: ${{ env.BcptTestResultsArtifactsName }} - path: '${{ matrix.project }}/bcptTestResults.json' - if-no-files-found: ignore - - - name: Analyze Test Results - id: analyzeTestResults - if: success() || failure() - uses: microsoft/AL-Go-Actions/AnalyzeTests@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - - - name: Cleanup - if: always() - uses: microsoft/AL-Go-Actions/PipelineCleanup@PPPreview - with: - shell: ${{ needs.Initialization.outputs.githubRunnerShell }} - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - Project: ${{ matrix.project }} - - PostProcess: - runs-on: [ windows-latest ] + 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 }} + project: ${{ matrix.project }} + projectName: ${{ matrix.projectName }} + buildMode: ${{ matrix.buildMode }} + projectDependenciesJson: ${{ needs.Initialization.outputs.projectDependenciesJson }} + baselineWorkflowRunId: ${{ needs.Initialization.outputs.baselineWorkflowRunId }} + secrets: 'licenseFileUrl,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + artifactsNameSuffix: 'PR${{ github.event.number }}' + + StatusCheck: needs: [ Initialization, Build ] if: (!cancelled()) + runs-on: [ windows-latest ] + name: Pull Request Status Check steps: - - name: Checkout - uses: actions/checkout@v3 - with: - lfs: true - ref: refs/pull/${{ github.event.number }}/merge - - - name: Finalize the workflow - id: PostProcess - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + - name: Pull Request Status Check + id: PullRequestStatusCheck + uses: microsoft/AL-Go/Actions/PullRequestStatusCheck@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - eventId: "DO0104" - telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PushPowerPlatformChanges.yaml b/.github/workflows/PushPowerPlatformChanges.yaml index d8a94fc..37d8dd1 100644 --- a/.github/workflows/PushPowerPlatformChanges.yaml +++ b/.github/workflows/PushPowerPlatformChanges.yaml @@ -3,17 +3,15 @@ name: " Push Power Platform changes" on: workflow_dispatch: inputs: - solutionName: - description: "Name of the Power Platform solution. (* takes the name from Al-go-settings.json)" - required: true - default: "*" environment: - description: "Environment" + description: Environment to push changes to required: true + solutionFolder: + description: Folder name of the Power Platform solution (leave empty to use AL-Go setting) + required: false permissions: - contents: write - pull-requests: write + contents: read defaults: run: @@ -25,94 +23,74 @@ jobs: name: Push changes to ${{ inputs.environment }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0103" - name: EnvName - id: envName - shell: powershell + env: + _environment: ${{ inputs.environment }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $envName = '${{ inputs.environment }}' - Add-Content -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + # Environment names can contains spaces and tags (like (PROD) etc. We need to remove them to get the correct environment name) + $envName = "$env:_environment".Split(' ')[0] + Add-Content -encoding utf8 -Path $env:GITHUB_ENV -Value "envName=$envName" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell + get: powerPlatformSolutionFolder - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 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" + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ env.envName }}-AuthContext,${{ env.envName }}_AuthContext,AuthContext' - - name: read auth context - id: authContext - uses: microsoft/AL-Go-Actions/ReadAuthContext@PPPreview + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go/Actions/DetermineDeploymentEnvironments@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + GITHUB_TOKEN: ${{ github.token }} with: shell: powershell - envName: ${{ steps.envName.outputs.envName }} - environment: ${{ steps.envName.outputs.envName }} + getEnvironments: ${{ inputs.environment }} + type: 'All' - - name: Set Power Platform solution name - id: solutionName - shell: powershell + - name: Set Power Platform solution folder env: - _inputSolutionName: ${{ inputs.solutionName }} + _solutionFolder: ${{ inputs.solutionFolder }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 - $solutionName = $env:_inputSolutionName - if ($solutionName -eq "*") { - write-host "Solution name is not provided. Taking the name from Al-go-settings.json" - $solutionName = $env:powerPlatformSolutionFolder + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $solutionFolder = $env:_solutionFolder + if ($solutionFolder -eq '') { + Write-Host "Solution folder is not provided. Taking the folder from AL-Go settings" + $solutionFolder = $env:powerPlatformSolutionFolder } - write-host "Solution name: $solutionName" - Add-Content -Path $env:GITHUB_ENV -Value "powerPlatformSolutionFolder=$solutionName" - - - name: Parse DeployToSettings and AuthContext - uses: microsoft/AL-Go-Actions/ReadPowerPlatformSettings@PPPreview - with: - shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - deploySettings: ${{ env.deployTo }} - authSettings: ${{ env.authContext }} + Write-Host "Solution folder: $solutionFolder" + Add-Content -encoding utf8 -Path $env:GITHUB_ENV -Value "solutionFolder=$solutionFolder" - - name: Build PowerPlatform Solution - id: BuildPowerPlatform - uses: microsoft/AL-Go-Actions/BuildPowerPlatform@PPPreview - with: - shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - solutionFolder: ${{ env.powerPlatformSolutionFolder }} - outputFolder: .buildartifacts/PowerPlatformSolution/ - outputFileName: tempsolution-PowerPlatformSolution- - environmentName: ${{ env.environmentName }} - companyId: ${{ env.companyId }} - - name: Export and push changes to Power Platform - uses: microsoft/AL-Go-Actions/DeployPowerPlatform@PPPreview + uses: microsoft/AL-Go/Actions/DeployPowerPlatform@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' with: shell: powershell - parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} - artifactPath: '.buildartifacts' - deploySettings: ${{ env.deployTo }} - authSettings: ${{ env.authContext }} + environmentName: ${{ inputs.environment }} + solutionFolder: ${{ env.solutionFolder }} + deploymentEnvironmentsJson: ${{ steps.DetermineDeploymentEnvironments.outputs.deploymentEnvironmentsJson }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0103" diff --git a/.github/workflows/Troubleshooting.yaml b/.github/workflows/Troubleshooting.yaml new file mode 100644 index 0000000..69a8a79 --- /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: + contents: read + actions: read + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Troubleshooting: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + lfs: true + + - name: Troubleshooting + uses: microsoft/AL-Go/Actions/Troubleshooting@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + displayNameOfSecrets: ${{ github.event.inputs.displayNameOfSecrets }} diff --git a/.github/workflows/UpdateGitHubGoSystemFiles.yaml b/.github/workflows/UpdateGitHubGoSystemFiles.yaml index 91b691b..bdffb1f 100644 --- a/.github/workflows/UpdateGitHubGoSystemFiles.yaml +++ b/.github/workflows/UpdateGitHubGoSystemFiles.yaml @@ -4,13 +4,17 @@ on: workflow_dispatch: inputs: templateUrl: - description: Template Repository URL (current is https://github.com/microsoft/AL-Go-PTE@PPPreview) + description: Template Repository URL (current is {TEMPLATEURL}) required: false default: '' + downloadLatest: + description: Download latest from template repository + type: boolean + default: true directCommit: - description: Direct COMMIT (Y/N) - required: false - default: 'N' + description: Direct Commit? + type: boolean + default: false permissions: contents: read @@ -25,75 +29,80 @@ env: jobs: UpdateALGoSystemFiles: + needs: [ ] runs-on: [ windows-latest ] steps: + - name: Dump Workflow Information + uses: microsoft/AL-Go/Actions/DumpWorkflowInfo@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: powershell + - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize the workflow id: init - uses: microsoft/AL-Go-Actions/WorkflowInitialize@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowInitialize@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0098" - name: Read settings - uses: microsoft/AL-Go-Actions/ReadSettings@PPPreview + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - get: keyVaultName,ghTokenWorkflowSecretName,templateUrl + get: templateUrl - name: Read secrets - uses: microsoft/AL-Go-Actions/ReadSecrets@PPPreview - env: - secrets: ${{ toJson(secrets) }} + id: ReadSecrets + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - settingsJson: ${{ env.Settings }} - secrets: 'ghTokenWorkflow=${{ env.GHTOKENWORKFLOWSECRETNAME }}' + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'ghTokenWorkflow' - name: Override templateUrl env: templateUrl: ${{ github.event.inputs.templateUrl }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 $templateUrl = $ENV:templateUrl if ($templateUrl) { Write-Host "Using Template Url: $templateUrl" - Add-Content -Path $env:GITHUB_ENV -Value "templateUrl=$templateUrl" + Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "templateUrl=$templateUrl" } - - name: Calculate DirectCommit + - name: Calculate Input env: - directCommit: ${{ github.event.inputs.directCommit }} + directCommit: '${{ github.event.inputs.directCommit }}' + downloadLatest: ${{ github.event.inputs.downloadLatest }} eventName: ${{ github.event_name }} run: | - $ErrorActionPreference = "STOP" - Set-StrictMode -version 2.0 + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 $directCommit = $ENV:directCommit + $downloadLatest = $ENV:downloadLatest 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' + Write-Host "Running Update AL-Go System Files on a schedule. Setting DirectCommit and DownloadLatest to true" + $directCommit = 'true' + $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@PPPreview + uses: microsoft/AL-Go/Actions/CheckForUpdates@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell - parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} - token: ${{ env.ghTokenWorkflow }} - Update: Y + token: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).ghTokenWorkflow }} + downloadLatest: ${{ env.downloadLatest }} + update: 'Y' templateUrl: ${{ env.templateUrl }} directCommit: ${{ env.directCommit }} - name: Finalize the workflow if: always() - uses: microsoft/AL-Go-Actions/WorkflowPostProcess@PPPreview + uses: microsoft/AL-Go/Actions/WorkflowPostProcess@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 with: shell: powershell eventId: "DO0098" diff --git a/.github/workflows/_BuildALGoProject.yaml b/.github/workflows/_BuildALGoProject.yaml new file mode 100644 index 0000000..2fa8e68 --- /dev/null +++ b/.github/workflows/_BuildALGoProject.yaml @@ -0,0 +1,273 @@ +name: '_Build AL-Go project' + +run-name: 'Build ${{ inputs.project }}' + +on: + workflow_call: + inputs: + shell: + description: Shell in which you want to run the action (powershell or pwsh) + required: false + default: powershell + type: string + 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 }} + 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 + projectDependenciesJson: + description: Dependencies of the built project in compressed Json format + required: false + default: '{}' + type: string + buildMode: + 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 + 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 + type: boolean + default: false + publishArtifacts: + description: Flag indicating whether the artifacts should be published + type: boolean + default: false + artifactsNameSuffix: + description: Suffix to add to the artifacts names + required: false + default: '' + type: string + signArtifacts: + description: Flag indicating whether the apps should be signed + type: boolean + default: false + useArtifactCache: + description: Flag determining whether to use the Artifacts Cache + type: boolean + default: false + parentTelemetryScopeJson: + description: Specifies the telemetry scope for the telemetry signal + required: false + type: string + +permissions: + contents: read + actions: read + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + BuildALGoProject: + needs: [ ] + runs-on: ${{ fromJson(inputs.runsOn) }} + defaults: + run: + shell: ${{ inputs.shell }} + name: ${{ inputs.projectName }} (${{ inputs.buildMode }}) + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.checkoutRef }} + lfs: true + + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,doNotRunTests,artifact,generateDependencyArtifact + + - name: Read secrets + id: ReadSecrets + if: github.event_name != 'pull_request' + uses: microsoft/AL-Go/Actions/ReadSecrets@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ inputs.shell }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ inputs.secrets }},appDependencyProbingPathsSecrets' + + - name: Determine ArtifactUrl + uses: microsoft/AL-Go/Actions/DetermineArtifactUrl@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + id: determineArtifactUrl + with: + shell: ${{ inputs.shell }} + parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} + project: ${{ inputs.project }} + + - name: Cache Business Central Artifacts + if: env.useCompilerFolder == 'True' && inputs.useArtifactCache && env.artifactCacheKey + uses: actions/cache@v4 + with: + path: .artifactcache + key: ${{ env.artifactCacheKey }} + + - name: Download Project Dependencies + id: DownloadProjectDependencies + uses: microsoft/AL-Go/Actions/DownloadProjectDependencies@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + projectsDependenciesJson: ${{ inputs.projectDependenciesJson }} + baselineWorkflowRunId: ${{ inputs.baselineWorkflowRunId }} + + - name: Build + uses: microsoft/AL-Go/Actions/RunPipeline@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + BuildMode: ${{ inputs.buildMode }} + with: + shell: ${{ inputs.shell }} + parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} + artifact: ${{ env.artifact }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + installAppsJson: ${{ steps.DownloadProjectDependencies.outputs.DownloadedApps }} + installTestAppsJson: ${{ steps.DownloadProjectDependencies.outputs.DownloadedTestApps }} + + - name: Sign + if: inputs.signArtifacts && env.doNotSignApps == 'False' && env.keyVaultCodesignCertificateName != '' + id: sign + uses: microsoft/AL-Go/Actions/Sign@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + azureCredentialsJson: ${{ secrets.AZURE_CREDENTIALS }} + pathToFiles: '${{ inputs.project }}/.buildartifacts/Apps/*.app' + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + + - name: Calculate Artifact names + id: calculateArtifactsNames + uses: microsoft/AL-Go/Actions/CalculateArtifactNames@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + if: success() || failure() + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + suffix: ${{ inputs.artifactsNameSuffix }} + + - name: Upload thisbuild artifacts - apps + if: inputs.publishThisBuildArtifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - dependencies + if: inputs.publishThisBuildArtifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildDependenciesArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Dependencies/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: inputs.publishThisBuildArtifacts + uses: actions/upload-artifact@v4 + 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@v4 + if: inputs.publishArtifacts + with: + name: ${{ steps.calculateArtifactsNames.outputs.AppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + + - name: Publish artifacts - dependencies + uses: actions/upload-artifact@v4 + if: inputs.publishArtifacts && env.generateDependencyArtifact == 'True' + with: + name: ${{ steps.calculateArtifactsNames.outputs.DependenciesArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Dependencies/' + if-no-files-found: ignore + + - name: Publish artifacts - test apps + uses: actions/upload-artifact@v4 + if: inputs.publishArtifacts + with: + name: ${{ steps.calculateArtifactsNames.outputs.TestAppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + + - name: Publish artifacts - build output + uses: actions/upload-artifact@v4 + 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@v4 + 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@v4 + if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.TestResultsArtifactsName }} + path: '${{ inputs.project }}/TestResults.xml' + if-no-files-found: ignore + + - name: Publish artifacts - bcpt test results + uses: actions/upload-artifact@v4 + if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.BcptTestResultsArtifactsName }} + path: '${{ inputs.project }}/bcptTestResults.json' + if-no-files-found: ignore + + - name: Analyze Test Results + id: analyzeTestResults + if: (success() || failure()) && env.doNotRunTests == 'False' + uses: microsoft/AL-Go/Actions/AnalyzeTests@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ inputs.shell }} + parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} + project: ${{ inputs.project }} + + - name: Cleanup + if: always() + uses: microsoft/AL-Go/Actions/PipelineCleanup@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ inputs.shell }} + parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} + project: ${{ inputs.project }} diff --git a/.github/workflows/_BuildPowerPlatformSolution.yaml b/.github/workflows/_BuildPowerPlatformSolution.yaml new file mode 100644 index 0000000..4981244 --- /dev/null +++ b/.github/workflows/_BuildPowerPlatformSolution.yaml @@ -0,0 +1,96 @@ +name: '_Build PowerPlatform Solution' + +run-name: 'Build PowerPlatform Solution' + +on: + workflow_call: + inputs: + shell: + description: Shell in which you want to run the action (powershell or pwsh) + required: false + default: powershell + type: string + 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 }} + 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 + publishArtifacts: + description: Flag indicating whether the artifacts should be published + type: boolean + default: false + artifactsNameSuffix: + description: Suffix to add to the artifacts names + required: false + default: '' + type: string + parentTelemetryScopeJson: + description: Specifies the telemetry scope for the telemetry signal + required: false + type: string + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Build: + needs: [ ] + runs-on: ${{ fromJson(inputs.runsOn) }} + defaults: + run: + shell: ${{ inputs.shell }} + name: '${{ inputs.projectName }}' + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.checkoutRef }} + lfs: true + + - name: Read settings + uses: microsoft/AL-Go/Actions/ReadSettings@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + get: type,powerPlatformSolutionFolder,appRevision,appBuild + + - name: Build + uses: microsoft/AL-Go/Actions/BuildPowerPlatform@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + with: + shell: ${{ inputs.shell }} + solutionFolder: ${{ inputs.project }} + outputFolder: ${{ inputs.project }}/.buildartifacts/_PowerPlatformSolution/ + outputFileName: ${{ inputs.project }} + appRevision: ${{ env.appRevision }} + appBuild: ${{ env.appBuild }} + + - name: Calculate Artifact names + id: calculateArtifactsNames + uses: microsoft/AL-Go/Actions/CalculateArtifactNames@6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17 + if: success() || failure() + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: 'default' + suffix: ${{ inputs.artifactsNameSuffix }} + + - name: Publish artifacts - Power Platform Solution + uses: actions/upload-artifact@v4 + if: inputs.publishArtifacts + with: + name: ${{ steps.calculateArtifactsNames.outputs.PowerPlatformSolutionArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/_PowerPlatformSolution/' + if-no-files-found: ignore diff --git a/ALApp/.AL-Go/cloudDevEnv.ps1 b/ALApp/.AL-Go/cloudDevEnv.ps1 index a85ac33..0fd9843 100644 --- a/ALApp/.AL-Go/cloudDevEnv.ps1 +++ b/ALApp/.AL-Go/cloudDevEnv.ps1 @@ -6,42 +6,45 @@ 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 { +Clear-Host +Write-Host +Write-Host -ForegroundColor Yellow @' + _____ _ _ _____ ______ + / ____| | | | | __ \ | ____| + | | | | ___ _ _ __| | | | | | _____ __ |__ _ ____ __ + | | | |/ _ \| | | |/ _` | | | | |/ _ \ \ / / __| | '_ \ \ / / + | |____| | (_) | |_| | (_| | | |__| | __/\ V /| |____| | | \ V / + \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ + +'@ + $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" +$GitHubHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/Github-Helper.psm1' +Write-Host "Downloading GitHub Helper module from $GitHubHelperUrl" $GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" +$webClient.DownloadFile($GitHubHelperUrl, $GitHubHelperPath) +$ALGoHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/AL-Go-Helper.ps1' +Write-Host "Downloading AL-Go Helper script from $ALGoHelperUrl" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/AL-Go-Helper.ps1', $ALGoHelperPath) +$webClient.DownloadFile($ALGoHelperUrl, $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 / - \_____|_|\___/ \__,_|\__,_| |_____/ \___| \_/ |______|_| |_|\_/ - -'@ - 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 +55,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 +79,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/ALApp/.AL-Go/localDevEnv.ps1 b/ALApp/.AL-Go/localDevEnv.ps1 index 4c1a68b..d771670 100644 --- a/ALApp/.AL-Go/localDevEnv.ps1 +++ b/ALApp/.AL-Go/localDevEnv.ps1 @@ -5,26 +5,41 @@ # 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 try { +Clear-Host +Write-Host +Write-Host -ForegroundColor Yellow @' + _ _ _____ ______ + | | | | | __ \ | ____| + | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ + | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / + | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / + |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ + +'@ + $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" +$GitHubHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/Github-Helper.psm1' +Write-Host "Downloading GitHub Helper module from $GitHubHelperUrl" $GitHubHelperPath = "$([System.IO.Path]::GetTempFileName()).psm1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/Github-Helper.psm1', $GitHubHelperPath) -Write-Host "Downloading AL-Go Helper script" +$webClient.DownloadFile($GitHubHelperUrl, $GitHubHelperPath) +$ALGoHelperUrl = 'https://raw.githubusercontent.com/microsoft/AL-Go/6a9ef0c91e5b54d0fd3abb3d4495417a1db28f17/Actions/AL-Go-Helper.ps1' +Write-Host "Downloading AL-Go Helper script from $ALGoHelperUrl" $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" -$webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/PPPreview/AL-Go-Helper.ps1', $ALGoHelperPath) +$webClient.DownloadFile($ALGoHelperUrl, $ALGoHelperPath) Import-Module $GitHubHelperPath . $ALGoHelperPath -local @@ -32,19 +47,8 @@ Import-Module $GitHubHelperPath $baseFolder = GetBaseFolder -folder $PSScriptRoot $project = GetProject -baseFolder $baseFolder -projectALGoFolder $PSScriptRoot -Clear-Host -Write-Host -Write-Host -ForegroundColor Yellow @' - _ _ _____ ______ - | | | | | __ \ | ____| - | | ___ ___ __ _| | | | | | _____ __ |__ _ ____ __ - | | / _ \ / __/ _` | | | | | |/ _ \ \ / / __| | '_ \ \ / / - | |____ (_) | (__ (_| | | | |__| | __/\ V /| |____| | | \ V / - |______\___/ \___\__,_|_| |_____/ \___| \_/ |______|_| |_|\_/ - -'@ - 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 +59,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) @@ -132,7 +136,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)"