Skip to content

Commit e79a7eb

Browse files
authored
build: Update dependencies, add Publish workflow (#100)
* build: Use .NET Core SDK v3.1.200 * style: Abstract class ctor now protected * ci: Set ci configuration to Release * style: Refactor Directory.Build.props * deps: Update to CG.R v0.7, RecGen v0.6 * ci: Add publish workflow * fix: Apply code quality warning fixes * tests: Don't close stream too early
1 parent 42abba7 commit e79a7eb

38 files changed

Lines changed: 157 additions & 109 deletions

File tree

.github/workflows/ci.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,38 @@
11
name: CI
2-
32
on: [push, pull_request]
4-
53
jobs:
64
build:
75
strategy:
86
matrix:
97
os: [ubuntu-latest, windows-latest]
108
BuildConfiguration: [Release]
9+
env:
10+
DOTNET_NOLOGO: 1
11+
Configuration: ${{ matrix.BuildConfiguration }}
1112
runs-on: ${{ matrix.os }}
1213
steps:
13-
- uses: actions/checkout@v1
14-
- uses: actions/setup-dotnet@v1
15-
- run: dotnet --info
16-
- run: dotnet tool restore
17-
- name: NuGet restore
18-
run: dotnet restore -v m
19-
- name: Build
20-
shell: pwsh
21-
run: dotnet build --no-restore -c ${{ matrix.BuildConfiguration }}
22-
- name: Test
23-
shell: pwsh
24-
run: dotnet test --no-build -c ${{ matrix.BuildConfiguration }}
25-
- name: Publish NuGet artifacts
26-
uses: actions/upload-artifact@v1
27-
with:
28-
name: nugets-${{ runner.os }}
29-
path: bin/Packages/${{ matrix.BuildConfiguration }}
14+
- uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0 # all history
17+
- name: Read .NET Core SDK version
18+
id: globaljson
19+
shell: pwsh
20+
run: |
21+
dotnet --version
22+
if ($LASTEXITCODE -ne 0) { # if dotnet didn't find version required by globaljson, it exits with non-0 code
23+
Write-Host "::set-output name=version::$((Get-Content global.json -Raw | ConvertFrom-Json).sdk.version)"
24+
}
25+
- uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: ${{ steps.globaljson.outputs.version }}
28+
- run: dotnet --info
29+
- run: dotnet tool restore
30+
- run: dotnet nbgv get-version
31+
- run: dotnet restore -v m
32+
- run: dotnet build --no-restore
33+
- run: dotnet test --no-build
34+
- name: Publish NuGet artifacts
35+
uses: actions/upload-artifact@v2
36+
with:
37+
name: nugets-${{ runner.os }}
38+
path: bin/Packages/${{ env.Configuration }}

.github/workflows/publish.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
publish-nugets:
7+
runs-on: ubuntu-latest
8+
env:
9+
DOTNET_NOLOGO: 1
10+
Configuration: Release
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0 # all history
15+
- name: Read .NET Core SDK version
16+
id: globaljson
17+
shell: pwsh
18+
run: |
19+
dotnet --version
20+
if ($LASTEXITCODE -ne 0) { # if dotnet didn't find version required by globaljson, it exits with non-0 code
21+
Write-Host "::set-output name=version::$((Get-Content global.json -Raw | ConvertFrom-Json).sdk.version)"
22+
}
23+
- uses: actions/setup-dotnet@v1
24+
with:
25+
dotnet-version: ${{ steps.globaljson.outputs.version }}
26+
- run: dotnet --info
27+
- run: dotnet tool restore
28+
- run: dotnet nbgv get-version
29+
- run: dotnet restore -v m
30+
- run: dotnet build --no-restore
31+
- run: dotnet test --no-build
32+
- name: Upload nugets to workflow artifacts
33+
uses: actions/upload-artifact@v2
34+
with:
35+
name: nugets
36+
path: bin/Packages/${{ env.Configuration }}
37+
- name: Publish to NuGet.org
38+
shell: pwsh
39+
run: |
40+
dotnet nuget push bin/Packages/${{ env.Configuration }}/*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_APIKEY }}
41+
# TODO Upload packages to release assets

Directory.Build.props

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,34 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22

33
<PropertyGroup>
4+
<LangVersion>8</LangVersion>
45
<Authors>Amadeusz Sadowski</Authors>
56
<Company>WarHub</Company>
67
<Copyright>Copyright © Amadeusz Sadowski</Copyright>
78
<PackageLicenseExpression>MIT</PackageLicenseExpression>
89
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
910
<PackageProjectUrl>https://github.com/WarHub/wham</PackageProjectUrl>
10-
<ReleaseNotes>https://github.com/WarHub/wham/blob/master/CHANGELOG.md</ReleaseNotes>
11+
<PackageReleaseNotes>https://github.com/WarHub/wham/blob/master/CHANGELOG.md</PackageReleaseNotes>
12+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
13+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
14+
<IncludeSymbols>true</IncludeSymbols>
15+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
16+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1117
</PropertyGroup>
1218

1319
<PropertyGroup>
14-
<LangVersion>8</LangVersion>
15-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1620
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
17-
<WarningsAsErrors Condition=" '$(Configuration)' == Release ">true</WarningsAsErrors>
18-
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
21+
<IsTestingOnlyProject>$(MSBuildProjectName.Contains('Test'))</IsTestingOnlyProject>
1922
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj/$(MSBuildProjectName)/</BaseIntermediateOutputPath>
2023
<OutputPath>$(MSBuildThisFileDirectory)bin/$(MSBuildProjectName)/$(Configuration)/</OutputPath>
2124
<PackageOutputPath>$(MSBuildThisFileDirectory)bin/Packages/$(Configuration)/</PackageOutputPath>
22-
<IsTestingOnlyProject>$(MSBuildProjectName.Contains('Test'))</IsTestingOnlyProject>
2325
<NoWarn>$(NoWarn);CS1591;NU5105</NoWarn>
2426
</PropertyGroup>
2527

26-
<PropertyGroup Condition=" !$(IsTestingOnlyProject) ">
27-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
28-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
29-
<IncludeSymbols>true</IncludeSymbols>
30-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
28+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
29+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
30+
<MSBuildTreatWarningsAsErrors>true</MSBuildTreatWarningsAsErrors>
31+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
3132
</PropertyGroup>
3233

3334
<PropertyGroup Condition=" $(IsTestingOnlyProject) ">
@@ -36,7 +37,6 @@
3637
</PropertyGroup>
3738

3839
<ItemGroup>
39-
<DotNetCliToolReference Include="dotnet-codegen" Version="0.6.1" />
4040
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
4141
</ItemGroup>
4242

Packages.props

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

44
<ItemGroup>
5-
<PackageReference Update="Amadevus.RecordGenerator" Version="[0.4.1]" PrivateAssets="all" />
6-
<PackageReference Update="CodeGeneration.Roslyn" Version="[0.6.1]" />
7-
<PackageReference Update="CodeGeneration.Roslyn.BuildTime" Version="[0.6.1]" PrivateAssets="all" />
8-
<PackageReference Update="morelinq" Version="[3.2.0]" />
9-
<PackageReference Update="Newtonsoft.Json" Version="[11.0.2]" />
10-
<PackageReference Update="Optional" Version="[4.0.0]" />
11-
<PackageReference Update="Serilog" Version="[2.8.0]" />
12-
<PackageReference Update="Serilog.Sinks.Console" Version="[3.1.1]" />
13-
<PackageReference Update="System.Collections.Immutable" Version="[1.5.0]" />
14-
<PackageReference Update="System.CommandLine.Experimental" Version="[0.3.0-alpha.19405.1]" />
5+
<PackageReference Update="Amadevus.RecordGenerator" Version="[0.6.0]" PrivateAssets="all" />
6+
<PackageReference Update="CodeGeneration.Roslyn" Version="[0.7.63]" />
7+
<PackageReference Update="CodeGeneration.Roslyn.Attributes" Version="[0.7.63]" PrivateAssets="all" ExcludeAssets="runtime" />
8+
<PackageReference Update="CodeGeneration.Roslyn.Tool" Version="[0.7.63]" PrivateAssets="all" />
9+
<PackageReference Update="morelinq" Version="3.2.0" />
10+
<PackageReference Update="Newtonsoft.Json" Version="11.0.2" />
11+
<PackageReference Update="Optional" Version="4.0.0" />
12+
<PackageReference Update="Serilog" Version="2.8.0" />
13+
<PackageReference Update="Serilog.Sinks.Console" Version="3.1.1" />
14+
<PackageReference Update="System.Collections.Immutable" Version="1.5.0" />
15+
<PackageReference Update="System.CommandLine.Experimental" Version="0.3.0-alpha.19405.1" />
1516
</ItemGroup>
1617

1718
<ItemGroup Label="Tests">
@@ -25,9 +26,9 @@
2526

2627
<ItemGroup>
2728
<GlobalPackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers"
28-
Version="2.9.7"/>
29+
Version="3.0.0"/>
2930
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub"
30-
Version="1.0.0-beta2-19554-01"
31+
Version="1.0.0"
3132
Condition=" !$(IsTestingOnlyProject) " />
3233
<GlobalPackageReference Include="Nerdbank.GitVersioning"
3334
Version="3.0.26" />

azure-pipelines.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ pool:
77

88
variables:
99
BuildConfiguration: 'Release'
10-
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
10+
DOTNET_NOLOGO: true
1111

1212
steps:
1313
- task: UseDotNet@2
14-
displayName: 'Install .NET Core SDK 3.0'
14+
displayName: 'Install .NET Core SDK'
1515
inputs:
1616
useGlobalJson: true
1717
performMultiLevelLookup: true
18-
- task: UseDotNet@2
19-
displayName: 'Install .NET Core SDK 2.2'
20-
inputs:
21-
version: '2.2.x'
22-
performMultiLevelLookup: true
2318

2419
- script: dotnet tool restore
2520
displayName: Restore dotnet tools

global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"sdk": {
3-
"version": "3.0.100"
3+
"version": "3.1.201"
44
},
55
"msbuild-sdks": {
6+
"CodeGeneration.Roslyn.Plugin.Sdk": "0.7.63",
67
"Microsoft.Build.CentralPackageVersions": "2.0.52"
78
}
89
}

src/WarHub.ArmouryModel.CliTool/Commands/PublishCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Immutable;
44
using System.IO;
55
using System.Linq;
6+
using Amadevus.RecordGenerator;
67
using WarHub.ArmouryModel.CliTool.Utilities;
78
using WarHub.ArmouryModel.ProjectModel;
89
using WarHub.ArmouryModel.Source;

src/WarHub.ArmouryModel.CliTool/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static Parser CreateParser()
6565
.Runs(typeof(ConvertGitreeCommand).GetMethod(nameof(ConvertGitreeCommand.Run))))
6666
.AddCommand(
6767
new Command("publish", "Publishes given workspace in selected formats, by default a .bsr file.")
68-
{
68+
{
6969
new Option(
7070
new[] { "-a", "--artifacts" },
7171
"Kinds of artifacts to publish to output (multiple values allowed):" +

src/WarHub.ArmouryModel.CliTool/Utilities/AutoProjectConfigurationProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public ProjectConfigurationInfo Create(string path)
1919
return ReadDirectory(path);
2020
}
2121

22-
private ProjectConfigurationInfo ReadFile(string path)
22+
private static ProjectConfigurationInfo ReadFile(string path)
2323
{
2424
if (!IsProjectConfituration(path))
2525
{
@@ -29,7 +29,7 @@ private ProjectConfigurationInfo ReadFile(string path)
2929
return ReadConfigurationFile(path);
3030
}
3131

32-
private ProjectConfigurationInfo ReadDirectory(string path)
32+
private static ProjectConfigurationInfo ReadDirectory(string path)
3333
{
3434
var directory = string.IsNullOrEmpty(path) ? "." : path;
3535
// search for single project configuration file in current directory

src/WarHub.ArmouryModel.ProjectModel/Configuration/ProjectConfiguration.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Immutable;
2+
using Amadevus.RecordGenerator;
23
using Newtonsoft.Json;
34

45
namespace WarHub.ArmouryModel.ProjectModel

0 commit comments

Comments
 (0)