Skip to content
This repository was archived by the owner on Apr 28, 2018. It is now read-only.

Commit da68f3a

Browse files
committed
Updating build mechanisms to work for tagging.
This change introduces a new approach for versioning the project: - The build version in the project.json file is the official central version, and must be of the form Major.Minor.Revision. No prerelease additions (ie: "-alpha") supported since PowerShell doesn't support them. - All other versions (.nuspec package metadata, .psd1 module metadata) remain at 0.0.0, which represents the version for local developer builds. - At AppVeyor build time, the project.json version is written into the .nuspec and .psd1 files. If this is a non-tagged build, it is a developer feed build and will include a build number in the version (dynamically added to the project.json as well), making the full version format Major.Minor.Revision.Build. The build number will not be included for tagged release builds.
1 parent 61667b0 commit da68f3a

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

appveyor.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '0.1.0.{build}'
1+
version: '{build}'
22
pull_requests:
33
do_not_increment_build_number: true
44
image: WMF 5
@@ -19,31 +19,38 @@ build_script:
1919
- ps: |
2020
$env:PATH = "c:\program files\dotnet;$env:PATH"
2121
22-
$version = $env:APPVEYOR_BUILD_VERSION
23-
if ($env:APPVEYOR_REPO_TAG -eq "true") {
24-
# Tags do not get build versions.
25-
$version = $version.Remove($version.LastIndexOf(".")) + ".0"
26-
}
27-
28-
# PowerShell does not support prerelease versions
29-
$psversion = $version.Split("-")[0]
30-
3122
$projectFile = "src\Docker.PowerShell\project.json"
3223
$project = Get-Content $projectFile -Raw | ConvertFrom-Json
33-
$project.version = $version
34-
ConvertTo-Json $project -Depth 100 | Out-File -Encoding UTF8 $projectFile
24+
$version = $project.version
25+
26+
# Tags do not get build versions.
27+
if ($env:APPVEYOR_REPO_TAG -ne "true") {
28+
$version += ".$($env:APPVEYOR_BUILD_VERSION)"
3529
30+
# Update the project.json version to include the build number.
31+
$project.version = $version
32+
ConvertTo-Json $project -Depth 100 | Out-File -Encoding UTF8 $projectFile
33+
}
34+
35+
# Replace module manifest version.
3636
$manifest = "src\Docker.PowerShell\Docker.psd1"
37-
(Get-Content $manifest -Raw) -replace "ModuleVersion.+","ModuleVersion = '$psversion'" | Out-File $manifest
37+
(Get-Content $manifest -Raw) -replace "ModuleVersion.+","ModuleVersion = '$version'" | Out-File $manifest
38+
39+
# Replace nuspec version.
40+
$nuspec = "$pwd\src\Docker.PowerShell\Docker.nuspec"
41+
$nuspecXML = [xml](Get-Content $nuspec)
42+
$nuspecXML.package.metadata.version = $version
43+
$nuspecXML.Save($nuspec)
3844
3945
Get-Content $projectFile
4046
Get-Content $manifest
47+
Get-Content $nuspec
4148
- ps: dotnet restore
4249
- ps: dotnet build src/Docker.PowerShell/project.json
4350
- ps: dotnet publish -f net46 -o $pwd\bin\net46 -c Release $pwd\src\Docker.PowerShell
4451
- ps: dotnet publish -f netstandard1.6 -o $pwd\bin\netstandard1.6 -c Release $pwd\src\Docker.PowerShell
4552
- ps: New-ExternalHelp -Path src\Docker.PowerShell\Help -OutputPath bin\en-US
46-
- ps: nuget pack src/Docker.PowerShell/Docker.nuspec -BasePath bin -OutputDirectory bin -Symbols -Version $psversion
53+
- ps: nuget pack src/Docker.PowerShell/Docker.nuspec -BasePath bin -OutputDirectory bin -Symbols -Version $version
4754
test_script:
4855
- ps: Register-PSRepository -Name test -SourceLocation $pwd\bin
4956
- ps: Install-Module -Name Docker -Repository test -Force
@@ -54,6 +61,7 @@ test_script:
5461
}
5562
- ps: git checkout -- src/Docker.PowerShell/Docker.psd1
5663
- ps: git checkout -- src/Docker.PowerShell/project.json
64+
- ps: git checkout -- src/Docker.PowerShell/Docker.nuspec
5765
- ps: git config core.autocrlf true
5866
- ps: New-MarkdownHelp -Module Docker -OutputFolder src\Docker.PowerShell\Help -ErrorAction SilentlyContinue
5967
- ps: Update-MarkdownHelp -Path src\Docker.PowerShell\Help

src/Docker.PowerShell/Docker.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>Docker</id>
5-
<version>0.1.0.0</version>
5+
<version>0.0.0</version>
66
<authors>Microsoft</authors>
77
<owners>microsoft</owners>
88
<licenseUrl>https://raw.githubusercontent.com/Microsoft/Docker-PowerShell/master/LICENSE</licenseUrl>

src/Docker.PowerShell/Docker.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
# Script module or binary module file associated with this manifest
1010
RootModule = "Docker.psm1"
1111

12-
# Version number of this module.
13-
ModuleVersion = '0.1.0.0'
12+
# Version number of this module. Gets replaced by appveyor at build time.
13+
ModuleVersion = '0.0.0'
1414

1515
# Minimum PowerShell version. This should match the reference assembly version
1616
# in project.json (we require 5.0 due to dependencies on parameter completion).

src/Docker.PowerShell/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.1.0-alpha",
2+
"version": "0.1.0",
33
"description": "Docker.PowerShell Cmdlet Library",
44
"dependencies": {
55
"Docker.DotNet.X509": "2.124.2",

0 commit comments

Comments
 (0)