Skip to content

Commit

Permalink
Update template.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejball committed Mar 24, 2021
1 parent f988dec commit 78af491
Show file tree
Hide file tree
Showing 15 changed files with 106 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ csharp_style_var_for_built_in_types = true : suggestion
csharp_style_var_when_type_is_apparent = true : suggestion
csharp_using_directive_placement = outside_namespace : warning
dotnet_code_quality_unused_parameters = all : suggestion
dotnet_diagnostic.CA1030.severity = none
dotnet_diagnostic.CA1031.severity = suggestion
dotnet_diagnostic.CA1032.severity = suggestion
dotnet_diagnostic.CA1054.severity = none
Expand All @@ -92,6 +93,7 @@ dotnet_diagnostic.CA1063.severity = none
dotnet_diagnostic.CA1303.severity = none
dotnet_diagnostic.CA1308.severity = suggestion
dotnet_diagnostic.CA1707.severity = none
dotnet_diagnostic.CA1716.severity = none
dotnet_diagnostic.CA1720.severity = suggestion
dotnet_diagnostic.CA1812.severity = none
dotnet_diagnostic.CA1815.severity = suggestion
Expand All @@ -101,6 +103,7 @@ dotnet_diagnostic.CA1822.severity = suggestion
dotnet_diagnostic.CA1826.severity = suggestion
dotnet_diagnostic.CA2000.severity = none
dotnet_diagnostic.CA2227.severity = none
dotnet_diagnostic.CA2234.severity = none
dotnet_diagnostic.CA2237.severity = none
dotnet_diagnostic.SA0001.severity = none
dotnet_diagnostic.SA1003.severity = none
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
*.cs text diff=csharp
*.csproj text merge=union
*.sln text merge=union

