Update ci to use dotnet-releaser

This commit is contained in:
Alexandre Mutel
2022-02-28 09:18:40 +01:00
parent 996b04cadb
commit 73b8bbe1c7
7 changed files with 62 additions and 62 deletions

View File

@@ -1,8 +1,5 @@
name: ci
env:
PROJECT_NAME: Markdig
on:
push:
paths-ignore:
@@ -19,46 +16,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install .NET 6.0
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Build (Release)
run: dotnet build src -c Release
- name: SpecFileGen
run: dotnet src/SpecFileGen/bin/Release/net6.0/SpecFileGen.dll
- name: Test (Release)
run: dotnet test src -c Release
- name: Build & Test (Debug)
run: dotnet test src -c Debug
- name: Coverlet
run: dotnet test src -c Release -f net6.0 /p:Include=\"[${{env.PROJECT_NAME}}]*\" /p:CollectCoverage=true /p:CoverletOutputFormat=lcov
- name: Coveralls Upload
uses: coverallsapp/github-action@1.1.3
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: src/${{env.PROJECT_NAME}}.Tests/coverage.info
- name: Pack
run: dotnet pack src -c Release
- name: Pack Signed
run: dotnet pack -c Release src/${{env.PROJECT_NAME}}.Signed/${{env.PROJECT_NAME}}.Signed.csproj
- name: Publish
if: github.event_name == 'push'
run: |
if ( "${{github.ref}}" -match "^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$" ) {
dotnet nuget push src\${{env.PROJECT_NAME}}\bin\Release\*.nupkg -s nuget.org -k ${{secrets.NUGET_TOKEN}}
dotnet nuget push src\${{env.PROJECT_NAME}}.Signed\bin\Release\*.nupkg -s nuget.org -k ${{secrets.NUGET_TOKEN}}
} else {
echo "publish is only enabled by tagging with a release tag"
}
- name: Build, Test, Pack, Publish
run: |
dotnet tool install -g dotnet-releaser
dotnet-releaser run --nuget-token ${{secrets.NUGET_TOKEN}} --github-token ${{secrets.GITHUB_TOKEN}} src/dotnet-releaser.toml

3
.gitignore vendored
View File

@@ -239,3 +239,6 @@ _Pvt_Extensions
**/.idea/**/*.iml
**/.idea/**/contentModel.xml
**/.idea/**/modules.xml
# Remove artifacts produced by dotnet-releaser
artifacts-dotnet-releaser/

View File

@@ -5,6 +5,8 @@
<OutputType>Exe</OutputType>
<IsPackable>false</IsPackable>
<StartupObject>Markdig.Tests.Program</StartupObject>
<SpecExecutable>$(MSBuildProjectDirectory)\..\SpecFileGen\bin\$(Configuration)\net6.0\SpecFileGen.dll</SpecExecutable>
<SpecTimestamp>$(MSBuildProjectDirectory)\..\SpecFileGen\bin\$(Configuration)\net6.0\SpecFileGen.timestamp</SpecTimestamp>
</PropertyGroup>
<ItemGroup>
@@ -19,6 +21,33 @@
<ItemGroup>
<ProjectReference Include="..\Markdig\Markdig.csproj" />
<ProjectReference Include="..\SpecFileGen\SpecFileGen.csproj" />
</ItemGroup>
<ItemGroup>
<ItemSpecExecutable Include="$(SpecExecutable)" />
<InputSpecFiles Include="Specs\*.md" />
<InputSpecFiles Include="NormalizeSpecs\*.md" />
<InputSpecFiles Include="PlainTextSpecs\*.md" />
<InputSpecFiles Include="RoundtripSpecs\*.md" />
<InputSpecFiles Remove="Specs\readme.md" />
<!-- Allow Visual Studio up-to-date check to verify that nothing has changed - https://github.com/dotnet/project-system/blob/main/docs/up-to-date-check.md -->
<UpToDateCheckInput Include="@(InputSpecFiles)"/>
<OutputSpecFiles Include="@(InputSpecFiles->'%(RelativeDir)%(Filename).generated.cs')" />
</ItemGroup>
<Target Name="GeneratedSpecsFile" BeforeTargets="BeforeCompile;CoreCompile" Inputs="@(ItemSpecExecutable);@(InputSpecFiles)" Outputs="@(ItemSpecExecutable->'%(RelativeDir)%(Filename).timestamp');@(InputSpecFiles->'%(RelativeDir)%(Filename).generated.cs')">
<Message Importance="high" Text="Regenerating Specs Files Input @(InputSpecFiles) Output @(OutputSpecFiles)'" />
<Exec Command="dotnet $(SpecExecutable)" />
<WriteLinesToFile File="$(SpecTimestamp)" Lines="$([System.DateTime]::Now)" />
<ItemGroup>
<FileWrites Include="$(SpecTimestamp)" />
<_GeneratedSpecsFile Include="Specs\*.generated.cs" />
<_GeneratedSpecsFile Include="NormalizeSpecs\*.generated.cs" />
<_GeneratedSpecsFile Include="PlainTextSpecs\*.generated.cs" />
<_GeneratedSpecsFile Include="RoundtripSpecs\*.generated.cs" />
<_GeneratedSpecsFile Remove="@(Compile)" />
<Compile Include="@(_GeneratedSpecsFile)" />
</ItemGroup>
</Target>
</Project>

