diff --git a/.github/AL-Go-Settings.json b/.github/AL-Go-Settings.json new file mode 100644 index 0000000..17ac5bb --- /dev/null +++ b/.github/AL-Go-Settings.json @@ -0,0 +1,4 @@ +{ + "type": "PTE", + "templateUrl": "https://github.com/microsoft/AL-Go-PTE@main" +} diff --git a/.github/RELEASENOTES.copy.md b/.github/RELEASENOTES.copy.md new file mode 100644 index 0000000..0ec44dc --- /dev/null +++ b/.github/RELEASENOTES.copy.md @@ -0,0 +1,482 @@ +## 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 + +Issue #446 Wrong NewLine character in Release Notes +Issue #453 DeliverToStorage - override fails reading secrets +Issue #434 Use gh auth token to get authentication token instead of gh auth status +Issue #501 The Create New App action will now use 22.0.0.0 as default application reference and include NoImplicitwith feature. + + +### New behavior + +The following workflows: + +- Create New App +- Create New Test App +- Create New Performance Test App +- Increment Version Number +- Add Existing App +- Create Online Development Environment + +All these actions now uses the selected branch in the **Run workflow** dialog as the target for the Pull Request or Direct COMMIT. + +### 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. +- `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. + +### License File + +With the changes to the CRONUS license in Business Central version 22, that license can in most cases be used as a developer license for AppSource Apps and it is no longer mandatory to specify a license file in AppSource App repositories. +Obviously, if you build and test your app for Business Central versions prior to 21, it will fail if you don't specify a licenseFileUrl secret. + +## v3.0 + +### **NOTE:** When upgrading to this version +When upgrading to this version form earlier versions of AL-Go for GitHub, you will need to run the _Update AL-Go System Files_ workflow twice if you have the `useProjectDependencies` setting set to _true_. + +### Publish to unknown environment +You can now run the **Publish To Environment** workflow without creating the environment in GitHub or settings up-front, just by specifying the name of a single environment in the Environment Name when running the workflow. +Subsequently, if an AuthContext secret hasn't been created for this environment, the Device Code flow authentication will be initiated from the Publish To Environment workflow and you can publish to the new environment without ever creating a secret. +Open Workflow details to get the device Code for authentication in the job summary for the initialize job. + +### Create Online Dev. Environment +When running the **Create Online Dev. Environment** workflow without having the _adminCenterApiCredentials_ secret created, the workflow will intiate the deviceCode flow and allow you to authenticate to the Business Central Admin Center. +Open Workflow details to get the device Code for authentication in the job summary for the initialize job. + +### Issues +- Issue #391 Create release action - CreateReleaseBranch error +- Issue 434 Building local DevEnv, downloading dependencies: Authentication fails when using "gh auth status" + +### Changes to Pull Request Process +In v2.4 and earlier, the PullRequestHandler would trigger the CI/CD workflow to run the PR build. +Now, the PullRequestHandler will perform the build and the CI/CD workflow is only run on push (or manual dispatch) and will perform a complete build. + +### Build modes per project +Build modes can now be specified per project + +### New Actions +- **DetermineProjectsToBuild** is used to determine which projects to build in PullRequestHandler, CI/CD, Current, NextMinor and NextMajor workflows. +- **CalculateArtifactNames** is used to calculate artifact names in PullRequestHandler, CI/CD, Current, NextMinor and NextMajor workflows. +- **VerifyPRChanges** is used to verify whether a PR contains changes, which are not allowed from a fork. + +## v2.4 + +### Issues +- Issue #171 create a workspace file when creating a project +- Issue #356 Publish to AppSource fails in multi project repo +- Issue #358 Publish To Environment Action stopped working in v2.3 +- Issue #362 Support for EnableTaskScheduler +- Issue #360 Creating a release and deploying from a release branch +- Issue #371 'No previous release found' for builds on release branches +- Issue #376 CICD jobs that are triggered by the pull request trigger run directly to an error if title contains quotes + +### Release Branches +**NOTE:** Release Branches are now only named after major.minor if the patch value is 0 in the release tag (which must be semver compatible) + +This version contains a number of bug fixes to release branches, to ensure that the recommended branching strategy is fully supported. Bugs fixed includes: +- Release branches was named after the full tag (1.0.0), even though subsequent hotfixes released from this branch would be 1.0.x +- Release branches named 1.0 wasn't picked up as a release branch +- Release notes contained the wrong changelog +- The previous release was always set to be the first release from a release branch +- SemVerStr could not have 5 segments after the dash +- Release was created on the right SHA, but the release branch was created on the wrong SHA + +Recommended branching strategy: + +![Branching Strategy](https://raw.githubusercontent.com/microsoft/AL-Go/main/Scenarios/images/branchingstrategy.png) + +### New Settings +New Project setting: EnableTaskScheduler in container executing tests and when setting up local development environment + +### Support for GitHub variables: ALGoOrgSettings and ALGoRepoSettings +Recently, GitHub added support for variables, which you can define on your organization or your repository. +AL-Go now supports that you can define a GitHub variable called ALGoOrgSettings, which will work for all repositories (with access to the variable) +Org Settings will be applied before Repo settings and local repository settings files will override values in the org settings +You can also define a variable called ALGoRepoSettings on the repository, which will be applied after reading the Repo Settings file in the repo +Example for usage could be setup of branching strategies, versioning or an appDependencyProbingPaths to repositories which all repositories share. +appDependencyProbingPaths from settings variables are merged together with appDependencyProbingPaths defined in repositories + +### Refactoring and tests +ReadSettings has been refactored to allow organization wide settings to be added as well. CI Tests have been added to cover ReadSettings. + +## v2.3 + +### Issues +- Issue #312 Branching enhancements +- Issue #229 Create Release action tags wrong commit +- Issue #283 Create Release workflow uses deprecated actions +- Issue #319 Support for AssignPremiumPlan +- Issue #328 Allow multiple projects in AppSource App repo +- Issue #344 Deliver To AppSource on finding app.json for the app +- Issue #345 LocalDevEnv.ps1 can't Dowload the file license file + +### New Settings +New Project setting: AssignPremiumPlan on user in container executing tests and when setting up local development environment +New Repo setting: unusedALGoSystemFiles is an array of AL-Go System Files, which won't be updated during Update AL-Go System Files. They will instead be removed. Use with care, as this can break the AL-Go for GitHub functionality and potentially leave your repo no longer functional. + +### Build modes support +AL-Go projects can now be built in different modes, by specifying the _buildModes_ setting in AL-Go-Settings.json. Read more about build modes in the [Basic Repository settings](https://github.com/microsoft/AL-Go/blob/main/Scenarios/settings.md#basic-repository-settings). + +### LocalDevEnv / CloudDevEnv +With the support for PowerShell 7 in BcContainerHelper, the scripts LocalDevEnv and CloudDevEnv (placed in the .AL-Go folder) for creating development environments have been modified to run inside VS Code instead of spawning a new powershell 5.1 session. + +### Continuous Delivery +Continuous Delivery can now run from other branches than main. By specifying a property called branches, containing an array of branches in the deliveryContext json construct, the artifacts generated from this branch are also delivered. The branch specification can include wildcards (like release/*). Default is main, i.e. no changes to functionality. + +### Continuous Deployment +Continuous Deployment can now run from other branches than main. By creating a repo setting (.github/AL-Go-Settings.json) called **`-Branches`**, which is an array of branches, which will deploy the generated artifacts to this environment. The branch specification can include wildcards (like release/*), although this probably won't be used a lot in continuous deployment. Default is main, i.e. no changes to functionality. + +### Create Release +When locating artifacts for the various projects, the SHA used to build the artifact is used for the release tag +If all projects are not available with the same SHA, this error is thrown: **The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release.** +There is no longer a hard dependency on the main branch name from Create Release. + +### AL-Go Tests +Some unit tests have been added and AL-Go unit tests can now be run directly from VS Code. +Another set of end to end tests have also been added and in the documentation on contributing to AL-Go, you can see how to run these in a local fork or from VS Code. + +### LF, UTF8 and JSON +GitHub natively uses LF as line seperator in source files. +In earlier versions of AL-Go for GitHub, many scripts and actions would use CRLF and convert back and forth. Some files were written with UTF8 BOM (Byte Order Mark), other files without and JSON formatting was done using PowerShell 5.1 (which is different from PowerShell 7). +In the latest version, we always use LF as line seperator, UTF8 without BOM and JSON files are written using PowerShell 7. If you have self-hosted runners, you need to ensure that PS7 is installed to make this work. + +### Experimental Support +Setting the repo setting "shell" to "pwsh", followed by running Update AL-Go System Files, will cause all PowerShell code to be run using PowerShell 7 instead of PowerShell 5. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues +Setting the repo setting "runs-on" to "Ubuntu-Latest", followed by running Update AL-Go System Files, will cause all non-build jobs to run using Linux. This functionality is experimental. Please report any issues at https://github.com/microsoft/AL-Go/issues + +## v2.2 + +### Enhancements +- Container Event log is added as a build artifact if builds or tests are failing + +### Issues +- Issue #280 Overflow error when test result summary was too big +- Issue #282, 292 AL-Go for GitHub causes GitHub to issue warnings +- Issue #273 Potential security issue in Pull Request Handler in Open Source repositories +- Issue #303 PullRequestHandler fails on added files +- Issue #299 Multi-project repositories build all projects on Pull Requests +- Issue #291 Issues with new Pull Request Handler +- Issue #287 AL-Go pipeline fails in ReadSettings step + +### Changes +- VersioningStrategy 1 is no longer supported. GITHUB_ID has changed behavior (Issue #277) + +## v2.1 + +### Issues +- Issue #233 AL-Go for GitHub causes GitHub to issue warnings +- Issue #244 Give error if AZURE_CREDENTIALS contains line breaks + +### Changes +- New workflow: PullRequestHandler to handle all Pull Requests and pass control safely to CI/CD +- Changes to yaml files, PowerShell scripts and codeowners files are not permitted from fork Pull Requests +- Test Results summary (and failed tests) are now displayed directly in the CI/CD workflow and in the Pull Request Check + +### Continuous Delivery +- Proof Of Concept Delivery to GitHub Packages and Nuget + +## v2.0 + +### Issues +- Issue #143 Commit Message for **Increment Version Number** workflow +- Issue #160 Create local DevEnv aith appDependencyProbingPaths +- Issue #156 Versioningstrategy 2 doesn't use 24h format +- Issue #155 Initial Add existing app fails with "Cannot find path" +- Issue #152 Error when loading dependencies from releases +- Issue #168 Regression in preview fixed +- Issue #189 Warnings: Resource not accessible by integration +- Issue #190 PublishToEnvironment is not working with AL-Go-PTE@preview +- Issue #186 AL-GO build fails for multi-project repository when there's nothing to build +- When you have GitHub pages enabled, AL-Go for GitHub would try to publish to github_pages environment +- Special characters wasn't supported in parameters to GitHub actions (Create New App etc.) + +### Continuous Delivery +- Added new GitHub Action "Deliver" to deliver build output to Storage or AppSource +- Refactor CI/CD and Release workflows to use new deliver action +- Custom delivery supported by creating scripts with the naming convention DeliverTo*.ps1 in the .github folder + +### AppSource Apps +- New workflow: Publish to AppSource +- Continuous Delivery to AppSource validation supported + +### Settings +- New Repo setting: CICDPushBranches can be specified as an array of branches, which triggers a CI/CD workflow on commit. Default is main', release/\*, feature/\* +- New Repo setting: CICDPullRequestBranches can be specified as an array of branches, which triggers a CI/CD workflow on pull request. Default is main +- New Repo setting: CICDSchedule can specify a CRONTab on when you want to run CI/CD on a schedule. Note that this will disable Push and Pull Request triggers unless specified specifically using CICDPushBranches or CICDPullRequestBranches +- New Repo setting: UpdateGitHubGoSystemFilesSchedule can specify a CRONTab on when you want to Update AL-Go System Files. Note that when running on a schedule, update AL-Go system files will perfom a direct commit and not create a pull request. +- New project Setting: AppSourceContext should be a compressed json structure containing authContext for submitting to AppSource. The BcContainerHelperFunction New-ALGoAppSourceContext will help you create this structure. +- New project Setting: AppSourceContinuousDelivery. Set this to true in enable continuous delivery for this project to AppSource. This requires AppSourceContext and AppSourceProductId to be set as well +- New project Setting: AppSourceProductId should be set to the product Id of this project in AppSource +- New project Setting: AppSourceMainAppFolder. If you have multiple appFolders, this is the folder name of the main app to submit to AppSource. + +### All workflows +- Support 2 folder levels projects (apps\w1, apps\dk etc.) +- Better error messages for if an error occurs within an action +- Special characters are now supported in secrets +- Initial support for agents running inside containers on a host +- Optimized workflows to have fewer jobs + +### Update AL-Go System Files Workflow +- workflow now displays the currently used template URL when selecting the Run Workflow action + +### CI/CD workflow +- Better detection of changed projects +- appDependencyProbingPaths did not support multiple projects in the same repository for latestBuild dependencies +- appDependencyProbingPaths with release=latestBuild only considered the last 30 artifacts +- Use mutex around ReadSecrets to ensure that multiple agents on the same host doesn't clash +- Add lfs when checking out files for CI/CD to support checking in dependencies +- Continue on error with Deploy and Deliver + +### CI/CD and Publish To New Environment +- Base functionality for selecting a specific GitHub runner for an environment +- Include dependencies artifacts when deploying (if generateDependencyArtifacts is true) + +### localDevEnv.ps1 and cloudDevEnv.ps1 +- Display clear error message if something goes wrong + +## v1.5 + +### Issues +- Issue #100 - Add more resilience to localDevEnv.ps1 and cloudDevEnv.ps1 +- Issue #131 - Special characters are not allowed in secrets + +### All workflows +- During initialize, all AL-Go settings files are now checked for validity and reported correctly +- During initialize, the version number of AL-Go for GitHub is printed in large letters (incl. preview or dev.) + +### New workflow: Create new Performance Test App +- Create BCPT Test app and add to bcptTestFolders to run bcpt Tests in workflows (set doNotRunBcptTests in workflow settings for workflows where you do NOT want this) + +### Update AL-Go System Files Workflow +- Include release notes of new version in the description of the PR (and in the workflow output) + +### CI/CD workflow +- Apps are not signed when the workflow is running as a Pull Request validation +- if a secret called applicationInsightsConnectionString exists, then the value of that will be used as ApplicationInsightsConnectionString for the app + +### Increment Version Number Workflow +- Bugfix: increment all apps using f.ex. +0.1 would fail. + +### Environments +- Add suport for EnvironmentName redirection by adding an Environment Secret under the environment or a repo secret called \_EnvironmentName with the actual environment name. +- No default environment name on Publish To Environment +- For multi-project repositories, you can specify an environment secret called Projects or a repo setting called \_Projects, containing the projects you want to deploy to this environment. + +### Settings +- New setting: **runs-on** to allow modifying runs-on for all jobs (requires Update AL-Go System files after changing the setting) +- New setting: **DoNotSignApps** - setting this to true causes signing of the app to be skipped +- New setting: **DoNotPublishApps** - setting this to true causes the workflow to skip publishing, upgrading and testing the app to improve performance. +- New setting: **ConditionalSettings** to allow to use different settings for specific branches. Example: +``` + "ConditionalSettings": [ + { + "branches": [ + "feature/*" + ], + "settings": { + "doNotPublishApps": true, + "doNotSignApps": true + } + } + ] +``` +- Default **BcContainerHelperVersion** is now based on AL-Go version. Preview AL-Go selects preview bcContainerHelper, normal selects latest. +- New Setting: **bcptTestFolders** contains folders with BCPT tests, which will run in all build workflows +- New Setting: set **doNotRunBcptTest** to true (in workflow specific settings file?) to avoid running BCPT tests +- New Setting: set **obsoleteTagMinAllowedMajorMinor** to enable appsource cop to validate your app against future changes (AS0105). This setting will become auto-calculated in Test Current, Test Next Minor and Test Next Major later. + +## v1.4 + +### All workflows +- Add requested permissions to avoid dependency on user/org defaults being too permissive + +### Update AL-Go System Files Workflow +- Default host to https://github.com/ (you can enter **myaccount/AL-Go-PTE@main** to change template) +- Support for "just" changing branch (ex. **\@Preview**) to shift to the preview version + +### CI/CD Workflow +- Support for feature branches (naming **feature/\***) - CI/CD workflow will run, but not generate artifacts nor deploy to QA + +### Create Release Workflow +- Support for release branches +- Force Semver format on release tags +- Add support for creating release branches on release (naming release/\*) +- Add support for incrementing main branch after release + +### Increment version number workflow +- Add support for incremental (and absolute) version number change + +### Environments +- Support environmentName redirection in CI/CD and Publish To Environments workflows +- If the name in Environments or environments settings doesn't match the actual environment name, +- You can add a secret called EnvironmentName under the environment (or \_ENVIRONMENTNAME globally) + + +## v1.3 + +### Issues +- Issue #90 - Environments did not work. Secrets for environments specified in settings can now be **\_AUTHCONTEXT** + +### CI/CD Workflow +- Give warning instead of error If no artifacts are found in **appDependencyProbingPaths** + +## v1.2 + +### Issues +- Issue #90 - Environments did not work. Environments (even if only defined in the settings file) did not work for private repositories if you didn't have a premium subscription. + +### Local scripts +- **LocalDevEnv.ps1** and ***CloudDevEnv.ps1** will now spawn a new PowerShell window as admin instead of running inside VS Code. Normally people doesn't run VS Code as administrator, and they shouldn't have to. Furthermore, I have seen a some people having problems when running these scripts inside VS Code. + + +## v1.1 + +### Settings +- New Repo Setting: **GenerateDependencyArtifact** (default **false**). When true, CI/CD pipeline generates an artifact with the external dependencies used for building the apps in this repo. +- New Repo Setting: **UpdateDependencies** (default **false**). When true, the default artifact for building the apps in this repo is not the latest available artifacts for this country, but instead the first compatible version (after calculating application dependencies). It is recommended to run Test Current, Test NextMinor and Test NextMajor in order to test your app against current and future builds. + +### CI/CD Workflow +- New Artifact: BuildOutput.txt. All compiler warnings and errors are emitted to this file to make it easier to investigate compiler errors and build a better UI for build errors and test results going forward. +- TestResults artifact name to include repo version number and workflow name (for Current, NextMinor and NextMajor) +- Default dependency version in appDependencyProbingPaths setting used is now latest Release instead of LatestBuild diff --git a/.github/Test Current.settings.json b/.github/Test Current.settings.json new file mode 100644 index 0000000..afb3d65 --- /dev/null +++ b/.github/Test Current.settings.json @@ -0,0 +1,5 @@ +{ + "artifact": "////latest", + "cacheImageName": "", + "versioningStrategy": 15 +} diff --git a/.github/Test Next Major.settings.json b/.github/Test Next Major.settings.json new file mode 100644 index 0000000..1fc329d --- /dev/null +++ b/.github/Test Next Major.settings.json @@ -0,0 +1,5 @@ +{ + "artifact": "////nextmajor", + "cacheImageName": "", + "versioningStrategy": 15 +} diff --git a/.github/Test Next Minor.settings.json b/.github/Test Next Minor.settings.json new file mode 100644 index 0000000..127bce7 --- /dev/null +++ b/.github/Test Next Minor.settings.json @@ -0,0 +1,5 @@ +{ + "artifact": "////nextminor", + "cacheImageName": "", + "versioningStrategy": 15 +} diff --git a/.github/workflows/AddExistingAppOrTestApp.yaml b/.github/workflows/AddExistingAppOrTestApp.yaml new file mode 100644 index 0000000..112f07c --- /dev/null +++ b/.github/workflows/AddExistingAppOrTestApp.yaml @@ -0,0 +1,79 @@ +name: 'Add existing app or test app' + +run-name: "Add existing app or test app in [${{ github.ref_name }}]" + +on: + workflow_dispatch: + inputs: + project: + description: Project name if the repository is setup for multiple projects + required: false + default: '.' + url: + description: Direct Download Url of .app or .zip file + required: true + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: 'N' + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + AddExistingAppOrTestApp: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0090" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + + - name: Add existing app + uses: microsoft/AL-Go-Actions/AddExistingApp@v4.0 + with: + shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + project: ${{ github.event.inputs.project }} + url: ${{ github.event.inputs.url }} + directCommit: ${{ github.event.inputs.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0090" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CICD.yaml b/.github/workflows/CICD.yaml new file mode 100644 index 0000000..126a500 --- /dev/null +++ b/.github/workflows/CICD.yaml @@ -0,0 +1,277 @@ +name: ' CI/CD' + +on: + workflow_dispatch: + push: + paths-ignore: + - '**.md' + - '.github/workflows/*.yaml' + - '!.github/workflows/CICD.yaml' + branches: [ 'main', 'release/*', 'feature/*' ] + + pull_request: + paths-ignore: + - '**.md' + - '.github/workflows/*.yaml' + - '!.github/workflows/CICD.yaml' + branches: [ 'main', 'release/*', 'feature/*' ] + +defaults: + run: + shell: powershell + +permissions: + contents: read + actions: read + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Initialization: + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + environmentsMatrixJson: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentsMatrixJson }} + environmentCount: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentCount }} + deploymentEnvironmentsJson: ${{ steps.DetermineDeploymentEnvironments.outputs.DeploymentEnvironmentsJson }} + deliveryTargetsJson: ${{ steps.DetermineDeliveryTargets.outputs.DeliveryTargetsJson }} + 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: Checkout + uses: actions/checkout@v3 + with: + lfs: true + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0091" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + get: type + + - 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@v4.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + - name: Determine Delivery Target Secrets + id: DetermineDeliveryTargetSecrets + uses: microsoft/AL-Go-Actions/DetermineDeliveryTargets@v4.0 + with: + shell: powershell + projectsJson: '${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' + checkContextSecrets: 'N' + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: ${{ steps.DetermineDeliveryTargetSecrets.outputs.ContextSecrets }} + + - name: Determine Delivery Targets + id: DetermineDeliveryTargets + uses: microsoft/AL-Go-Actions/DetermineDeliveryTargets@v4.0 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + projectsJson: '${{ steps.determineProjectsToBuild.outputs.ProjectsJson }}' + checkContextSecrets: 'Y' + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go-Actions/DetermineDeploymentEnvironments@v4.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + shell: powershell + getEnvironments: '*' + type: 'CD' + + CheckForUpdates: + runs-on: [ windows-latest ] + needs: [ Initialization ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + get: templateUrl + + - name: Check for updates to AL-Go system files + uses: microsoft/AL-Go-Actions/CheckForUpdates@v4.0 + with: + shell: powershell + parentTelemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} + templateUrl: ${{ env.templateUrl }} + + BuildJS: + name: Build and pack JavaScript app + steps: + - name: npm build and test + uses: ./.github/workflows/nodejs_webpack.yaml + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: graph_view_dist + path: ./GraphViewControl/Scripts/dist + + Build: + needs: [ Initialization, BuildJS ] + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 + strategy: + matrix: + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} + fail-fast: false + 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/') || needs.Initialization.outputs.deliveryTargetsJson != '[]' || needs.Initialization.outputs.environmentCount > 0 }} + signArtifacts: true + useArtifactCache: true + + Deploy: + needs: [ Initialization, Build ] + if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.environmentCount > 0 + strategy: ${{ fromJson(needs.Initialization.outputs.environmentsMatrixJson) }} + runs-on: ${{ fromJson(matrix.os) }} + name: Deploy to ${{ matrix.environment }} + environment: + name: ${{ matrix.environment }} + url: ${{ steps.Deploy.outputs.environmentUrl }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: '.artifacts' + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: EnvName + id: envName + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $envName = '${{ matrix.environment }}'.split(' ')[0] + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + 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: Deploy + id: Deploy + uses: microsoft/AL-Go-Actions/Deploy@v4.0 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + environmentName: ${{ matrix.environment }} + artifacts: '.artifacts' + type: 'CD' + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} + + Deliver: + needs: [ Initialization, Build ] + if: always() && needs.Build.result == 'Success' && needs.Initialization.outputs.deliveryTargetsJson != '[]' + strategy: + matrix: + 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 + + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + path: '.artifacts' + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ matrix.deliveryTarget }}Context' + + - name: Deliver + uses: microsoft/AL-Go-Actions/Deliver@v4.0 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + type: 'CD' + projects: ${{ needs.Initialization.outputs.projects }} + deliveryTarget: ${{ matrix.deliveryTarget }} + artifacts: '.artifacts' + + PostProcess: + if: (!cancelled()) + runs-on: [ windows-latest ] + needs: [ Initialization, Build, Deploy, Deliver ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0091" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateApp.yaml b/.github/workflows/CreateApp.yaml new file mode 100644 index 0000000..97c3285 --- /dev/null +++ b/.github/workflows/CreateApp.yaml @@ -0,0 +1,94 @@ +name: 'Create a new app' + +run-name: "Create a new app in [${{ github.ref_name }}]" + +on: + workflow_dispatch: + inputs: + project: + description: Project name if the repository is setup for multiple projects + required: false + default: '.' + name: + description: Name + required: true + publisher: + description: Publisher + required: true + idrange: + description: ID range (from..to) + required: true + sampleCode: + description: Include Sample code (Y/N) + required: false + default: 'Y' + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: "N" + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + CreateApp: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0092" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + get: type + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + + - name: Creating a new app + uses: microsoft/AL-Go-Actions/CreateApp@v4.0 + with: + shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + project: ${{ github.event.inputs.project }} + type: ${{ env.type }} + name: ${{ github.event.inputs.name }} + publisher: ${{ github.event.inputs.publisher }} + idrange: ${{ github.event.inputs.idrange }} + sampleCode: ${{ github.event.inputs.sampleCode }} + directCommit: ${{ github.event.inputs.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0092" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml new file mode 100644 index 0000000..391d83f --- /dev/null +++ b/.github/workflows/CreateOnlineDevelopmentEnvironment.yaml @@ -0,0 +1,149 @@ +name: ' Create Online Dev. Environment' + +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' + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: 'N' + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Initialization: + 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: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0093" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'adminCenterApiCredentials' + + - name: Check AdminCenterApiCredentials / Initiate Device Login (open to see code) + id: authenticate + run: | + $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/v4.0/AL-Go-Helper.ps1', $ALGoHelperPath) + . $ALGoHelperPath + DownloadAndImportBcContainerHelper + $authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0)) + 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: ${{ fromJson(needs.Initialization.outputs.githubRunner) }} + defaults: + run: + shell: ${{ needs.Initialization.outputs.githubRunnerShell }} + name: Create Development Environment + needs: [ Initialization ] + env: + deviceCode: ${{ needs.Initialization.outputs.deviceCode }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + 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)""}")) + } + 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@v4.0 + with: + shell: powershell + 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: ${{ steps.SetAdminCenterApiCredentials.outputs.adminCenterApiCredentials }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0093" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreatePerformanceTestApp.yaml b/.github/workflows/CreatePerformanceTestApp.yaml new file mode 100644 index 0000000..5f49f87 --- /dev/null +++ b/.github/workflows/CreatePerformanceTestApp.yaml @@ -0,0 +1,100 @@ +name: 'Create a new performance test app' + +run-name: "Create a new performance test app in [${{ github.ref_name }}]" + +on: + workflow_dispatch: + inputs: + project: + description: Project name if the repository is setup for multiple projects + required: false + default: '.' + name: + description: Name + required: true + default: '.PerformanceTest' + publisher: + description: Publisher + required: true + idrange: + description: ID range + required: true + default: '50000..99999' + sampleCode: + description: Include Sample code (Y/N) + required: false + default: 'Y' + sampleSuite: + description: Include Sample BCPT Suite (Y/N) + required: false + default: 'Y' + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: 'N' + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + CreatePerformanceTestApp: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0102" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + 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@v4.0 + with: + shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + project: ${{ github.event.inputs.project }} + type: 'Performance Test App' + name: ${{ github.event.inputs.name }} + publisher: ${{ github.event.inputs.publisher }} + idrange: ${{ github.event.inputs.idrange }} + sampleCode: ${{ github.event.inputs.sampleCode }} + sampleSuite: ${{ github.event.inputs.sampleSuite }} + directCommit: ${{ github.event.inputs.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0102" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateRelease.yaml b/.github/workflows/CreateRelease.yaml new file mode 100644 index 0000000..fc5e855 --- /dev/null +++ b/.github/workflows/CreateRelease.yaml @@ -0,0 +1,348 @@ +name: ' Create release' + +on: + workflow_dispatch: + inputs: + appVersion: + description: App version to promote to release (default is latest) + required: false + default: 'latest' + name: + description: Name of this release + required: true + default: '' + tag: + description: Tag of this release (needs to be semantic version string https://semver.org, ex. 1.0.0) + required: true + default: '' + prerelease: + description: Prerelease (Y/N) + required: false + default: 'N' + draft: + description: Draft (Y/N) + required: false + default: 'N' + createReleaseBranch: + description: Create Release Branch (Y/N) + required: false + default: 'N' + 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' + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + actions: read + +concurrency: release + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + CreateRelease: + 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 }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0094" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + get: templateUrl,repoName + + - name: Determine Projects + id: determineProjects + uses: microsoft/AL-Go-Actions/DetermineProjectsToBuild@v4.0 + with: + shell: powershell + + - name: Check for updates to AL-Go system files + uses: microsoft/AL-Go-Actions/CheckForUpdates@v4.0 + with: + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + templateUrl: ${{ env.templateUrl }} + + - name: Analyze Artifacts + id: analyzeartifacts + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $projects = '${{ steps.determineProjects.outputs.ProjectsJson }}' | ConvertFrom-Json + Write-Host "projects:" + $projects | ForEach-Object { Write-Host "- $_" } + $include = @() + $sha = '' + $allArtifacts = @() + $page = 1 + $headers = @{ + "Authorization" = "token ${{ github.token }}" + "X-GitHub-Api-Version" = "2022-11-28" + "Accept" = "application/vnd.github+json" + } + do { + $repoArtifacts = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/actions/artifacts?per_page=100&page=$page" | ConvertFrom-Json + $allArtifacts += $repoArtifacts.Artifacts | Where-Object { !$_.expired } + $page++ + } + while ($repoArtifacts.Artifacts.Count -gt 0) + Write-Host "Repo Artifacts count: $($repoArtifacts.total_count)" + Write-Host "Downloaded Artifacts count: $($allArtifacts.Count)" + $projects | ForEach-Object { + $thisProject = $_ + if ($thisProject -and ($thisProject -ne '.')) { + $project = $thisProject.Replace('\','_').Replace('/','_') + } + else { + $project = $env:repoName + } + $refname = "$ENV:GITHUB_REF_NAME".Replace('/','_') + Write-Host "Analyzing artifacts for project $project" + $appVersion = '${{ github.event.inputs.appVersion }}' + if ($appVersion -eq "latest") { + Write-Host "Grab latest" + $artifact = $allArtifacts | Where-Object { $_.name -like "$project-$refname-Apps-*" } | Select-Object -First 1 + } + else { + Write-Host "Search for $project-$refname-Apps-$appVersion" + $artifact = $allArtifacts | Where-Object { $_.name -eq "$project-$refname-Apps-$appVersion" } | Select-Object -First 1 + } + if ($artifact) { + $artifactsVersion = $artifact.name.SubString($artifact.name.LastIndexOf('-Apps-')+6) + } + else { + Write-Host "::Error::No artifacts found for this project" + exit 1 + } + if ($sha) { + if ($artifact.workflow_run.head_sha -ne $sha) { + Write-Host "::Error::The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release." + throw "The build selected for release doesn't contain all projects. Please rebuild all projects by manually running the CI/CD workflow and recreate the release." + } + } + else { + $sha = $artifact.workflow_run.head_sha + } + + $allArtifacts | Where-Object { ($_.name -like "$project-$refname-Apps-$($artifactsVersion)" -or $_.name -like "$project-$refname-TestApps-$($artifactsVersion)" -or $_.name -like "$project-$refname-Dependencies-$($artifactsVersion)") } | ForEach-Object { + $atype = $_.name.SubString(0,$_.name.Length-$artifactsVersion.Length-1) + $atype = $atype.SubString($atype.LastIndexOf('-')+1) + $include += $( [ordered]@{ "name" = $_.name; "url" = $_.archive_download_url; "atype" = $atype; "project" = $thisproject } ) + } + if ($include.Count -eq 0) { + Write-Host "::Error::No artifacts found" + exit 1 + } + } + $artifacts = @{ "include" = $include } + $artifactsJson = $artifacts | ConvertTo-Json -compress + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "artifacts=$artifactsJson" + Write-Host "artifacts=$artifactsJson" + 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@v4.0 + 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 + id: createrelease + env: + bodyMD: ${{ steps.createreleasenotes.outputs.releaseNotes }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var bodyMD = process.env.bodyMD + const createReleaseResponse = await github.rest.repos.createRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: '${{ github.event.inputs.tag }}', + name: '${{ github.event.inputs.name }}', + body: bodyMD.replaceAll('\\n','\n').replaceAll('%0A','\n').replaceAll('%0D','\n').replaceAll('%25','%'), + draft: ${{ github.event.inputs.draft=='Y' }}, + prerelease: ${{ github.event.inputs.prerelease=='Y' }}, + make_latest: 'legacy', + target_commitish: '${{ steps.analyzeartifacts.outputs.commitish }}' + }); + const { + data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl } + } = createReleaseResponse; + core.setOutput('releaseId', releaseId); + + UploadArtifacts: + runs-on: [ windows-latest ] + needs: [ CreateRelease ] + strategy: + matrix: ${{ fromJson(needs.CreateRelease.outputs.artifacts) }} + fail-fast: true + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'nuGetContext,storageContext' + + - name: Download artifact + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + Write-Host "Downloading artifact ${{ matrix.name}}" + $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 + env: + releaseId: ${{ needs.createrelease.outputs.releaseId }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const releaseId = process.env.releaseId + const assetPath = '${{ matrix.name }}.zip' + const assetName = '${{ matrix.name }}.zip' + const fs = require('fs'); + const uploadAssetResponse = await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: releaseId, + name: assetName, + data: fs.readFileSync(assetPath) + }); + + - name: Deliver to NuGet + uses: microsoft/AL-Go-Actions/Deliver@v4.0 + if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).nuGetContext != '' }} + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + type: 'Release' + projects: ${{ matrix.project }} + deliveryTarget: 'NuGet' + artifacts: ${{ github.event.inputs.appVersion }} + atypes: 'Apps,TestApps' + + - name: Deliver to Storage + uses: microsoft/AL-Go-Actions/Deliver@v4.0 + if: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).storageContext != '' }} + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + type: 'Release' + projects: ${{ matrix.project }} + deliveryTarget: 'Storage' + artifacts: ${{ github.event.inputs.appVersion }} + atypes: 'Apps,TestApps,Dependencies' + + CreateReleaseBranch: + if: ${{ github.event.inputs.createReleaseBranch=='Y' }} + runs-on: [ windows-latest ] + needs: [ CreateRelease, UploadArtifacts ] + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: '${{ needs.createRelease.outputs.commitish }}' + + - name: Create Release Branch + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + git checkout -b ${{ needs.CreateRelease.outputs.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 }} + + UpdateVersionNumber: + if: ${{ github.event.inputs.updateVersionNumber!='' }} + runs-on: [ windows-latest ] + needs: [ CreateRelease, UploadArtifacts ] + steps: + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + + - name: Update Version Number + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v4.0 + with: + shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} + versionNumber: ${{ github.event.inputs.updateVersionNumber }} + directCommit: ${{ github.event.inputs.directCommit }} + + PostProcess: + if: always() + runs-on: [ windows-latest ] + needs: [ CreateRelease, UploadArtifacts, CreateReleaseBranch, UpdateVersionNumber ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0094" + telemetryScopeJson: ${{ needs.CreateRelease.outputs.telemetryScopeJson }} diff --git a/.github/workflows/CreateTestApp.yaml b/.github/workflows/CreateTestApp.yaml new file mode 100644 index 0000000..cac7067 --- /dev/null +++ b/.github/workflows/CreateTestApp.yaml @@ -0,0 +1,95 @@ +name: 'Create a new test app' + +run-name: "Create a new test app in [${{ github.ref_name }}]" + +on: + workflow_dispatch: + inputs: + project: + description: Project name if the repository is setup for multiple projects + required: false + default: '.' + name: + description: Name + required: true + default: '.Test' + publisher: + description: Publisher + required: true + idrange: + description: ID range + required: true + default: '50000..99999' + sampleCode: + description: Include Sample code (Y/N) + required: false + default: 'Y' + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: 'N' + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + CreateTestApp: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0095" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + 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@v4.0 + with: + shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + project: ${{ github.event.inputs.project }} + type: 'Test App' + name: ${{ github.event.inputs.name }} + publisher: ${{ github.event.inputs.publisher }} + idrange: ${{ github.event.inputs.idrange }} + sampleCode: ${{ github.event.inputs.sampleCode }} + directCommit: ${{ github.event.inputs.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0095" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/Current.yaml b/.github/workflows/Current.yaml new file mode 100644 index 0000000..dabbacf --- /dev/null +++ b/.github/workflows/Current.yaml @@ -0,0 +1,96 @@ +name: ' Test Current' + +on: + workflow_dispatch: + +permissions: + contents: read + +defaults: + run: + shell: powershell + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Initialization: + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + 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: Checkout + uses: actions/checkout@v3 + with: + lfs: true + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0101" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - 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@v4.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + Build: + needs: [ Initialization ] + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 + strategy: + matrix: + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} + fail-fast: false + 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: + if: always() + runs-on: [ windows-latest ] + needs: [ Initialization, Build ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0101" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/IncrementVersionNumber.yaml b/.github/workflows/IncrementVersionNumber.yaml new file mode 100644 index 0000000..89e4680 --- /dev/null +++ b/.github/workflows/IncrementVersionNumber.yaml @@ -0,0 +1,79 @@ +name: ' Increment Version Number' + +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) + 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' + useGhTokenWorkflow: + description: Use GhTokenWorkflow for Pull Request/COMMIT + type: boolean + +permissions: + contents: write + pull-requests: write + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + IncrementVersionNumber: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0096" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'TokenForPush' + useGhTokenWorkflowForPush: '${{ github.event.inputs.useGhTokenWorkflow }}' + + - name: Increment Version Number + uses: microsoft/AL-Go-Actions/IncrementVersionNumber@v4.0 + with: + shell: powershell + token: ${{ steps.ReadSecrets.outputs.TokenForPush }} + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + project: ${{ github.event.inputs.project }} + versionNumber: ${{ github.event.inputs.versionNumber }} + directCommit: ${{ github.event.inputs.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0096" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMajor.yaml b/.github/workflows/NextMajor.yaml new file mode 100644 index 0000000..191a9ce --- /dev/null +++ b/.github/workflows/NextMajor.yaml @@ -0,0 +1,96 @@ +name: ' Test Next Major' + +on: + workflow_dispatch: + +permissions: + contents: read + +defaults: + run: + shell: powershell + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Initialization: + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + 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: Checkout + uses: actions/checkout@v3 + with: + lfs: true + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0099" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - 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@v4.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + Build: + needs: [ Initialization ] + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 + strategy: + matrix: + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} + fail-fast: false + 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: + if: always() + runs-on: [ windows-latest ] + needs: [ Initialization, Build ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0099" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/NextMinor.yaml b/.github/workflows/NextMinor.yaml new file mode 100644 index 0000000..267f179 --- /dev/null +++ b/.github/workflows/NextMinor.yaml @@ -0,0 +1,96 @@ +name: ' Test Next Minor' + +on: + workflow_dispatch: + +permissions: + contents: read + +defaults: + run: + shell: powershell + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Initialization: + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + 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: Checkout + uses: actions/checkout@v3 + with: + lfs: true + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0100" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - 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@v4.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + Build: + needs: [ Initialization ] + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 + strategy: + matrix: + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} + fail-fast: false + 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: + if: always() + runs-on: [ windows-latest ] + needs: [ Initialization, Build ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0100" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PublishToEnvironment.yaml b/.github/workflows/PublishToEnvironment.yaml new file mode 100644 index 0000000..9fe83ed --- /dev/null +++ b/.github/workflows/PublishToEnvironment.yaml @@ -0,0 +1,173 @@ +name: ' Publish To Environment' + +on: + workflow_dispatch: + inputs: + appVersion: + description: App version to deploy to environment(s) (current, prerelease, draft, latest or version number) + required: false + default: 'current' + environmentName: + description: Environment mask to receive the new version (* for all, PROD* for all environments starting with PROD) + required: true + +permissions: + contents: read + actions: read + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + Initialization: + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + environmentsMatrixJson: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentsMatrixJson }} + environmentCount: ${{ steps.DetermineDeploymentEnvironments.outputs.EnvironmentCount }} + deploymentEnvironmentsJson: ${{ steps.DetermineDeploymentEnvironments.outputs.DeploymentEnvironmentsJson }} + deviceCode: ${{ steps.Authenticate.outputs.deviceCode }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0097" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Determine Deployment Environments + id: DetermineDeploymentEnvironments + uses: microsoft/AL-Go-Actions/DetermineDeploymentEnvironments@v4.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + shell: powershell + getEnvironments: ${{ github.event.inputs.environmentName }} + type: 'Publish' + + - name: EnvName + id: envName + if: steps.DetermineDeploymentEnvironments.outputs.UnknownEnvironment == 1 + run: | + $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 + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + if: steps.DetermineDeploymentEnvironments.outputs.UnknownEnvironment == 1 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ steps.envName.outputs.envName }}-AuthContext,${{ steps.envName.outputs.envName }}_AuthContext,AuthContext' + + - name: Authenticate + id: Authenticate + 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)) { + if ($secrets."$_") { + Write-Host "Using $_ secret as AuthContext" + $authContext = $secrets."$_" + $secretName = $_ + } + } + } + if ($authContext) { + Write-Host "AuthContext provided in secret $secretName!" + Set-Content -Path $ENV:GITHUB_STEP_SUMMARY -value "AuthContext was provided in a secret called $secretName. Using this information for authentication." + } + else { + Write-Host "No AuthContext provided for $envName, initiating Device Code flow" + $ALGoHelperPath = "$([System.IO.Path]::GetTempFileName()).ps1" + $webClient = New-Object System.Net.WebClient + $webClient.DownloadFile('https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v4.0/AL-Go-Helper.ps1', $ALGoHelperPath) + . $ALGoHelperPath + DownloadAndImportBcContainerHelper + $authContext = New-BcAuthContext -includeDeviceLogin -deviceLoginTimeout ([TimeSpan]::FromSeconds(0)) + 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 -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "deviceCode=$($authContext.deviceCode)" + } + + Deploy: + needs: [ Initialization ] + if: needs.Initialization.outputs.environmentCount > 0 + strategy: ${{ fromJson(needs.Initialization.outputs.environmentsMatrixJson) }} + runs-on: ${{ fromJson(matrix.os) }} + name: Deploy to ${{ matrix.environment }} + environment: + name: ${{ matrix.environment }} + url: ${{ steps.Deploy.outputs.environmentUrl }} + env: + deviceCode: ${{ needs.Initialization.outputs.deviceCode }} + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: EnvName + id: envName + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $envName = '${{ matrix.environment }}'.split(' ')[0] + Add-Content -Encoding UTF8 -Path $env:GITHUB_OUTPUT -Value "envName=$envName" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + 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: Deploy + id: Deploy + uses: microsoft/AL-Go-Actions/Deploy@v4.0 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: powershell + environmentName: ${{ matrix.environment }} + artifacts: ${{ github.event.inputs.appVersion }} + type: 'Publish' + deploymentEnvironmentsJson: ${{ needs.Initialization.outputs.deploymentEnvironmentsJson }} + + PostProcess: + if: always() + runs-on: [ windows-latest ] + needs: [ Initialization, Deploy ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Finalize the workflow + id: PostProcess + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0097" + telemetryScopeJson: ${{ needs.Initialization.outputs.telemetryScopeJson }} diff --git a/.github/workflows/PullRequestHandler.yaml b/.github/workflows/PullRequestHandler.yaml new file mode 100644 index 0000000..b84dffb --- /dev/null +++ b/.github/workflows/PullRequestHandler.yaml @@ -0,0 +1,111 @@ +name: 'Pull Request Build' + +on: + pull_request_target: + branches: [ 'main' ] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +defaults: + run: + shell: powershell + +permissions: + contents: read + actions: read + pull-requests: read + +env: + workflowDepth: 1 + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + PregateCheck: + 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: microsoft/AL-Go-Actions/VerifyPRChanges@v4.0 + + Initialization: + needs: [ PregateCheck ] + if: (!failure() && !cancelled()) + runs-on: [ windows-latest ] + outputs: + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + 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: Checkout + uses: actions/checkout@v3 + with: + lfs: true + ref: refs/pull/${{ github.event.number }}/merge + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0104" + + - name: Read settings + id: ReadSettings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + + - 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@v4.0 + with: + shell: powershell + maxBuildDepth: ${{ env.workflowDepth }} + + Build: + needs: [ Initialization ] + if: (!failure()) && (!cancelled()) && fromJson(needs.Initialization.outputs.buildOrderJson)[0].projectsCount > 0 + strategy: + matrix: + include: ${{ fromJson(needs.Initialization.outputs.buildOrderJson)[0].buildDimensions }} + fail-fast: false + 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 }} + secrets: 'licenseFileUrl,keyVaultCertificateUrl,*keyVaultCertificatePassword,keyVaultClientId,gitHubPackagesContext,applicationInsightsConnectionString' + publishThisBuildArtifacts: ${{ needs.Initialization.outputs.workflowDepth > 1 }} + artifactsNameSuffix: 'PR${{ github.event.number }}' + + StatusCheck: + runs-on: [ windows-latest ] + needs: [ Initialization, Build ] + if: (!cancelled()) + name: Pull Request Status Check + steps: + - name: Pull Request Status Check + id: PullRequestStatusCheck + uses: microsoft/AL-Go-Actions/PullRequestStatusCheck@v4.0 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + shell: powershell diff --git a/.github/workflows/UpdateGitHubGoSystemFiles.yaml b/.github/workflows/UpdateGitHubGoSystemFiles.yaml new file mode 100644 index 0000000..f807081 --- /dev/null +++ b/.github/workflows/UpdateGitHubGoSystemFiles.yaml @@ -0,0 +1,95 @@ +name: ' Update AL-Go System Files' + +on: + workflow_dispatch: + inputs: + templateUrl: + description: Template Repository URL (current is {TEMPLATEURL}) + required: false + default: '' + directCommit: + description: Direct COMMIT (Y/N) + required: false + default: 'N' + +permissions: + contents: read + +defaults: + run: + shell: powershell + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + UpdateALGoSystemFiles: + runs-on: [ windows-latest ] + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize the workflow + id: init + uses: microsoft/AL-Go-Actions/WorkflowInitialize@v4.0 + with: + shell: powershell + eventId: "DO0098" + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: powershell + get: templateUrl + + - name: Read secrets + id: ReadSecrets + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: powershell + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: 'ghTokenWorkflow' + + - name: Override templateUrl + env: + templateUrl: ${{ github.event.inputs.templateUrl }} + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $templateUrl = $ENV:templateUrl + if ($templateUrl) { + Write-Host "Using Template Url: $templateUrl" + Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "templateUrl=$templateUrl" + } + + - name: Calculate DirectCommit + env: + directCommit: ${{ github.event.inputs.directCommit }} + eventName: ${{ github.event_name }} + run: | + $errorActionPreference = "Stop"; $ProgressPreference = "SilentlyContinue"; Set-StrictMode -Version 2.0 + $directCommit = $ENV:directCommit + Write-Host $ENV:eventName + if ($ENV:eventName -eq 'schedule') { + Write-Host "Running Update AL-Go System Files on a schedule. Setting DirectCommit = Y" + $directCommit = 'Y' + } + Add-Content -Encoding UTF8 -Path $env:GITHUB_ENV -Value "DirectCommit=$directCommit" + + - name: Update AL-Go system files + uses: microsoft/AL-Go-Actions/CheckForUpdates@v4.0 + with: + shell: powershell + parentTelemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} + token: ${{ fromJson(steps.ReadSecrets.outputs.Secrets).ghTokenWorkflow }} + Update: Y + templateUrl: ${{ env.templateUrl }} + directCommit: ${{ env.directCommit }} + + - name: Finalize the workflow + if: always() + uses: microsoft/AL-Go-Actions/WorkflowPostProcess@v4.0 + with: + shell: powershell + eventId: "DO0098" + telemetryScopeJson: ${{ steps.init.outputs.telemetryScopeJson }} diff --git a/.github/workflows/_BuildALGoProject.yaml b/.github/workflows/_BuildALGoProject.yaml new file mode 100644 index 0000000..0f1ec99 --- /dev/null +++ b/.github/workflows/_BuildALGoProject.yaml @@ -0,0 +1,260 @@ +name: '_Build AL-GO project' + +run-name: 'Build project ${{ 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 og 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 + secrets: + description: A comma-separated string with the names of the secrets, required for the workflow. + required: false + default: '' + type: string + publishThisBuildArtifacts: + description: Flag indicating whether this build artifacts should be published + required: false + default: false + type: boolean + publishArtifacts: + description: Flag indicating whether the artifacts should be published + required: false + default: false + type: boolean + artifactsNameSuffix: + description: Suffix to add to the artifacts names + required: false + default: '' + type: string + signArtifacts: + description: Flag indicating whether the apps should be signed + required: false + default: false + type: boolean + useArtifactCache: + description: Flag determining whether to use the Artifacts Cache + required: false + default: false + type: boolean + parentTelemetryScopeJson: + description: Specifies the telemetry scope for the telemetry signal + required: false + type: string + +env: + ALGoOrgSettings: ${{ vars.ALGoOrgSettings }} + ALGoRepoSettings: ${{ vars.ALGoRepoSettings }} + +jobs: + BuildALGoProject: + runs-on: ${{ fromJson(inputs.runsOn) }} + name: ${{ inputs.projectName }} (${{ inputs.buildMode }}) + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ inputs.checkoutRef }} + lfs: true + + - name: Read settings + uses: microsoft/AL-Go-Actions/ReadSettings@v4.0 + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + get: useCompilerFolder,keyVaultCodesignCertificateName,doNotSignApps,doNotRunTests,artifact + + - name: Read secrets + id: ReadSecrets + if: github.event_name != 'pull_request' + uses: microsoft/AL-Go-Actions/ReadSecrets@v4.0 + with: + shell: ${{ inputs.shell }} + gitHubSecrets: ${{ toJson(secrets) }} + getSecrets: '${{ inputs.secrets }},appDependencyProbingPathsSecrets' + + - name: Determine ArtifactUrl + uses: microsoft/AL-Go-Actions/DetermineArtifactUrl@v4.0 + 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@v3 + with: + path: .artifactcache + key: ${{ env.artifactCacheKey }} + + - name: Download Project Dependencies + id: DownloadProjectDependencies + uses: microsoft/AL-Go-Actions/DownloadProjectDependencies@v4.0 + env: + Secrets: '${{ steps.ReadSecrets.outputs.Secrets }}' + with: + shell: ${{ inputs.shell }} + project: ${{ inputs.project }} + buildMode: ${{ inputs.buildMode }} + projectsDependenciesJson: ${{ inputs.projectDependenciesJson }} + + - name: Download JavaScript artifacts + with: + name: graph_view_dist + path: ./GraphViewControl/Scripts/dist + + - name: Run pipeline + id: RunPipeline + uses: microsoft/AL-Go-Actions/RunPipeline@v4.0 + 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@v4.0 + 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@v4.0 + 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@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildAppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Upload thisbuild artifacts - test apps + if: inputs.publishThisBuildArtifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.calculateArtifactsNames.outputs.ThisBuildTestAppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + retention-days: 1 + + - name: Publish artifacts - apps + uses: actions/upload-artifact@v3 + if: inputs.publishArtifacts + with: + name: ${{ steps.calculateArtifactsNames.outputs.AppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Apps/' + if-no-files-found: ignore + + - name: Publish artifacts - dependencies + uses: actions/upload-artifact@v3 + if: inputs.publishArtifacts + with: + name: ${{ steps.calculateArtifactsNames.outputs.DependenciesArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/Dependencies/' + if-no-files-found: ignore + + - name: Publish artifacts - test apps + uses: actions/upload-artifact@v3 + if: inputs.publishArtifacts + with: + name: ${{ steps.calculateArtifactsNames.outputs.TestAppsArtifactsName }} + path: '${{ inputs.project }}/.buildartifacts/TestApps/' + if-no-files-found: ignore + + - name: Publish artifacts - build output + uses: actions/upload-artifact@v3 + if: (success() || failure()) && (hashFiles(format('{0}/BuildOutput.txt',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.BuildOutputArtifactsName }} + path: '${{ inputs.project }}/BuildOutput.txt' + if-no-files-found: ignore + + - name: Publish artifacts - container event log + uses: actions/upload-artifact@v3 + if: (failure()) && (hashFiles(format('{0}/ContainerEventLog.evtx',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.ContainerEventLogArtifactsName }} + path: '${{ inputs.project }}/ContainerEventLog.evtx' + if-no-files-found: ignore + + - name: Publish artifacts - test results + uses: actions/upload-artifact@v3 + if: (success() || failure()) && (hashFiles(format('{0}/TestResults.xml',inputs.project)) != '') + with: + name: ${{ steps.calculateArtifactsNames.outputs.TestResultsArtifactsName }} + path: '${{ inputs.project }}/TestResults.xml' + if-no-files-found: ignore + + - name: Publish artifacts - bcpt test results + uses: actions/upload-artifact@v3 + if: (success() || failure()) && (hashFiles(format('{0}/bcptTestResults.json',inputs.project)) != '') + with: + name: ${{ 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@v4.0 + with: + shell: ${{ inputs.shell }} + parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} + project: ${{ inputs.project }} + + - name: Cleanup + if: always() + uses: microsoft/AL-Go-Actions/PipelineCleanup@v4.0 + with: + shell: ${{ inputs.shell }} + parentTelemetryScopeJson: ${{ inputs.parentTelemetryScopeJson }} + project: ${{ inputs.project }} diff --git a/.github/workflows/webpack.yml b/.github/workflows/nodejs_webpack.yaml similarity index 78% rename from .github/workflows/webpack.yml rename to .github/workflows/nodejs_webpack.yaml index 036da24..ac2dfb0 100644 --- a/.github/workflows/webpack.yml +++ b/.github/workflows/nodejs_webpack.yaml @@ -1,11 +1,7 @@ name: NodeJS with Webpack on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - workflow_dispatch: + workflow_call: jobs: build: diff --git a/.gitignore b/.gitignore index 709dad7..6e8bdf8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ package-lock.json .vscode/ node_modules/ GraphViewControl/Scripts/dist/ +Release diff --git a/AL-Go-settings.json b/AL-Go-settings.json new file mode 100644 index 0000000..00469ab --- /dev/null +++ b/AL-Go-settings.json @@ -0,0 +1,122 @@ +{ + "keyVaultCertificateUrlSecretName": "", + "microsoftTelemetryConnectionString": "", + "type": "PTE", + "sendExtendedTelemetryToMicrosoft": false, + "appBuild": 3, + "installTestApps": [ + + ], + "versioningStrategy": 0, + "installApps": [ + + ], + "installTestLibraries": true, + "runNumberOffset": 0, + "codeSignCertificatePasswordSecretName": "codeSignCertificatePassword", + "country": "w1", + "excludeEnvironments": [ + + ], + "partnerTelemetryConnectionString": "", + "doNotRunTests": false, + "runs-on": "windows-latest", + "configPackages": [ + + ], + "generateDependencyArtifact": false, + "templateUrl": "https://github.com/microsoft/AL-Go-PTE@main", + "keyVaultCertificatePasswordSecretName": "", + "rulesetFile": "", + "shell": "powershell", + "enableExternalRulesets": false, + "memoryLimit": "", + "keyVaultClientIdSecretName": "", + "testFolders": [ + "./GraphViewTests", + "./CostGraphTests", + "./RoutingGraphTests" + ], + "githubRunner": "windows-latest", + "doNotBuildTests": false, + "environments": [ + + ], + "companyName": "", + "assignPremiumPlan": false, + "artifact": "", + "ghTokenWorkflowSecretName": "ghTokenWorkflow", + "enableTaskScheduler": false, + "enableCodeCop": true, + "repoVersion": "1.0", + "doNotPublishApps": false, + "doNotSignApps": true, + "githubRunnerShell": "powershell", + "cacheKeepDays": 3, + "bcptTestFolders": [ + + ], + "updateDependencies": false, + "cacheImageName": "my", + "treatTestFailuresAsWarnings": false, + "additionalCountries": [ + + ], + "licenseFileUrlSecretName": "", + "enableUICop": true, + "customCodeCops": [ + + ], + "appDependencies": [ + + ], + "doNotRunBcptTests": false, + "skipUpgrade": false, + "appDependencyProbingPaths": [ + + ], + "useCompilerFolder": false, + "installTestFramework": true, + "keyVaultCodesignCertificateName": "", + "keyVaultName": "", + "obsoleteTagMinAllowedMajorMinor": "", + "applicationDependency": "23.0.0.0", + "applicationInsightsConnectionStringSecretName": "", + "failOn": "error", + "projects": [ + + ], + "appSourceCopMandatoryAffixes": [ + + ], + "projectName": ".", + "testDependencies": [ + + ], + "appRevision": 0, + "codeSignCertificateUrlSecretName": "", + "vsixFile": "", + "useProjectDependencies": false, + "unusedALGoSystemFiles": [ + + ], + "buildModes": [ + + ], + "templateBranch": "", + "installPerformanceToolkit": false, + "PullRequestTrigger": "pull_request_target", + "appFolders": [ + "./GraphViewControl", + "./CostGraph", + "./RoutingGraph" + ], + "repoName": "BCVisuals", + "fullBuildPatterns": [ + + ], + "alwaysBuildAllProjects": false, + "installOnlyReferencedApps": true, + "installTestRunner": true, + "adminCenterApiCredentialsSecretName": "" +} \ No newline at end of file