Skip to content

Commit f80a960

Browse files
Merge pull request #1245 from SixLabors/js/gitversion-mainline
Better Builds
2 parents ab8ab39 + 9657ac0 commit f80a960

File tree

10 files changed

+49
-59
lines changed

10 files changed

+49
-59
lines changed

.github/workflows/build-and-test.yml

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,14 @@ jobs:
5252
git fetch --prune --unshallow
5353
git submodule -q update --init --recursive
5454
55-
- name: Fetch Tags for GitVersion
56-
run: |
57-
git fetch --tags
58-
59-
- name: Fetch master for GitVersion
60-
if: github.ref != 'refs/heads/master'
61-
run: git branch --create-reflog master origin/master
62-
63-
- name: Install GitVersion
64-
uses: gittools/actions/gitversion/setup@v0.9.3
65-
with:
66-
versionSpec: "5.3.x"
67-
68-
- name: Use GitVersion
69-
id: gitversion # step id used as reference for output values
70-
uses: gittools/actions/gitversion/execute@v0.9.3
71-
7255
- name: Setup DotNet SDK
7356
uses: actions/setup-dotnet@v1
7457
with:
75-
dotnet-version: "3.1.101"
58+
dotnet-version: "3.1.x"
7659

7760
- name: Build
7861
shell: pwsh
79-
run: ./ci-build.ps1 "${{steps.gitversion.outputs.nuGetVersion}}" "${{matrix.options.framework}}"
62+
run: ./ci-build.ps1 "${{matrix.options.framework}}"
8063

8164
- name: Test
8265
shell: pwsh
@@ -112,33 +95,18 @@ jobs:
11295
git fetch --prune --unshallow
11396
git submodule -q update --init --recursive
11497
115-
- name: Fetch Tags for GitVersion
116-
run: |
117-
git fetch --tags
118-
119-
- name: Fetch master for GitVersion
120-
if: github.ref != 'refs/heads/master'
121-
run: git branch --create-reflog master origin/master
122-
123-
- name: Install GitVersion
124-
uses: gittools/actions/gitversion/setup@v0.9.3
125-
with:
126-
versionSpec: "5.3.x"
127-
128-
- name: Use GitVersion
129-
id: gitversion # step id used as reference for output values
130-
uses: gittools/actions/gitversion/execute@v0.9.3
131-
13298
- name: Setup DotNet SDK
13399
uses: actions/setup-dotnet@v1
134100
with:
135-
dotnet-version: "3.1.101"
101+
dotnet-version: "3.1.x"
136102

137103
- name: Pack
138104
shell: pwsh
139-
run: ./ci-pack.ps1 "${{steps.gitversion.outputs.nuGetVersion}}"
105+
run: ./ci-pack.ps1
140106

141107
- name: Publish to MyGet
142108
shell: pwsh
143-
run: nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package
109+
run: |
110+
nuget.exe push .\artifacts\*.nupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v2/package
111+
nuget.exe push .\artifacts\*.snupkg ${{secrets.MYGET_TOKEN}} -Source https://www.myget.org/F/sixlabors/api/v3/index.json
144112
# TODO: If github.ref starts with 'refs/tags' then it was tag push and we can optionally push out package to nuget.org

Directory.Build.props

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
<DebugType Condition="'$(codecov)' != ''">full</DebugType>
2626
<NullableContextOptions>disable</NullableContextOptions>
2727
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
28-
<SignAssembly>false</SignAssembly>
2928
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
3029
</PropertyGroup>
3130

@@ -93,6 +92,12 @@
9392
<VersionSuffix></VersionSuffix>
9493
</PropertyGroup>
9594

95+
<!--MinVer Properties for versioning-->
96+
<PropertyGroup>
97+
<MinVerTagPrefix>v</MinVerTagPrefix>
98+
<MinVerVerbosity>normal</MinVerVerbosity>
99+
</PropertyGroup>
100+
96101
<!-- Default settings that are otherwise undefined -->
97102
<PropertyGroup>
98103
<Copyright>Copyright © Six Labors</Copyright>

Directory.Build.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
<PackageReference Update="StyleCop.Analyzers" PrivateAssets="All" Version="1.1.118" />
2424

2525
<!--Src Dependencies-->
26+
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
27+
<PackageReference Update="MinVer" PrivateAssets="All" Version="2.3.0" />
2628
<PackageReference Update="System.Buffers" Version="4.5.0" />
2729
<PackageReference Update="System.IO.Compression" Version="4.3.0" />
2830
<PackageReference Update="System.IO.UnmanagedMemoryStream" Version="4.3.0" />

