-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add PR task to check for new alerts (#33)
* PR-task: support multiple AlertTypes to check * Add config and load option for "all repos in project" * Determining the highst version in the extension file * fix error * Load main version from AzDo server * fix pwsh code * install the tfx extension * check if we hit all branches * get all branches * Updated the output * fix output * Map URLS to new area name * updates * Updated advanced security review task * temp checkin * update extension with PR task support - release to PROD
- Loading branch information
Showing
14 changed files
with
884 additions
and
551 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,82 @@ | ||
name: Handle versioning accros branches | ||
|
||
on: | ||
push: | ||
# todo: add file paths of the files with version numbers | ||
|
||
jobs: | ||
extension-versioning: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: git-actions/set-user@v1 | ||
|
||
- name: Prevent branch warnings | ||
run: | | ||
# config git advice.detachedHead to false | ||
git config advice.detachedHead false | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install tfx extension | ||
run: | | ||
npm install -g tfx-cli | ||
- name: Get highest version number accross all branches | ||
id: get-version | ||
shell: pwsh | ||
env: | ||
AZURE_DEVOPS_CREATE_PAT: ${{ secrets.AZURE_DEVOPS_CREATE_PAT}} | ||
run: | | ||
# get the last updated version for this extension from the server | ||
$output = $(tfx extension show --token $env:AZURE_DEVOPS_CREATE_PAT --vsix $vsix --publisher "RobBos" --extension-id "GHAzDoWidget-DEV" --output json | ConvertFrom-Json) | ||
$lastVersion = ($output.versions | Sort-Object -Property lastUpdated -Descending)[0] | ||
Write-Host "Last version: [$($lastVersion.version)] from server" | ||
# SemVer code | ||
function Parse-SemVer ($version) { | ||
$parts = $version.Split('.') | ||
return @{ | ||
Major = [int]$parts[0] | ||
Minor = [int]$parts[1] | ||
Patch = [int]$parts[2] | ||
} | ||
} | ||
$highestVersion = @{ | ||
Major = 0 | ||
Minor = 0 | ||
Patch = 0 | ||
} | ||
# loop over all branches | ||
$highestVersion = 0 | ||
foreach ($branch in $(git branch -r --format='%(refname:short)')) { | ||
Write-Host "Checkout the branch [$branch]" | ||
git checkout $branch | ||
# get the semantic version number from the version in the dependencyReviewTask/task.json file | ||
$version = Get-Content -Path "dependencyReviewTask/task.json" | ConvertFrom-Json | Select-Object -ExpandProperty version | ||
Write-Host "Found version: [$version] in branch: [$branch]" | ||
# check if the version is semantically higher than the highest version using SemVer | ||
if ($version.Major -gt $highestVersion.Major -or | ||
($version.Major -eq $highestVersion.Major -and $version.Minor -gt $highestVersion.Minor) -or | ||
($version.Major -eq $highestVersion.Major -and $version.Minor -eq $highestVersion.Minor -and $version.Patch -gt $highestVersion.Patch)) | ||
{ | ||
$highestVersion = $version | ||
Write-Host "New highest version from PR task.json: [$($highestVersion.Major).$($highestVersion.Minor).$($highestVersion.Patch)]" | ||
} | ||
} | ||
Write-Host "Highest version: [$($highestVersion.Major).$($highestVersion.Minor).$($highestVersion.Patch)]" | ||
# show the highest version number in GitHub by writing to the job summary file | ||
Set-Content -Path $env:GITHUB_STEP_SUMMARY -Value "Highest version of the extension: [$($lastVersion.version)]" | ||
Set-Content -Path $env:GITHUB_STEP_SUMMARY -Value "Highest version of the PR check extension: [$($highestVersion.Major).$($highestVersion.Minor).$($highestVersion.Patch)]" |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.