*.g.cs linguist-generated=true
31 changes: 19 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
paths-ignore:
- '*.md'
- 'docs/**'
branches:
- '**'
tags-ignore:
- '**'
pull_request:
paths-ignore:
- '*.md'
Expand All @@ -16,23 +20,26 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest, macos-latest]
defaults:
run:
shell: pwsh
steps:
- name: Check out code
uses: actions/checkout@v1
- name: Set up .NET Core
- name: Set up .NET 5
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
- name: Build Windows
if: runner.os == 'Windows' && github.ref != 'refs/heads/master'
run: .\build.cmd package
- name: Publish Windows
if: runner.os == 'Windows' && github.ref == 'refs/heads/master'
dotnet-version: 5.0.x
- name: Restore
run: .\build.ps1 restore
- name: Build
run: .\build.ps1 build --skip restore
- name: Test
run: .\build.ps1 test --skip build
- name: Publish
if: runner.os == 'Windows' && github.repository_owner == 'FacilityApi' && github.ref == 'refs/heads/master'
env:
BUILD_BOT_PASSWORD: ${{ secrets.BUILD_BOT_PASSWORD }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: .\build.cmd publish
- name: Build Linux
if: runner.os == 'Linux'
run: ./build.sh package
run: .\build.ps1 publish --skip test
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.vs/
bin/
obj/
release/

.vs/
Thumbs.db
*.cache
*.log
*.user
*.userprefs
*.ncrunchproject
*.ncrunchsolution
*.user
launchSettings.json
nCrunchTemp*
_ReSharper*
.DS_Store
launchSettings.json
9 changes: 5 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

<PropertyGroup>
<VersionPrefix>0.0.0</VersionPrefix>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<NeutralLanguage>en-US</NeutralLanguage>
<NoWarn>$(NoWarn);1591;1998;NU5105</NoWarn>
<NoWarn>$(NoWarn);1591;1998;NU5105;CA1014</NoWarn>
<DebugType>embedded</DebugType>
<GitHubOrganization>FacilityApi</GitHubOrganization>
<RepositoryName>RepoTemplate</RepositoryName>
Expand All @@ -18,6 +18,8 @@
<Copyright>Copyright $(Authors)</Copyright>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
Expand All @@ -28,9 +30,8 @@

<ItemGroup>
<PackageReference Include="Faithlife.Analyzers" Version="1.0.7" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright 2020 Ed Ball
Copyright 2021 Ed Ball

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# RepoTemplate

Repository description.

[![Build](https://github.com/FacilityApi/RepoTemplate/workflows/Build/badge.svg)](https://github.com/FacilityApi/RepoTemplate/actions?query=workflow%3ABuild)

* [Documentation](https://facilityapi.github.io/)
* [Release Notes](ReleaseNotes.md)
6 changes: 0 additions & 6 deletions build.cmd

This file was deleted.

16 changes: 16 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
$ErrorActionPreference = 'Stop'
Push-Location $PSScriptRoot
try {
if (-not (Test-Path ./tools/bin/Build) -or
(Get-ChildItem ./tools/Build/* | Measure-Object LastWriteTime -Maximum).Maximum -gt
(Get-ChildItem ./tools/bin/Build/* | Measure-Object LastWriteTime -Maximum).Maximum) {
if (Test-Path ./tools/bin/Build) { Remove-Item ./tools/bin/Build -Recurse }
dotnet publish ./tools/Build/Build.csproj --output ./tools/bin/Build --nologo --verbosity quiet
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
dotnet ./tools/bin/Build/Build.dll $args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
}
finally {
Pop-Location
}
5 changes: 0 additions & 5 deletions build.sh

This file was deleted.

6 changes: 3 additions & 3 deletions dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"isRoot": true,
"tools": {
"dotnet-format": {
"version": "4.1.131201",
"version": "5.0.211103",
"commands": [
"dotnet-format"
]
},
"jetbrains.resharper.globaltools": {
"version": "2020.2.4",
"version": "2020.3.4",
"commands": [
"jb"
]
}
}
}
}
80 changes: 42 additions & 38 deletions tools/Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,51 @@
using static Faithlife.Build.BuildUtility;
using static Faithlife.Build.DotNetRunner;

internal static class Build
return BuildRunner.Execute(args, build =>
{
public static int Main(string[] args) => BuildRunner.Execute(args, build =>
{
var codegen = "fsdgen___";
var codegen = "fsdgen___";

var gitLogin = new GitLoginInfo("FacilityApiBot", Environment.GetEnvironmentVariable("BUILD_BOT_PASSWORD") ?? "");

var dotNetBuildSettings = new DotNetBuildSettings
var dotNetBuildSettings = new DotNetBuildSettings
{
NuGetApiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY"),
DocsSettings = new DotNetDocsSettings
{
NuGetApiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY"),
DocsSettings = new DotNetDocsSettings
{
GitLogin = new GitLoginInfo("FacilityApiBot", Environment.GetEnvironmentVariable("BUILD_BOT_PASSWORD") ?? ""),
GitAuthor = new GitAuthorInfo("FacilityApiBot", "[email protected]"),
SourceCodeUrl = "https://github.com/FacilityApi/RepoTemplate/tree/master/src",
ProjectHasDocs = name => !name.StartsWith("fsdgen", StringComparison.Ordinal),
},
};

build.AddDotNetTargets(dotNetBuildSettings);

build.Target("codegen")
.DependsOn("build")
.Describe("Generates code from the FSD")
.Does(() => CodeGen(verify: false));

build.Target("verify-codegen")
.DependsOn("build")
.Describe("Ensures the generated code is up-to-date")
.Does(() => CodeGen(verify: true));

build.Target("test")
.DependsOn("verify-codegen");

void CodeGen(bool verify)
GitLogin = gitLogin,
GitAuthor = new GitAuthorInfo("FacilityApiBot", "[email protected]"),
SourceCodeUrl = "https://github.com/FacilityApi/RepoTemplate/tree/master/src",
ProjectHasDocs = name => !name.StartsWith("fsdgen", StringComparison.Ordinal),
},
PackageSettings = new DotNetPackageSettings
{
var configuration = dotNetBuildSettings!.BuildOptions!.ConfigurationOption!.Value;
var toolPath = FindFiles($"src/{codegen}/bin/{configuration}/netcoreapp3.1/{codegen}.dll").FirstOrDefault();
GitLogin = gitLogin,
PushTagOnPublish = x => $"nuget.{x.Version}",
},
};

build.AddDotNetTargets(dotNetBuildSettings);

build.Target("codegen")
.DependsOn("build")
.Describe("Generates code from the FSD")
.Does(() => CodeGen(verify: false));

build.Target("verify-codegen")
.DependsOn("build")
.Describe("Ensures the generated code is up-to-date")
.Does(() => CodeGen(verify: true));

build.Target("test")
.DependsOn("verify-codegen");

void CodeGen(bool verify)
{
var configuration = dotNetBuildSettings.GetConfiguration();
var toolPath = FindFiles($"src/{codegen}/bin/{configuration}/net5.0/{codegen}.dll").FirstOrDefault();

var verifyOption = verify ? "--verify" : null;
var verifyOption = verify ? "--verify" : null;

RunDotNet(toolPath, "___", "___", "--newline", "lf", verifyOption);
}
});
}
RunDotNet(toolPath, "___", "___", "--newline", "lf", verifyOption);
}
});
5 changes: 2 additions & 3 deletions tools/Build/Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace />
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Faithlife.Build" Version="5.2.2" />
<PackageReference Include="Faithlife.Build" Version="5.10.3" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions tools/XmlDocGen/XmlDocGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
</ItemGroup>

<ItemGroup>
<PackageReference Include="XmlDocMarkdown.Core" Version="2.3.0" />
<PackageReference Include="XmlDocMarkdown.Core" Version="2.5.2" />
</ItemGroup>

</Project>
8 changes: 1 addition & 7 deletions tools/XmlDocGen/XmlDocGenApp.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
using XmlDocMarkdown.Core;

namespace XmlDocGen
{
internal sealed class XmlDocGenApp
{
public static int Main(string[] args) => XmlDocMarkdownApp.Run(args);
}
}
return XmlDocMarkdownApp.Run(args);

0 comments on commit 78af491

Please sign in to comment.