From 166747f21d904c493603b5f84b6f72606a33c66b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Fri, 20 Dec 2024 09:47:07 -0500 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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" } + ]'