iT邦幫忙

第 11 屆 iThome 鐵人賽

DAY 13
0
DevOps

.NET Core 專案持續整合與部署系列 第 13

Integrate:Version Number

  • 分享至 

  • xImage
  •  

今天想研究的是如何透過自動化的方式去設定專案的版本號,預期會是與 Git 做掛鉤。

首先,先安裝 GitVersionTask 這個套件:

$ dotnet add package GitVersionTask --version 5.0.1
  Writing /var/folders/hx/lgdjx1l93pq08s35hhwb0py40000gn/T/tmpSIIyRn.tmp
info : Adding PackageReference for package 'GitVersionTask' into project '/Users/ironman/dotnet-sln/WebProj/WebProj.csproj'.
info : Restoring packages for /Users/ironman/dotnet-sln/WebProj/WebProj.csproj...
info :   GET https://api.nuget.org/v3-flatcontainer/gitversiontask/index.json
info :   OK https://api.nuget.org/v3-flatcontainer/gitversiontask/index.json 934ms
info :   GET https://api.nuget.org/v3-flatcontainer/gitversiontask/5.0.1/gitversiontask.5.0.1.nupkg
info :   OK https://api.nuget.org/v3-flatcontainer/gitversiontask/5.0.1/gitversiontask.5.0.1.nupkg 1119ms
info : Installing GitVersionTask 5.0.1.
info : Package 'GitVersionTask' is compatible with all the specified frameworks in project '/Users/ironman/dotnet-sln/WebProj/WebProj.csproj'.
info : PackageReference for package 'GitVersionTask' version '5.0.1' added to file '/Users/ironman/dotnet-sln/WebProj/WebProj.csproj'.
info : Committing restore...
info : Generating MSBuild file /Users/ironman/dotnet-sln/WebProj/obj/WebProj.csproj.nuget.g.props.
info : Generating MSBuild file /Users/ironman/dotnet-sln/WebProj/obj/WebProj.csproj.nuget.g.targets.
info : Writing assets file to disk. Path: /Users/ironman/dotnet-sln/WebProj/obj/project.assets.json
log  : Restore completed in 7.47 sec for /Users/ironman/dotnet-sln/WebProj/WebProj.csproj.

然後在 Repository 根目錄下建立 GitVersion.yml 依照我們要的方式進行設定:

next-version: 1.0
mode: ContinuousDelivery
increment: Inherit
tag-prefix: '[vV]'
source-branches: ['master', 'feature', 'hotfix']
ignore:
  sha: []
  commits-before: 2019-09-29T00:00:00
branches:
  master:
    regex: master$
    mode: ContinuousDelivery
    tag: ''
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: true
  release:
    regex: releases/
    mode: ContinuousDelivery
    tag: beta
    increment: Patch
    prevent-increment-of-merged-branch-version: true
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: true
  feature:
    regex: features/
    mode: ContinuousDeployment
    tag: alpha
    increment: Minor
    prevent-increment-of-merged-branch-version: false
    track-merge-target: false
    tracks-release-branches: false
    is-release-branch: false

先記錄到這邊,預計明天會把設定檔的概念補上來。


上一篇
Integrate:Publish Mode
下一篇
Integrate:API Documents
系列文
.NET Core 專案持續整合與部署31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言