GitVersion.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ci-build.ps1

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
param(
2-
[Parameter(Mandatory, Position = 0)]
3-
[string]$version,
4-
[Parameter(Mandatory = $true, Position = 1)]
2+
[Parameter(Mandatory = $true, Position = 0)]
53
[string]$targetFramework
64
)
75

@@ -10,4 +8,4 @@ dotnet clean -c Release
108
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
119

1210
# Building for a specific framework.
13-
dotnet build -c Release -f $targetFramework /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl
11+
dotnet build -c Release -f $targetFramework /p:RepositoryUrl=$repositoryUrl

ci-pack.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
param(
2-
[Parameter(Mandatory, Position = 0)]
3-
[string]$version
4-
)
5-
61
dotnet clean -c Release
72

83
$repositoryUrl = "https://github.com/$env:GITHUB_REPOSITORY"
94

105
# Building for packing and publishing.
11-
dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:packageversion=$version /p:RepositoryUrl=$repositoryUrl
6+
dotnet pack -c Release --output "$PSScriptRoot/artifacts" /p:RepositoryUrl=$repositoryUrl

src/Directory.Build.props

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@
2626
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
2727
</PropertyGroup>
2828

29+
<!--Add deterministic builds in CI-->
30+
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
31+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
32+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
33+
</PropertyGroup>
34+
35+
<PropertyGroup>
36+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
37+
<!-- Build symbol package (.snupkg) to distribute the PDB containing Source Link -->
38+
<IncludeSymbols>true</IncludeSymbols>
39+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
40+
</PropertyGroup>
41+
2942
<ItemGroup>
3043
<!-- DynamicProxyGenAssembly2 is needed so Moq can use our internals -->
3144
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" PublicKey="0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7" />

src/Directory.Build.targets

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@
2020
<GeneratedInternalsVisibleToFile Condition="'$(GeneratedInternalsVisibleToFile)' == ''">$(IntermediateOutputPath)$(MSBuildProjectName).InternalsVisibleTo$(DefaultLanguageSourceExtension)</GeneratedInternalsVisibleToFile>
2121
</PropertyGroup>
2222

23+
<!-- Workaround for running Coverlet with Determenistic builds -->
24+
<!-- https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DeterministicBuild.md -->
25+
<Target Name="CoverletGetPathMap"
26+
DependsOnTargets="InitializeSourceRootMappedPaths"
27+
Returns="@(_LocalTopLevelSourceRoot)"
28+
Condition="'$(DeterministicSourcePaths)' == 'true'">
29+
<ItemGroup>
30+
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
31+
</ItemGroup>
32+
</Target>
33+
2334
<ItemDefinitionGroup>
2435
<InternalsVisibleTo>
2536
<Visible>false</Visible>
@@ -51,7 +62,7 @@
5162
<!-- Empty target so that `dotnet test` will work on the solution -->
5263
<!-- https://github.com/Microsoft/vstest/issues/411 -->
5364
<Target Name="VSTest" Condition="'$(IsTestProject)' == 'true'"/>
54-
65+
5566
<ItemGroup>
5667
<!--Shared config files that have to exist at root level.-->
5768
<ConfigFilesToCopy Include="..\..\shared-infrastructure\.editorconfig;..\..\shared-infrastructure\.gitattributes" />

src/ImageSharp/ImageSharp.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
<RootNamespace>SixLabors.ImageSharp</RootNamespace>
2020
</PropertyGroup>
2121

22+
<ItemGroup>
23+
<PackageReference Include="Microsoft.SourceLink.GitHub"/>
24+
<PackageReference Include="MinVer" PrivateAssets="All" />
25+
</ItemGroup>
26+
2227
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
2328
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
2429
</ItemGroup>

tests/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<PackageReference Update="BenchmarkDotNet" Version="0.12.0" />
2929
<PackageReference Update="BenchmarkDotNet.Diagnostics.Windows" Version="0.12.0" Condition="'$(OS)' == 'Windows_NT'" />
3030
<PackageReference Update="Colourful" Version="2.0.3" />
31-
<PackageReference Update="coverlet.collector" Version="1.2.0" PrivateAssets="All"/>
31+
<PackageReference Update="coverlet.collector" Version="1.3.0" PrivateAssets="All"/>
3232
<PackageReference Update="Magick.NET-Q16-AnyCPU" Version="7.15.5" />
3333
<PackageReference Update="Microsoft.DotNet.RemoteExecutor" Version="5.0.0-beta.20069.1" />
3434
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20200116-01" />

0 commit comments

Comments
 (0)