View File

@@ -4,7 +4,6 @@
<Description>A fast, powerful, CommonMark compliant, extensible Markdown processor for .NET with 20+ builtin extensions (pipetables, footnotes, definition lists... etc.)</Description>
<Copyright>Alexandre Mutel</Copyright>
<NeutralLanguage>en-US</NeutralLanguage>
<VersionPrefix>0.27.0</VersionPrefix>
<Authors>Alexandre Mutel</Authors>
<!-- Markdig.Wpf still supports net452, a target still supported by by Microsoft until January 10, 2023 -->
<!-- see: https://github.com/xoofx/markdig/pull/466 -->
@@ -38,6 +37,10 @@
<ItemGroup>
<None Include="../../img/markdig.png" Pack="true" PackagePath="" />
<None Include="../../readme.md" Pack="true" PackagePath="/"/>
<PackageReference Include="MinVer" Version="2.5.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.*" PrivateAssets="All"/>
</ItemGroup>

View File

@@ -99,17 +99,15 @@ namespace SpecFileGen
static void Main()
{
Console.WriteLine("Generating {0} specs ...", Specs.Length);
bool anyChanged = false;
List<Spec> missingSpecs = new List<Spec>();
int totalTests = 0;
bool hasErrors = false;
foreach (var spec in Specs)
{
if (!File.Exists(spec.Path))
{
missingSpecs.Add(spec);
EmitError("Could not find the specification file at " + spec.Path);
hasErrors = true;
continue;
}
@@ -119,31 +117,22 @@ namespace SpecFileGen
if (File.Exists(spec.OutputPath)) // If the source hasn't changed, don't bump the generated tag
{
string previousSource = File.ReadAllText(spec.OutputPath).Replace("\r\n", "\n", StringComparison.Ordinal);
if (previousSource == source)
if (previousSource == source && File.GetLastWriteTime(spec.OutputPath) > File.GetLastWriteTime(spec.Path))
{
continue;
}
Console.WriteLine($"Spec changed {spec.Path}. Need to regenerate");
}
Console.WriteLine($"Generating spec {spec.Name} to {spec.OutputPath}...");
File.WriteAllText(spec.OutputPath, source);
anyChanged = true;
}
if (missingSpecs.Count != 0)
if (hasErrors)
{
foreach (var spec in missingSpecs)
{
EmitError("Could not find the specification file at " + spec.Path);
}
Environment.Exit(1);
}
if (anyChanged && Environment.GetEnvironmentVariable("CI") != null)
{
EmitError("Error - Specification files have changed. You must run SpecFileGen when changing specification files.");
Environment.Exit(1);
}
Console.WriteLine("There are {0} tests in total", totalTests);
Console.WriteLine("There are {0} spec tests in total", totalTests);
}
static void EmitError(string error)
{

10
src/dotnet-releaser.toml Normal file
View File

@@ -0,0 +1,10 @@
[msbuild]
project = ["markdig.sln", "./Markdig.Signed/Markdig.Signed.csproj"]
build_debug = true
[github]
user = "xoofx"
repo = "markdig"
[test]
run_tests_for_debug = true
[coverage]
exclude = "[SpecFileGen*]*"

View File

@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28407.52
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{061866E2-005C-4D13-A338-EA464BBEC60F}"
ProjectSection(SolutionItems) = preProject