-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Tine Staric
committed
Sep 13, 2024
1 parent
533cc2c
commit 3eb30b6
Showing
12 changed files
with
849 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Setup Build Matrix | ||
description: Populate matrix for build job strategy | ||
|
||
inputs: | ||
sources: | ||
required: true | ||
description: Stringified JSON object with VSIXPackages of the AL Language versions | ||
al-version-latest: | ||
required: true | ||
description: Version number of the Latest version of the AL Language | ||
al-version-prerelease: | ||
required: true | ||
description: Version number of the Pre-Release version of the AL Language | ||
|
||
outputs: | ||
matrix: | ||
description: Stringified JSON object with matrix for build job strategy | ||
value: ${{ steps.get-matrix.outputs.matrix }} | ||
isempty: | ||
description: Boolean 'true'/'false' if the matrix is an empty result | ||
value: ${{ steps.get-matrix.outputs.isempty }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Get Matrix | ||
id: get-matrix | ||
shell: pwsh | ||
env: | ||
AL_VERSION_LATEST: ${{ inputs.al-version-latest }} | ||
AL_VERSION_PRERELEASE: ${{ inputs.al-version-prerelease }} | ||
run: | | ||
$matrix = @() | ||
$sources = '${{ inputs.sources }}' | ConvertFrom-Json | ||
foreach ($item in $sources) { | ||
$matrix += [Ordered]@{ | ||
version = $item.version; | ||
assetname = "CopmanialCop.AL-$($item.version).dll"; | ||
assetUri = $item.source; | ||
latest = $($item.version -eq $env:AL_VERSION_LATEST); | ||
prerelease = $($item.version -eq $env:AL_VERSION_PRERELEASE); | ||
} | ||
} | ||
echo "isempty=$([string]($matrix.Count -eq 0).ToString().ToLower())" >> $env:GITHUB_OUTPUT | ||
$matrix = @{'include' = $matrix } | ConvertTo-Json -Compress | ||
echo "matrix=$($matrix)" >> $env:GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
name: dotnet build | ||
description: Builds a .NET project and all of its dependencies. | ||
|
||
inputs: | ||
asset-version-number: | ||
required: false | ||
description: The version number for the artifact | ||
asset-name: | ||
required: false | ||
description: The name for the artifact | ||
asset-publish: | ||
required: false | ||
default: "false" | ||
description: Publish artifact as asset on workflow | ||
al-version-number: | ||
required: true | ||
description: The version number of the corresponding AL Language | ||
al-asset-uri: | ||
required: true | ||
description: The asset uri for retrieving the VSIXPackages of the AL Language | ||
al-latest: | ||
default: "false" | ||
required: false | ||
description: Set build as Latest version of the AL Language | ||
al-prerelease: | ||
default: "false" | ||
required: false | ||
description: Set build as Pre-Release version of the AL Language | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Restore dependencies | ||
shell: pwsh | ||
run: dotnet restore CompanialCopAnalyzer | ||
|
||
- name: Download platform artifact | ||
shell: pwsh | ||
env: | ||
ASSET_URI: ${{ inputs.al-asset-uri }} | ||
run: Invoke-WebRequest $env:ASSET_URI -OutFile ALLanguage.vsix | ||
|
||
- name: Unzip vsix | ||
shell: pwsh | ||
run: 7z x ALLanguage.vsix "-oALLanguage" "extension/bin/Analyzers" -r | ||
|
||
- name: Set AssemblyInfo | ||
shell: pwsh | ||
if: ${{ inputs.asset-publish == 'true' }} | ||
env: | ||
AL_VERSION: ${{ inputs.al-version-number }} | ||
LC_VERSION: ${{ inputs.asset-version-number }} | ||
run: | ||
(Get-Content CompanialCopAnalyzer/AssemblyInfo.cs) -replace 'Version\("([\d\.]+)"\)]', | ||
("Version(""" + ($env:LC_VERSION | ||
-replace "v","") + """)]") | Out-File CompanialCopAnalyzer/AssemblyInfo.cs | ||
|
||
(Get-Content CompanialCopAnalyzer/AssemblyInfo.cs) -replace 'AssemblyTitle\("([^"]*)"\)', "AssemblyTitle(`"AL-$env:AL_VERSION`")" | Out-File CompanialCopAnalyzer/AssemblyInfo.cs | ||
|
||
- name: Populate Feature Flags | ||
id: get-feature-flags | ||
uses: ./.github/actions/feature-flags | ||
with: | ||
version-number: ${{ inputs.al-version-number }} | ||
|
||
- name: Build | ||
shell: pwsh | ||
run: dotnet build CompanialCopAnalyzer /p:FeatureFlags=${{ steps.get-feature-flags.outputs.feature-flags }} --no-restore --configuration Release | ||
|
||
- name: Test | ||
shell: pwsh | ||
run: dotnet test CompanialCopAnalyzer.Test /p:FeatureFlags=${{ steps.get-feature-flags.outputs.feature-flags }} | ||
|
||
- name: Upload build artifact | ||
id: upload-build-asset | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ inputs.asset-publish == 'true' }} | ||
with: | ||
name: ${{ inputs.asset-name }} | ||
path: CompanialCopAnalyzer/bin/Release/netstandard2.1/CompanialCop.dll | ||
compression-level: 0 # no compression | ||
|
||
### Upload Asset as Latest | ||
- name: Upload build artifact (Latest) | ||
id: upload-build-asset-latest | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ inputs.asset-publish == 'true' && inputs.al-latest == 'true' }} | ||
with: | ||
name: CompanialCop.dll | ||
path: CompanialCopAnalyzer/bin/Release/netstandard2.1/CompanialCop.dll | ||
compression-level: 0 # no compression | ||
|
||
### Upload Asset as Pre-Release | ||
- name: Upload build artifact (Pre-Release) | ||
id: upload-build-asset-prerelease | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ inputs.asset-publish == 'true' && inputs.al-prerelease == 'true' }} | ||
with: | ||
name: CompanialCop.AL-PreRelease.dll | ||
path: CompanialCopAnalyzer/bin/Release/netstandard2.1/CompanialCop.dll | ||
compression-level: 0 # no compression | ||
|
||
### Compatibility with previous naming of files | ||
### Release Asset as Current | ||
- name: Upload build artifact (Current) | ||
id: upload-build-asset-current | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ inputs.asset-publish == 'true' && inputs.al-latest == 'true' }} | ||
with: | ||
name: CompanialCop.current.dll | ||
path: CompanialCopAnalyzer/bin/Release/netstandard2.1/CompanialCop.dll | ||
compression-level: 0 # no compression | ||
|
||
### Release Asset as Next | ||
- name: Upload build artifact (Next) | ||
id: upload-build-asset-next | ||
uses: actions/upload-artifact@v4 | ||
if: ${{ inputs.asset-publish == 'true' && inputs.al-prerelease == 'true' }} | ||
with: | ||
name: CompanialCop.next.dll | ||
path: CompanialCopAnalyzer/bin/Release/netstandard2.1/CompanialCop.dll | ||
compression-level: 0 # no compression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Code Sign Assets | ||
description: "" | ||
|
||
inputs: | ||
base-directory: | ||
required: true | ||
description: Path with the artifacts that need to be code signed | ||
description: | ||
required: true | ||
description: "" | ||
description-url: | ||
required: true | ||
description: "" | ||
azure-key-vault-url: | ||
required: true | ||
description: "" | ||
azure-key-vault-certificate: | ||
required: true | ||
description: "" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install Sign CLI tool | ||
shell: pwsh | ||
run: dotnet tool install --tool-path . sign --version 0.9.0-beta.23127.3 | ||
|
||
- name: Sign artifacts | ||
shell: pwsh | ||
env: | ||
KEY_VAULT_URL: ${{ inputs.azure-key-vault-url }} | ||
KEY_VAULT_CERTIFICATE: ${{ inputs.azure-key-vault-certificate }} | ||
run: > | ||
./sign code azure-key-vault | ||
**/*.dll | ||
--base-directory ${{ inputs.base-directory }} | ||
--description ${{ inputs.description }} | ||
--description-url ${{ inputs.description-url }} | ||
--azure-key-vault-managed-identity true | ||
--azure-key-vault-url $env:KEY_VAULT_URL | ||
--azure-key-vault-certificate $env:KEY_VAULT_CERTIFICATE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Download artifacts | ||
description: Download artifacts | ||
|
||
inputs: | ||
path: | ||
required: true | ||
description: "" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Download artifacts | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: ${{ github.workspace }}\DownloadBuildArtifacts | ||
|
||
- name: Rename artifacts | ||
shell: pwsh | ||
env: | ||
SOURCE_PATH: ${{ github.workspace }}\DownloadBuildArtifacts | ||
TARGET_PATH: ${{ inputs.path }} | ||
run: | | ||
# Get list of artifacts files | ||
$artifacts = Get-ChildItem -Path $env:SOURCE_PATH -Recurse -File | ||
| Where-Object { $_.Name -like 'CompanialCop*.dll' -and $_.Directory.Name -like 'CompanialCop*.dll' } | ||
# Create folder if not exits | ||
if (!(Test-Path $env:TARGET_PATH)) { | ||
New-Item -Path $env:TARGET_PATH -ItemType Directory -Force | Out-Null | ||
} | ||
# Move the artifacts (CompanialCop.dll) in every directory to a combined folder and rename the file to the name of it's parent directory | ||
$artifacts | ForEach-Object { Move-Item -Path $_ -Destination (Join-Path $env:TARGET_PATH $_.Directory.Name) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Get-FeatureFlags.ps1 | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $version | ||
) | ||
|
||
function ConvertTo-Version { | ||
[OutputType([System.Version])] | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $version | ||
) | ||
|
||
$result = $null | ||
if ([System.Version]::TryParse($version, [ref]$result)) { | ||
return $result | ||
} | ||
else { | ||
Write-Error "The value '$($version)' is not a valid input." | ||
} | ||
} | ||
|
||
function Get-FeatureFlags { | ||
[OutputType([System.String])] | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[System.Version] $version | ||
) | ||
$featureFlags = "" | ||
|
||
$RuntimeVersion = [Ordered]@{ | ||
'Spring2018' = '1.0' | ||
'Fall2018' = '2.0' | ||
'Spring2019' = '3.0' | ||
'Fall2019' = '4.0' | ||
'Spring2020' = '5.0' | ||
'Fall2020' = '6.0' | ||
'Spring2021' = '7.0' | ||
'Fall2021' = '8.0' | ||
'Spring2022' = '9.0' | ||
'Spring2022RV1' = '9.1' | ||
'Spring2022RV2' = '9.2' | ||
'Fall2022' = '10.0' | ||
'Spring2023' = '11.0' | ||
'Fall2023' = '12.0' | ||
'Fall2023RV1' = '12.1' | ||
'Fall2023RV2' = '12.2' | ||
'Fall2023RV3' = '12.3' | ||
'Spring2024' = '13.0' | ||
'Fall2024' = '14.0' | ||
'Spring2025' = '15.0' | ||
'Fall2025' = '16.0' | ||
|
||
'Spring2024OrGreater' = '13.0.964488' | ||
'ManifestHelper' = '13.0.937154' | ||
'PageSystemAction' = '13.0.878831' | ||
} | ||
|
||
$supportedRuntimeVersions = $RuntimeVersion.GetEnumerator() | Where-Object { $(ConvertTo-Version($_.Value)) -le $(ConvertTo-Version($version)) } | Foreach-Object { $_.Key } | ForEach-Object { "#$_" } | ||
if (![string]::IsNullOrEmpty($supportedRuntimeVersions)) { | ||
$featureFlags = [System.String]::Join("", $supportedRuntimeVersions) | ||
} | ||
|
||
return $featureFlags | ||
} | ||
|
||
# Convert input version string to System.Version | ||
$version = ConvertTo-Version -version $version | ||
|
||
# Call Get-FeatureFlags with the converted version | ||
$result = Get-FeatureFlags -version $version | ||
|
||
# Output the result | ||
Write-Output $result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Feature Flags | ||
description: Composite Action to populate the Feature Flags based on the AL Language version | ||
|
||
inputs: | ||
version-number: | ||
required: true | ||
description: version number of the AL Language | ||
|
||
outputs: | ||
feature-flags: | ||
description: string of feature flags | ||
value: ${{ steps.populate-feature-flags.outputs.feature-flags }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Populate Feature Flags | ||
id: populate-feature-flags | ||
shell: pwsh | ||
env: | ||
VERSION_NUMBER: ${{ inputs.version-number}} | ||
run: | | ||
$result = ${{github.action_path}}/Get-FeatureFlags.ps1 $env:VERSION_NUMBER | ||
echo "feature-flags=$($result)" >> $env:GITHUB_OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function ConvertTo-Version { | ||
[OutputType([System.Version])] | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[string] $version | ||
) | ||
|
||
$result = $null | ||
if ([System.Version]::TryParse($version, [ref]$result)) { | ||
return $result | ||
} | ||
else { | ||
Write-Error "The value '$($version)' is not a valid input." | ||
} | ||
} | ||
|
||
$listing = Invoke-WebRequest -Method POST -UseBasicParsing ` | ||
-Uri https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery?api-version=3.0-preview.1 ` | ||
-Body '{"filters":[{"criteria":[{"filterType":8,"value":"Microsoft.VisualStudio.Code"},{"filterType":12,"value":"4096"},{"filterType":7,"value":"ms-dynamics-smb.al"}],"pageNumber":1,"pageSize":50,"sortBy":0,"sortOrder":0}],"assetTypes":[],"flags":0x192}' ` | ||
-ContentType application/json | ConvertFrom-Json | ||
|
||
$listingFiltered = $listing.results | Select-Object -First 1 -ExpandProperty extensions ` | ||
| Select-Object -ExpandProperty versions ` | ||
| Where-Object { $(ConvertTo-Version($_.version)) -gt [System.Version]::Parse("12.0.0") } | ||
|
||
Write-Output $listingFiltered | ConvertTo-Json -Compress -Depth 3 |
Oops, something went wrong.