From 1cd7282b0d2ca78aade388d2d30407691ad36262 Mon Sep 17 00:00:00 2001 From: Aleksey Usatov Date: Tue, 16 Nov 2021 00:55:43 +0300 Subject: [PATCH 1/4] Use templating to set version --- .azure-pipelines/ci.yml | 10 ++----- .azure-pipelines/release-pipeline.yml | 18 ++++------- .azure-pipelines/setVersionVariables.js | 40 ------------------------- .azure-pipelines/variables.yml | 12 ++++++++ Telegram.Bot.sln | 1 - 5 files changed, 20 insertions(+), 61 deletions(-) delete mode 100644 .azure-pipelines/setVersionVariables.js diff --git a/.azure-pipelines/ci.yml b/.azure-pipelines/ci.yml index 368de31bf..d10afce4f 100644 --- a/.azure-pipelines/ci.yml +++ b/.azure-pipelines/ci.yml @@ -25,12 +25,6 @@ stages: pool: vmImage: $(vmImage) steps: - - script: node .azure-pipelines/setVersionVariables.js - env: - VERSION_PREFIX: $(versionPrefix) - VERSION_SUFFIX: $(versionSuffix) - CI_VERSION_SUFFIX: $(ciVersionSuffix) - displayName: Set version variables - task: DotNetCoreCLI@2 displayName: Build project with CI version inputs: @@ -38,14 +32,14 @@ stages: projects: $(projectPath) arguments: > --configuration $(buildConfiguration) - -p:Version=$(CI_VERSION) + -p:Version=$(ciVersion) -p:CI_EMBED_SYMBOLS=true - bash: > dotnet pack --no-build --output "$(Build.ArtifactStagingDirectory)/packages" --configuration $(buildConfiguration) - -p:Version=$(CI_VERSION) + -p:Version=$(ciVersion) -p:CI_EMBED_SYMBOLS=true $(projectPath) displayName: Create CI nuget package diff --git a/.azure-pipelines/release-pipeline.yml b/.azure-pipelines/release-pipeline.yml index ee001b28b..af91ae03e 100644 --- a/.azure-pipelines/release-pipeline.yml +++ b/.azure-pipelines/release-pipeline.yml @@ -20,12 +20,6 @@ pool: vmImage: $(vmImage) steps: - - script: node .azure-pipelines/setVersionVariables.js - env: - VERSION_PREFIX: $(versionPrefix) - VERSION_SUFFIX: $(versionSuffix) - CI_VERSION_SUFFIX: $(ciVersionSuffix) - displayName: Set version variables - task: DotNetCoreCLI@2 displayName: Build project with release version inputs: @@ -33,13 +27,13 @@ steps: projects: $(projectPath) arguments: > --configuration $(buildConfiguration) - -p:Version=$(RELEASE_VERSION) + -p:Version=$(releaseVersion) - bash: > dotnet pack --no-build --output "$(Build.ArtifactStagingDirectory)/packages" --configuration $(buildConfiguration) - -p:Version=$(RELEASE_VERSION) + -p:Version=$(releaseVersion) $(projectPath) displayName: Create release nuget package - bash: > @@ -54,12 +48,12 @@ steps: action: create target: $(Build.SourceVersion) tagSource: manual - tag: v$(RELEASE_VERSION) - tagPattern: v$(RELEASE_VERSION) - title: v$(RELEASE_VERSION) + tag: v$(releaseVersion) + tagPattern: v$(releaseVersion) + title: v$(releaseVersion) githubConnection: githubRelease repositoryName: $(Build.Repository.Name) - isPreRelease: $(IS_PRE_RELEASE) + isPreRelease: $(isPreRelease) addChangeLog: false assets: $(Build.ArtifactStagingDirectory)/packages/* displayName: Create Github Release diff --git a/.azure-pipelines/setVersionVariables.js b/.azure-pipelines/setVersionVariables.js deleted file mode 100644 index 26caba23f..000000000 --- a/.azure-pipelines/setVersionVariables.js +++ /dev/null @@ -1,40 +0,0 @@ -const assert = require('assert').strict; - -const prefix = process.env['VERSION_PREFIX']; -const suffix = process.env['VERSION_SUFFIX']; -const ciSuffix = process.env['CI_VERSION_SUFFIX']; - -const prefixRegex = /[0-9]+\.[0-9]+\.[0-9]+/; -const ciSuffixRegex = /ci\.[0-9]+\+git\.commit\.[0-9a-z]{40}/; - -assert.ok(prefix, "Version prefix is empty"); -assert.ok(ciSuffix, "CI version suffix is empty"); -assert.ok(prefixRegex.test(prefix), "Version prefix is invalid"); -assert.ok(ciSuffixRegex.test(ciSuffix), "CI version prefix is invalid"); - -const releaseVersionCommand = createCommand( - 'RELEASE_VERSION', - suffix && suffix.length > 0 - ? `${prefix}-${suffix}` - : `${prefix}` -); - -const ciVersionCommand = createCommand( - 'CI_VERSION', - suffix && suffix.length > 0 - ? `${prefix}-${suffix}.${ciSuffix}` - : `${prefix}-${ciSuffix}` -); - -const isPreRelease = createCommand( - 'IS_PRE_RELEASE', - suffix && suffix.length > 0 ? true : false -); - -console.log(releaseVersionCommand); -console.log(ciVersionCommand); -console.log(isPreRelease); - -function createCommand(key, value) { - return `##vso[task.setvariable variable=${key};]${value}` -} diff --git a/.azure-pipelines/variables.yml b/.azure-pipelines/variables.yml index 3554ca6bd..234125db5 100644 --- a/.azure-pipelines/variables.yml +++ b/.azure-pipelines/variables.yml @@ -6,6 +6,18 @@ variables: value: "alpha.5" - name: ciVersionSuffix value: ci.$(Build.BuildId)+git.commit.$(Build.SourceVersion) + - name: isPreRelease + value: ${{ ne(variables.versionSuffix, '') }} + - name: releaseVersion + ${{ if eq(variables.isPreRelease, true) }}: + value: $(versionPrefix)-$(versionSuffix) + ${{ else }}: + value: $(versionPrefix) + - name: ciVersion + ${{ if eq(variables.isPreRelease, true) }}: + value: $(versionPrefix)-$(versionSuffix).$(ciVersionSuffix) + ${{ else }}: + value: $(versionPrefix)-$(ciVersionSuffix) - name: buildConfiguration value: Release - name: vmImage diff --git a/Telegram.Bot.sln b/Telegram.Bot.sln index ab9a5cdae..879fd9536 100644 --- a/Telegram.Bot.sln +++ b/Telegram.Bot.sln @@ -28,7 +28,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".azure-pipelines", ".azure- .azure-pipelines\develop-pipeline.yml = .azure-pipelines\develop-pipeline.yml .azure-pipelines\manual-pipeline.yml = .azure-pipelines\manual-pipeline.yml .azure-pipelines\release-pipeline.yml = .azure-pipelines\release-pipeline.yml - .azure-pipelines\setVersionVariables.js = .azure-pipelines\setVersionVariables.js .azure-pipelines\variables.yml = .azure-pipelines\variables.yml EndProjectSection EndProject From 2014bb7e9cf7363498012b80ce99e3192caf4396 Mon Sep 17 00:00:00 2001 From: Aleksey Usatov Date: Tue, 16 Nov 2021 00:56:23 +0300 Subject: [PATCH 2/4] Update images --- .azure-pipelines/develop-pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/develop-pipeline.yml b/.azure-pipelines/develop-pipeline.yml index fcb297586..e0bd62964 100644 --- a/.azure-pipelines/develop-pipeline.yml +++ b/.azure-pipelines/develop-pipeline.yml @@ -24,9 +24,9 @@ stages: buildConfiguration: $(buildConfiguration) projects: $(unitTestsProject) strategies: - - Windows: windows-2019 + - Windows: windows-2022 - Ubuntu: ubuntu-20.04 - - macOS: macOS-10.15 + - macOS: macOS-11 - stage: IntegrationTests displayName: 🧪 Integration tests jobs: From c08efa60942b32a929f0332e3c7e1b3a2941da5e Mon Sep 17 00:00:00 2001 From: Aleksey Usatov Date: Wed, 17 Nov 2021 14:38:51 +0000 Subject: [PATCH 3/4] Add gitpod config --- .gitpod.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..5dc5877cf --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1 @@ +image: gitpod/workspace-dotnet \ No newline at end of file From fa58c90644a09f85c840c444d50dec9463756322 Mon Sep 17 00:00:00 2001 From: Aleksey Usatov Date: Wed, 17 Nov 2021 14:42:44 +0000 Subject: [PATCH 4/4] Remove prelease suffix --- .azure-pipelines/variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/variables.yml b/.azure-pipelines/variables.yml index 234125db5..2b598ec00 100644 --- a/.azure-pipelines/variables.yml +++ b/.azure-pipelines/variables.yml @@ -3,7 +3,7 @@ variables: - name: versionPrefix value: 17.0.0 - name: versionSuffix - value: "alpha.5" + value: '' - name: ciVersionSuffix value: ci.$(Build.BuildId)+git.commit.$(Build.SourceVersion) - name: isPreRelease