From 55352f183eb89980046a1123a82514f5d0dbf863 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 19 Dec 2024 10:18:53 -0500 Subject: [PATCH 01/12] ci: updates main with the latest ci changes --- .azure-pipelines/ci-build.yml | 48 ++++++++++++++++----------- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/docker.yml | 16 ++++----- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index f381a4303..e9aa773a3 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -5,13 +5,15 @@ name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) trigger: branches: include: - - master - - vnext + - main + - dev + - support/v1 pr: branches: include: - - master - - vnext + - main + - dev + - support/v1 variables: buildPlatform: 'Any CPU' buildConfiguration: 'Release' @@ -206,10 +208,17 @@ extends: content: '*.nupkg' - stage: deploy - condition: and(contains(variables['build.sourceBranch'], 'refs/heads/master'), succeeded()) + condition: and(or(contains(variables['build.sourceBranch'], 'refs/heads/main'),contains(variables['build.sourceBranch'], 'refs/heads/support/v1')), succeeded()) dependsOn: build jobs: - deployment: deploy_hidi + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: Nugets + targetPath: '$(Pipeline.Workspace)' dependsOn: [] environment: nuget-org strategy: @@ -218,11 +227,6 @@ extends: pool: vmImage: ubuntu-latest steps: - - task: DownloadPipelineArtifact@2 - displayName: Download nupkg from artifacts - inputs: - artifact: Nugets - source: current - task: DownloadPipelineArtifact@2 displayName: Download hidi executable from artifacts inputs: @@ -264,6 +268,13 @@ extends: ]' - deployment: deploy_lib + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: Nugets + targetPath: '$(Pipeline.Workspace)' dependsOn: [] environment: nuget-org strategy: @@ -272,11 +283,6 @@ extends: pool: vmImage: ubuntu-latest steps: - - task: DownloadPipelineArtifact@2 - displayName: Download nupkg from artifacts - inputs: - artifact: Nugets - source: current - powershell: | $fileNames = "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Workbench.*.nupkg" foreach($fileName in $fileNames) { @@ -294,6 +300,13 @@ extends: publishFeedCredentials: 'OpenAPI Nuget Connection' - deployment: deploy_readers + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: Nugets + targetPath: '$(Pipeline.Workspace)' dependsOn: deploy_lib environment: nuget-org strategy: @@ -302,11 +315,6 @@ extends: pool: vmImage: ubuntu-latest steps: - - task: DownloadPipelineArtifact@2 - displayName: Download nupkg from artifacts - inputs: - artifact: Nugets - source: current - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 22eb5f8fa..4224ace24 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,7 +2,7 @@ name: CodeQL Analysis on: push: - branches: [ vnext ] + branches: [ main, dev ] pull_request: schedule: - cron: '0 8 * * *' diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index a2a2bb104..7e81a456d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,7 +2,7 @@ name: Publish Docker image on: workflow_dispatch: push: - branches: [master, vnext] + branches: [main, dev, support/v1] paths: ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**'] env: REGISTRY: msgraphprod.azurecr.io @@ -16,7 +16,7 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v4 - - name: Login to GitHub package feed + - name: Login to registry uses: docker/login-action@v3.3.0 with: username: ${{ secrets.ACR_USERNAME }} @@ -28,15 +28,15 @@ jobs: echo "::set-output name=version::${version}" shell: pwsh id: getversion - - name: Push to GitHub Packages - Nightly - if: ${{ github.ref == 'refs/heads/vnext' }} - uses: docker/build-push-action@v6.9.0 + - name: Push to registry - Nightly + if: ${{ github.ref == 'refs/heads/dev' }} + uses: docker/build-push-action@v6.10.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly - - name: Push to GitHub Packages - Release - if: ${{ github.ref == 'refs/heads/master' }} - uses: docker/build-push-action@v6.9.0 + - name: Push to registry - Release + if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/support/v1' }} + uses: docker/build-push-action@v6.10.0 with: push: true tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }} From a3c6c8330f26db5a181f17024a2b9e20ca8529f2 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 19 Dec 2024 12:12:27 -0500 Subject: [PATCH 02/12] fix: removes extraneous download artifact task Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index e9aa773a3..2303ea0a0 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -227,10 +227,6 @@ extends: pool: vmImage: ubuntu-latest steps: - - task: DownloadPipelineArtifact@2 - displayName: Download hidi executable from artifacts - inputs: - source: current - pwsh: | $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" From 662e9d7405b1d75099348a28e4884c08dc4da7ad Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 19 Dec 2024 13:02:08 -0500 Subject: [PATCH 03/12] fix: hidi GH release Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 2303ea0a0..922fde421 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -45,8 +45,8 @@ extends: targetPath: '$(Build.ArtifactStagingDirectory)/Nugets' - output: pipelineArtifact displayName: 'Publish Artifact: Hidi' - artifactName: Microsoft.OpenApi.Hidi-v$(hidiversion) - targetPath: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion)' + artifactName: Hidi + targetPath: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi' steps: - task: UseDotNet@2 displayName: 'Use .NET 6' @@ -179,23 +179,13 @@ extends: MaxConcurrency: '50' MaxRetryAttempts: '5' PendingAnalysisWaitTimeoutMinutes: '5' - - - task: PowerShell@2 - displayName: "Get Hidi's version-number from .csproj" - inputs: - targetType: 'inline' - script: | - $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj) - $version = $xml.Project.PropertyGroup.Version - echo $version - echo "##vso[task.setvariable variable=hidiversion]$version" - + # publish hidi as an .exe - task: DotNetCoreCLI@2 displayName: publish Hidi as executable inputs: command: 'publish' - arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion) + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true /p:PackAsTool=false --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' publishWebProjects: False zipAfterPublish: false @@ -219,6 +209,9 @@ extends: - input: pipelineArtifact artifactName: Nugets targetPath: '$(Pipeline.Workspace)' + - input: pipelineArtifact + artifactName: Hidi + targetPath: '$(Pipeline.Workspace)' dependsOn: [] environment: nuget-org strategy: From 1ae06b1ed1d1870236f24e7894dc46af25cf8c90 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 19 Dec 2024 13:39:59 -0500 Subject: [PATCH 04/12] fix: redundant artifact upload Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 922fde421..449142a91 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -43,10 +43,6 @@ extends: displayName: 'Publish Artifact: Nugets' artifactName: Nugets targetPath: '$(Build.ArtifactStagingDirectory)/Nugets' - - output: pipelineArtifact - displayName: 'Publish Artifact: Hidi' - artifactName: Hidi - targetPath: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi' steps: - task: UseDotNet@2 displayName: 'Use .NET 6' @@ -209,9 +205,6 @@ extends: - input: pipelineArtifact artifactName: Nugets targetPath: '$(Pipeline.Workspace)' - - input: pipelineArtifact - artifactName: Hidi - targetPath: '$(Pipeline.Workspace)' dependsOn: [] environment: nuget-org strategy: From 166747f21d904c493603b5f84b6f72606a33c66b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 09:47:07 -0500 Subject: [PATCH 05/12] fix: removes actions steps that create extraneous tags Signed-off-by: Vincent Biret --- .github/workflows/ci-cd.yml | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 01861ee2d..13a34f171 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -3,15 +3,12 @@ name: CI/CD Pipeline on: [push, pull_request, workflow_dispatch] permissions: - contents: write + contents: read jobs: ci: name: Continuous Integration runs-on: ubuntu-latest - outputs: - latest_version: ${{ steps.tag_generator.outputs.new_version }} - is_default_branch: ${{ steps.conditionals_handler.outputs.is_default_branch }} env: ARTIFACTS_FOLDER: ${{ github.workspace }}/Artifacts GITHUB_RUN_NUMBER: ${{ github.run_number }} @@ -21,27 +18,6 @@ jobs: with: dotnet-version: 8.0.x - - name: Data gatherer - id: data_gatherer - shell: pwsh - run: | - # Get default branch - $repo = 'microsoft/OpenAPI.NET' - $defaultBranch = Invoke-RestMethod -Method GET -Uri https://api.github.com/repos/$repo | Select-Object -ExpandProperty default_branch - Write-Output "::set-output name=default_branch::$(echo $defaultBranch)" - - - name: Conditionals handler - id: conditionals_handler - shell: pwsh - run: | - $defaultBranch = "${{ steps.data_gatherer.outputs.default_branch }}" - $githubRef = "${{ github.ref }}" - $isDefaultBranch = 'false' - if ( $githubRef -like "*$defaultBranch*" ) { - $isDefaultBranch = 'true' - } - Write-Output "::set-output name=is_default_branch::$(echo $isDefaultBranch)" - - name: Checkout repository id: checkout_repo uses: actions/checkout@v4 @@ -49,15 +25,6 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 - - if: steps.conditionals_handler.outputs.is_default_branch == 'true' - name: Bump GH tag - id: tag_generator - uses: mathieudutour/github-tag-action@v6.2 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - default_bump: false - release_branches: ${{ steps.data_gatherer.outputs.default_branch }} - - name: Build projects id: build_projects shell: pwsh From ff52d8345e3936b8fdeb6923875a4612b614d4d3 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 09:50:49 -0500 Subject: [PATCH 06/12] fix: updates output syntax for tag version Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 449142a91..614174516 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -218,10 +218,9 @@ extends: $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" #Set Variable $artifactName and $artifactVersion Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" - Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName" - echo "$artifactName" echo "$artifactVersion" displayName: 'Fetch Artifact Name' + name: getTagVersion - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: @@ -234,10 +233,10 @@ extends: condition: succeededOrFailed() inputs: gitHubConnection: 'Github-MaggieKimani1' - action: edit + action: create tagSource: userSpecifiedTag - tag: '$(artifactVersion)' - title: '$(artifactVersion)' + tag: '$(getTagVersion.artifactVersion)' + title: '$(getTagVersion.artifactVersion)' releaseNotesSource: inline assets: '$(Pipeline.Workspace)\**\*.exe' changeLogType: issueBased From 2fcda792101dbd5bd3af6192360af7c0df471269 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 09:55:32 -0500 Subject: [PATCH 07/12] ci: moves create github release to its own job Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 74 ++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 614174516..a72bfe48b 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -213,14 +213,6 @@ extends: pool: vmImage: ubuntu-latest steps: - - pwsh: | - $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 - $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" - #Set Variable $artifactName and $artifactVersion - Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" - echo "$artifactVersion" - displayName: 'Fetch Artifact Name' - name: getTagVersion - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: @@ -228,25 +220,6 @@ extends: packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' - - task: GitHubRelease@1 - displayName: 'GitHub release (edit)' - condition: succeededOrFailed() - inputs: - gitHubConnection: 'Github-MaggieKimani1' - action: create - tagSource: userSpecifiedTag - tag: '$(getTagVersion.artifactVersion)' - title: '$(getTagVersion.artifactVersion)' - releaseNotesSource: inline - assets: '$(Pipeline.Workspace)\**\*.exe' - changeLogType: issueBased - changeLogLabels: '[ - { "label" : "feature-work", "feature", "displayName" : "New Features", "state" : "closed" }, - { "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" }, - { "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" }, - { "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"}, - { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" } - ]' - deployment: deploy_lib templateContext: @@ -302,4 +275,49 @@ extends: packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg' packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external - publishFeedCredentials: 'OpenAPI Nuget Connection' \ No newline at end of file + publishFeedCredentials: 'OpenAPI Nuget Connection' + + - deployment: create_github_release + templateContext: + type: releaseJob + isProduction: true + inputs: + - input: pipelineArtifact + artifactName: Nugets + targetPath: '$(Pipeline.Workspace)' + dependsOn: [] + environment: kiota-github-releases + strategy: + runOnce: + deploy: + pool: + vmImage: ubuntu-latest + steps: + - pwsh: | + $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 + $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" + #Set Variable $artifactName and $artifactVersion + Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" + echo "$artifactVersion" + displayName: 'Fetch Artifact Name' + name: getTagVersion + - task: GitHubRelease@1 + displayName: 'GitHub release (edit)' + condition: succeededOrFailed() + inputs: + gitHubConnection: 'Github-MaggieKimani1' + action: create + tagSource: userSpecifiedTag + tag: '$(getTagVersion.artifactVersion)' + title: '$(getTagVersion.artifactVersion)' + releaseNotesSource: inline + assets: '$(Pipeline.Workspace)\**\*.exe' + changeLogType: issueBased + changeLogLabels: '[ + { "label" : "feature-work", "feature", "displayName" : "New Features", "state" : "closed" }, + { "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" }, + { "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" }, + { "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"}, + { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" } + ]' + From ee99c4d82e37b6b437b5cef63285f9e11e382364 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 09:58:44 -0500 Subject: [PATCH 08/12] nit: fixes indent Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index a72bfe48b..5c07e63ee 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -302,22 +302,22 @@ extends: displayName: 'Fetch Artifact Name' name: getTagVersion - task: GitHubRelease@1 - displayName: 'GitHub release (edit)' - condition: succeededOrFailed() - inputs: - gitHubConnection: 'Github-MaggieKimani1' - action: create - tagSource: userSpecifiedTag - tag: '$(getTagVersion.artifactVersion)' - title: '$(getTagVersion.artifactVersion)' - releaseNotesSource: inline - assets: '$(Pipeline.Workspace)\**\*.exe' - changeLogType: issueBased - changeLogLabels: '[ - { "label" : "feature-work", "feature", "displayName" : "New Features", "state" : "closed" }, - { "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" }, - { "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" }, - { "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"}, - { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" } - ]' + displayName: 'GitHub release (edit)' + condition: succeededOrFailed() + inputs: + gitHubConnection: 'Github-MaggieKimani1' + action: create + tagSource: userSpecifiedTag + tag: '$(getTagVersion.artifactVersion)' + title: '$(getTagVersion.artifactVersion)' + releaseNotesSource: inline + assets: '$(Pipeline.Workspace)\**\*.exe' + changeLogType: issueBased + changeLogLabels: '[ + { "label" : "feature-work", "feature", "displayName" : "New Features", "state" : "closed" }, + { "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" }, + { "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" }, + { "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"}, + { "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" } + ]' From e7dfa1a2c0b79c5aa2030e2265fea19dca2b329e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 10:47:04 -0500 Subject: [PATCH 09/12] fix: reverts to a regular variable for the tag value Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 5c07e63ee..d59d69cd3 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -297,10 +297,9 @@ extends: $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" #Set Variable $artifactName and $artifactVersion - Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" + Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false;]$artifactVersion" echo "$artifactVersion" displayName: 'Fetch Artifact Name' - name: getTagVersion - task: GitHubRelease@1 displayName: 'GitHub release (edit)' condition: succeededOrFailed() @@ -308,8 +307,8 @@ extends: gitHubConnection: 'Github-MaggieKimani1' action: create tagSource: userSpecifiedTag - tag: '$(getTagVersion.artifactVersion)' - title: '$(getTagVersion.artifactVersion)' + tag: '$(artifactVersion)' + title: '$(artifactVersion)' releaseNotesSource: inline assets: '$(Pipeline.Workspace)\**\*.exe' changeLogType: issueBased From 5a824bbaecad98bf96ea1470c8792b0653c92c39 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 10:55:27 -0500 Subject: [PATCH 10/12] ci: fix artefacts path --- .azure-pipelines/ci-build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index d59d69cd3..6686bba75 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -216,7 +216,7 @@ extends: - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: - packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg' + packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg' packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' @@ -238,7 +238,7 @@ extends: vmImage: ubuntu-latest steps: - powershell: | - $fileNames = "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Workbench.*.nupkg" + $fileNames = "$(Pipeline.Workspace)/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Microsoft.OpenApi.Workbench.*.nupkg" foreach($fileName in $fileNames) { if(Test-Path $fileName) { rm $fileName -Verbose @@ -248,7 +248,7 @@ extends: - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: - packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.*.nupkg' + packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.*.nupkg' packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' @@ -272,7 +272,7 @@ extends: - task: 1ES.PublishNuget@1 displayName: 'NuGet push' inputs: - packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg' + packagesToPush: '$(Pipeline.Workspace)/Microsoft.OpenApi.Readers.*.nupkg' packageParentPath: '$(Pipeline.Workspace)' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' @@ -294,7 +294,7 @@ extends: vmImage: ubuntu-latest steps: - pwsh: | - $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 + $artifactName = Get-ChildItem -Path $(Pipeline.Workspace) -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" #Set Variable $artifactName and $artifactVersion Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false;]$artifactVersion" From a6a44a7e3d271a2cc88fda02aabec944402a32a9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 2 Jan 2025 15:51:30 -0500 Subject: [PATCH 11/12] fix: date time and date time offset shifting zones perf: avoid round trip serialization Signed-off-by: Vincent Biret --- .../Writers/OpenApiWriterAnyExtensions.cs | 67 +++++++++++++------ 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index b0ef0a174..a54753d80 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -1,7 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Collections.Generic; +using System.Globalization; using System.Text.Json; using System.Text.Json.Nodes; using Microsoft.OpenApi.Any; @@ -49,7 +51,7 @@ public static void WriteExtensions(this IOpenApiWriter writer, IDictionaryThe JsonNode value public static void WriteAny(this IOpenApiWriter writer, JsonNode node) { - Utils.CheckArgumentNull(writer);; + Utils.CheckArgumentNull(writer); if (node == null) { @@ -57,8 +59,7 @@ public static void WriteAny(this IOpenApiWriter writer, JsonNode node) return; } - var element = JsonDocument.Parse(node.ToJsonString()).RootElement; - switch (element.ValueKind) + switch (node.GetValueKind()) { case JsonValueKind.Array: // Array writer.WriteArray(node as JsonArray); @@ -67,13 +68,13 @@ public static void WriteAny(this IOpenApiWriter writer, JsonNode node) writer.WriteObject(node as JsonObject); break; case JsonValueKind.String: // Primitive - writer.WritePrimitive(element); + writer.WritePrimitive(node); break; case JsonValueKind.Number: // Primitive - writer.WritePrimitive(element); + writer.WritePrimitive(node); break; case JsonValueKind.True or JsonValueKind.False: // Primitive - writer.WritePrimitive(element); + writer.WritePrimitive(node); break; case JsonValueKind.Null: // null writer.WriteNull(); @@ -108,52 +109,74 @@ private static void WriteObject(this IOpenApiWriter writer, JsonObject entity) writer.WriteEndObject(); } - private static void WritePrimitive(this IOpenApiWriter writer, JsonElement primitive) + private static void WritePrimitive(this IOpenApiWriter writer, JsonNode primitive) { if (writer == null) { Utils.CheckArgumentNull(writer); } - if (primitive.ValueKind == JsonValueKind.String) + var valueKind = primitive.GetValueKind(); + + if (valueKind == JsonValueKind.String && primitive is JsonValue jsonStrValue) { - // check whether string is actual string or date time object - if (primitive.TryGetDateTime(out var dateTime)) + if (jsonStrValue.TryGetValue(out var dto)) { - writer.WriteValue(dateTime); + writer.WriteValue(dto); } - else if (primitive.TryGetDateTimeOffset(out var dateTimeOffset)) + else if (jsonStrValue.TryGetValue(out var dt)) { - writer.WriteValue(dateTimeOffset); + writer.WriteValue(dt); } - else + else if (jsonStrValue.TryGetValue(out var strValue)) { - writer.WriteValue(primitive.GetString()); + // check whether string is actual string or date time object + if (DateTimeOffset.TryParse(strValue, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var dateTimeOffset)) + { + writer.WriteValue(dateTimeOffset); + } + else if (DateTime.TryParse(strValue, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out var dateTime)) + { // order matters, DTO needs to be checked first!!! + writer.WriteValue(dateTime); + } + else + { + writer.WriteValue(strValue); + } } } - if (primitive.ValueKind == JsonValueKind.Number) + else if (valueKind == JsonValueKind.Number && primitive is JsonValue jsonValue) { - if (primitive.TryGetDecimal(out var decimalValue)) + + if (jsonValue.TryGetValue(out var decimalValue)) { writer.WriteValue(decimalValue); } - else if (primitive.TryGetDouble(out var doubleValue)) + else if (jsonValue.TryGetValue(out var doubleValue)) { writer.WriteValue(doubleValue); } - else if (primitive.TryGetInt64(out var longValue)) + else if (jsonValue.TryGetValue(out var floatValue)) + { + writer.WriteValue(floatValue); + } + else if (jsonValue.TryGetValue(out var longValue)) { writer.WriteValue(longValue); } - else if (primitive.TryGetInt32(out var intValue)) + else if (jsonValue.TryGetValue(out var intValue)) { writer.WriteValue(intValue); } } - if (primitive.ValueKind is JsonValueKind.True or JsonValueKind.False) + else if (valueKind is JsonValueKind.False) + { + writer.WriteValue(false); + } + else if (valueKind is JsonValueKind.True) { - writer.WriteValue(primitive.GetBoolean()); + writer.WriteValue(true); } } } From 4a50c77a90f0e9810b4912cbb694883921c508cd Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 2 Jan 2025 16:20:11 -0500 Subject: [PATCH 12/12] fix: removes useless condition for null check Signed-off-by: Vincent Biret --- src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs index a54753d80..fd2ff1387 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs @@ -111,10 +111,7 @@ private static void WriteObject(this IOpenApiWriter writer, JsonObject entity) private static void WritePrimitive(this IOpenApiWriter writer, JsonNode primitive) { - if (writer == null) - { - Utils.CheckArgumentNull(writer); - } + Utils.CheckArgumentNull(writer); var valueKind = primitive.GetValueKind();