diff --git a/.azure-pipelines/clocks.net-buddy.yml b/.azure-pipelines/clocks.net-buddy.yml index 89b6d5ac..03246459 100644 --- a/.azure-pipelines/clocks.net-buddy.yml +++ b/.azure-pipelines/clocks.net-buddy.yml @@ -13,33 +13,16 @@ variables: steps: - script: exit 1 + displayName: Check if is main branch condition: ne(variables['Build.SourceBranch'], 'refs/heads/main') -- task: AzureKeyVault@2 - inputs: - connectedServiceName: 'Isolated' - keyVaultName: 'shuaizhang-akv' - secretsFilter: 'NuGetOrgApiKey' - - template: /.azure-pipelines/build.yml@self parameters: isOfficial: 'false' packProjects: 'true' projects: 'Clocks.Net/dirs.proj' -- script: | - git config user.name "Azure DevOps Build Bot" - git config user.email "zhangshuai.ustc+devopsbot@gmail.com" - git tag -a "Clocks.Net/$(NBGV_CloudBuildNumber)" -m "Created by Azure DevOps Build Pipeline" - git push origin "$(NBGV_CloudBuildNumber)" - displayName: 'Create git tag' - -- task: GitHubRelease@0 - displayName: 'Create GitHub release' - inputs: - gitHubConnection: GitHub - isPreRelease: true - assets: $(Build.SourcesDirectory)/artifacts/packages/** - -- script: dotnet nuget push $(Build.SourcesDirectory)\artifacts\packages\*.nupkg --source https://api.nuget.org/v3/index.json --api-key $(NuGetOrgApiKey) - displayName: 'Push NuGet packages to nuget.org' +- template: /.azure-pipelines/publish.yml@self + parameters: + isOfficial: 'false' + tagPrefix: 'Clocks.Net' diff --git a/.azure-pipelines/publish.yml b/.azure-pipelines/publish.yml new file mode 100644 index 00000000..cdccc480 --- /dev/null +++ b/.azure-pipelines/publish.yml @@ -0,0 +1,38 @@ +parameters: +- name: isOfficial + type: boolean + default: false +- name: tagPrefix + type: string + +steps: +- ${{ if parameters.isOfficial }}: + - script: | + git config user.name "Azure DevOps Build Bot" + git config user.email "zhangshuai.ustc+devopsbot@gmail.com" + git tag -a "${{ parameters.tagPrefix }}/$(NBGV_CloudBuildNumber)" -m "Created by Azure DevOps Build Pipeline" + git push origin "${{ parameters.tagPrefix }}/$(NBGV_CloudBuildNumber)" + displayName: 'Create git tag' + + - task: GitHubRelease@0 + displayName: 'Create GitHub release' + inputs: + gitHubConnection: GitHub + isPreRelease: '${{ eq(parameters.isOfficial, false) }}' + assets: $(Build.SourcesDirectory)/artifacts/packages/** + + - task: AzureKeyVault@2 + displayName: Get ApiKey from Azure KeyVault + inputs: + connectedServiceName: 'Isolated' + keyVaultName: 'shuaizhang-akv' + secretsFilter: 'NuGetOrgApiKey' + + - script: dotnet nuget push $(Build.SourcesDirectory)\artifacts\packages\*.nupkg --source https://api.nuget.org/v3/index.json --api-key $(NuGetOrgApiKey) + displayName: 'Push NuGet packages to nuget.org' +- ${{ else }}: + - task: NuGetAuthenticate@1 + displayName: Setup NuGet authentication + + - script: dotnet nuget push $(Build.SourcesDirectory)\artifacts\packages\*.nupkg --source https://pkgs.dev.azure.com/zhangshuai89/4debf70e-9948-4d59-9745-b27035b12245/_packaging/OneDotNet/nuget/v3/index.json --api-key AzureDevOps" + displayName: 'Push NuGet packages to internal feed'