Skip to content

Commit 236529a

Browse files
authored
Improve assembly versioning (#4)
1 parent f0364c8 commit 236529a

File tree

6 files changed

+91
-25
lines changed

6 files changed

+91
-25
lines changed

.github/workflows/PRBuild.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ on: [pull_request]
55
jobs:
66
build:
77
env:
8+
BuildProps: src\GXOdata.Client.All\Directory.Build.props
89
Configuration: Release
9-
SolutionFile: GXOData.Client.sln
1010
NuspecFile: GXOData.Client.nuspec
1111
PackageFolder: build/packages/
12+
SolutionFile: GXOData.Client.sln
1213

1314
runs-on: windows-latest
1415

@@ -22,10 +23,28 @@ jobs:
2223
- name: Build
2324
run: dotnet msbuild $Env:SolutionFile -p:Configuration=$Env:Configuration
2425

25-
- name: Prepare Nuspec
26+
- name: Prepare Nuspec and Build
2627
run: |
27-
(gc $Env:NuspecFile) -replace '#GIT_BRANCH#', $Env:GITHUB_REF | Out-File -encoding ASCII $Env:NuspecFile
28-
(gc $Env:NuspecFile) -replace '#GIT_SHA#', $Env:GITHUB_SHA | Out-File -encoding ASCII $Env:NuspecFile
28+
[xml]$build_props = Get-Content $Env:BuildProps
29+
$PACKAGE_VERSION = $build_props.Project.PropertyGroup.AssemblyVersion
30+
if (!$PACKAGE_VERSION) {
31+
Write-Output "Unable to find package version in Nuspec file"
32+
exit 1
33+
}
34+
35+
$COMMITS_INTERVAL = (git describe --tags --abbrev=0) + '..HEAD'
36+
$BUILD_NUMBER = git rev-list --first-parent --count $COMMITS_INTERVAL
37+
38+
$NEW_PACKAGE_VERSION = $PACKAGE_VERSION + '-rc' + $BUILD_NUMBER
39+
40+
[xml]$xml = Get-Content $Env:NuspecFile
41+
$xml.package.metadata.version = $NEW_PACKAGE_VERSION
42+
$xml.package.metadata.repository.branch = $Env:GITHUB_REF
43+
$xml.package.metadata.repository.commit = $Env:GITHUB_SHA
44+
45+
$xml.Save($Env:NuspecFile)
46+
47+
dotnet msbuild $Env:SolutionFile -p:Configuration=$Env:Configuration /t:Clean,Build
2948
3049
- name: Package
3150
run: dotnet pack $Env:SolutionFile --output $Env:PackageFolder /p:NuspecFile=..\..\$Env:NuspecFile

.github/workflows/build.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build prerelease version of GXOdata.Client.All
1+
name: Build
22

33
on:
44
push:
@@ -10,11 +10,12 @@ on:
1010
jobs:
1111
build:
1212
env:
13+
BuildProps: src\GXOdata.Client.All\Directory.Build.props
1314
Configuration: Release
1415
NuGetRepository: http://nexus.genexus.com/repository/nuget-prereleases/
15-
SolutionFile: GXOData.Client.sln
1616
NuspecFile: GXOData.Client.nuspec
1717
PackageFolder: build/packages/
18+
SolutionFile: GXOData.Client.sln
1819

1920
runs-on: [self-hosted, windows]
2021

@@ -32,14 +33,28 @@ jobs:
3233
- name: Restore
3334
run: dotnet restore $Env:SolutionFile
3435

35-
- name: Build
36-
run: dotnet msbuild $Env:SolutionFile -p:Configuration=$Env:Configuration
37-
38-
- name: Prepare Nuspec
36+
- name: Prepare Nuspec and Build
3937
run: |
40-
(gc $Env:NuspecFile) -replace '#GIT_BRANCH#', $Env:GITHUB_REF | Out-File -encoding ASCII $Env:NuspecFile
41-
(gc $Env:NuspecFile) -replace '#GIT_SHA#', $Env:GITHUB_SHA | Out-File -encoding ASCII $Env:NuspecFile
42-
(gc $Env:NuspecFile) -replace '</version>', '-rc</version>' | Out-File -encoding ASCII $Env:NuspecFile
38+
[xml]$build_props = Get-Content $Env:BuildProps
39+
$PACKAGE_VERSION = $build_props.Project.PropertyGroup.AssemblyVersion
40+
if (!$PACKAGE_VERSION) {
41+
Write-Output "Unable to find package version in Nuspec file"
42+
exit 1
43+
}
44+
45+
$COMMITS_INTERVAL = (git describe --tags --abbrev=0) + '..HEAD'
46+
$BUILD_NUMBER = git rev-list --first-parent --count $COMMITS_INTERVAL
47+
48+
$NEW_PACKAGE_VERSION = $PACKAGE_VERSION + '-rc' + $BUILD_NUMBER
49+
50+
[xml]$xml = Get-Content $Env:NuspecFile
51+
$xml.package.metadata.version = $NEW_PACKAGE_VERSION
52+
$xml.package.metadata.repository.branch = $Env:GITHUB_REF
53+
$xml.package.metadata.repository.commit = $Env:GITHUB_SHA
54+
55+
$xml.Save($Env:NuspecFile)
56+
57+
dotnet msbuild $Env:SolutionFile -p:Configuration=$Env:Configuration /t:Clean,Build
4358
4459
- name: Package
4560
run: dotnet pack $Env:SolutionFile --output $Env:PackageFolder /p:NuspecFile=..\..\$Env:NuspecFile

.github/workflows/publish.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ on:
77
jobs:
88
build:
99
env:
10+
BuildProps: src\GXOdata.Client.All\Directory.Build.props
1011
Configuration: Release
1112
NuGetRepository: http://nexus.genexus.com/repository/nuget-hosted/
12-
SolutionFile: GXOData.Client.sln
1313
NuspecFile: GXOData.Client.nuspec
1414
PackageFolder: build/packages/
15+
SolutionFile: GXOData.Client.sln
1516

1617
runs-on: [self-hosted, windows]
1718

@@ -29,13 +30,28 @@ jobs:
2930
- name: Restore
3031
run: dotnet restore $Env:SolutionFile
3132

32-
- name: Build
33-
run: dotnet msbuild $Env:SolutionFile -p:Configuration=$Env:Configuration
34-
35-
- name: Prepare Nuspec
33+
- name: Prepare Nuspec and Build
3634
run: |
37-
(gc $Env:NuspecFile) -replace '#GIT_BRANCH#', $Env:GITHUB_REF | Out-File -encoding ASCII $Env:NuspecFile
38-
(gc $Env:NuspecFile) -replace '#GIT_SHA#', $Env:GITHUB_SHA | Out-File -encoding ASCII $Env:NuspecFile
35+
[xml]$build_props = Get-Content $Env:BuildProps
36+
$PACKAGE_VERSION = $build_props.Project.PropertyGroup.AssemblyVersion
37+
if (!$PACKAGE_VERSION) {
38+
Write-Output "Unable to find package version in Nuspec file"
39+
exit 1
40+
}
41+
42+
$COMMITS_INTERVAL = (git describe --tags --abbrev=0) + '..HEAD'
43+
$BUILD_NUMBER = git rev-list --first-parent --count $COMMITS_INTERVAL
44+
45+
$NEW_PACKAGE_VERSION = $PACKAGE_VERSION + '-rc' + $BUILD_NUMBER
46+
47+
[xml]$xml = Get-Content $Env:NuspecFile
48+
$xml.package.metadata.version = $NEW_PACKAGE_VERSION
49+
$xml.package.metadata.repository.branch = $Env:GITHUB_REF
50+
$xml.package.metadata.repository.commit = $Env:GITHUB_SHA
51+
52+
$xml.Save($Env:NuspecFile)
53+
54+
dotnet msbuild $Env:SolutionFile -p:Configuration=$Env:Configuration /t:Clean,Build
3955
4056
- name: Package
4157
run: dotnet pack $Env:SolutionFile --output $Env:PackageFolder /p:NuspecFile=..\..\$Env:NuspecFile

GXOData.Client.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
44
<id>GXOdata.Client</id>
55
<authors>Vagif Abilov and GeneXus</authors>
6-
<version>5.2.3</version>
6+
<version></version>
77
<owners>Vagif Abilov</owners>
88
<description>
99
GXOdata.Client is a multiplatform OData client library supporting .NET 4.x, .NET Standard, .NET Core, iOS and Android. The adapter provides a great alternative to WCF Data Services client. It does not require generation of context or entity classes and fits RESTful nature of OData services.
@@ -13,7 +13,7 @@
1313
GXOdata.Client is a multiplatform OData client library supporting .NET 4.x, .NET Standard, .NET Core, iOS and Android. The adapter provides a great alternative to WCF Data Services client. It does not require generation of context or entity classes and fits RESTful nature of OData services.
1414
The package GXOdata.Client contains libraries that can work with OData feeds that implement both V1-3 and V4 OData protocol.
1515
</summary>
16-
<repository type="git" url="https://github.com/genexuslabs/Simple.OData.Client.git" branch="#GIT_BRANCH#" commit="#GIT_SHA#" />
16+
<repository type="git" url="https://github.com/genexuslabs/Simple.OData.Client.git" branch="" commit="" />
1717
<license type="expression">MIT</license>
1818
<copyright>Copyright 2012-2018 Vagif Abilov</copyright>
1919
<language>en-us</language>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project>
2+
<PropertyGroup>
3+
<AssemblyVersion>5.2.3.1</AssemblyVersion>
4+
<FileVersion>$(AssemblyVersion)</FileVersion>
5+
<InformationalVersion>$([System.DateTime]::UtcNow.ToString("yyyyMMddHHmmss")).$(GITHUB_SHA)</InformationalVersion>
6+
<Company>GeneXus</Company>
7+
<CopyrightYear>$([System.DateTime]::UtcNow.ToString("yyyy"))</CopyrightYear>
8+
<Copyright>Copyright © 1988-$(CopyrightYear) GeneXus. All Rights Reserved</Copyright>
9+
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
10+
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
11+
<Authors>GeneXus</Authors>
12+
<RepositoryType>git</RepositoryType>
13+
</PropertyGroup>
14+
</Project>

src/GXOdata.Client.All/GXOData.Client.All.csproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<!-->TargetFrameworks>net452;netstandard2.0</TargetFrameworks-->
43
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
5-
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
64
<RootNamespace>Simple.OData.Client</RootNamespace>
75
<OutputPath>$(SolutionDir)/build/$(Configuration)/$(AssemblyName)/$(TargetFramework)/</OutputPath>
86
<OutDir>$(OutputPath)</OutDir>
@@ -44,4 +42,8 @@
4442
<Compile Include="..\Simple.OData.Client.V4.Adapter\**\*.cs" Exclude="**\AssemblyInfo.cs" Label="V4Adapter" />
4543
</ItemGroup>
4644

45+
<ItemGroup>
46+
<Compile Remove="Properties\CommonAssemblyVersion.cs" />
47+
</ItemGroup>
48+
4749
</Project>

0 commit comments

Comments
 (0)