Skip to content

Commit

Permalink
Automatic releasing (#150)
Browse files Browse the repository at this point in the history
* Prepare Directory.Build.props

* Update Build all projects.yml

* Create release-drafter.yml

* Fix

* Update Test all projects.yml

* Update Build all projects.yml

* Restore

* dotnet nuget

* Update Test all projects.yml

* Update Test all projects.yml

* Fixes

* Fix PackageVersion

* Update Test all projects.yml

* Update Directory.Build.props

* Update Test all projects.yml

* Update Test all projects.yml

* Update Test all projects.yml

* Update Test all projects.yml

* Create Release.yml

* Rename Build all projects.yml to Build.yml

* Rename Test all projects.yml to Test.yml

* Update release-drafter.yml

* Update Release.yml

* Update Test.yml

* Update Release.yml

* Update release-drafter.yml

* Update Release.yml

* Update Test.yml

* Update release-drafter.yml

* Update Test.yml

* Update Test.yml

* Update Test.yml

* Update Test.yml

* Update Test.yml

* Update Test.yml

* Update Directory.Build.props

* Update Release.yml

* Update release-drafter.yml

* Update Release.yml

* Update Test.yml

* Update Release.yml

* "RELEASE_NOTES"? lol

* RELEEASE_NOTES? lol

* Update CaretTests.cs

* Update Release.yml
  • Loading branch information
Happypig375 committed Jul 31, 2020
1 parent aabb520 commit cecc4b0
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 64 deletions.
50 changes: 50 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# https://github.com/marketplace/actions/release-drafter#configuration
name-template: '$RESOLVED_VERSION CI'
tag-template: 'v$RESOLVED_VERSION'
version-resolver:
major:
labels:
- 'Version/Major'
minor:
labels:
- 'Version/Minor'
patch:
labels:
- 'Version/Patch'
default: patch
exclude-labels:
- 'Version/None'
prerelease: true
template: |
<!--Example release name: $RESOLVED_VERSION xxx Update [Alpha|Beta]-->
<!--Please release immediately after modifying as any changes will be overwritten on next run of the Test workflow-->
<!--Remove these comments, they will be visible in the released NuGet packages!-->
## Changes from $PREVIOUS_TAG (Recently merged first)
$CHANGES
## Contributors
$CONTRIBUTORS
categories:
- title: '🌈 New Platform!'
labels:
- 'Type/Platform'
- title: '🚀 Features'
labels:
- 'Type/Enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'Type/Bug'
- title: '🧰 Maintenance'
label: 'Type/Housekeeping'
# Extra line before $BODY or markdown on the first line of $BODY will be interpreted as plain text
change-template: |
<details><summary>$TITLE (#$NUMBER) @$AUTHOR</summary>
$BODY
</details>
no-changes-template: '* (No changes)'
replacers:
# We don't support nested <summary> and <details> so we add a (?!<details>|<summary>)
- search: '/<details><summary>((?:(?!<details>|<summary>).)+?)<\/summary>\s*<\/details>/g'
replace: '- $1'
36 changes: 0 additions & 36 deletions .github/workflows/Build all projects.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build

on: [push, pull_request]
jobs:
all_projects:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.302'
- name: Setup NuGet
uses: NuGet/setup-nuget@v1.0.2
- name: Setup MSBuild Path
uses: warrenbuckley/Setup-MSBuild@v1
- name: Restore NuGet Packages
run: nuget restore CSharpMath.sln
- name: Build CI artifacts
run: msbuild CSharpMath.sln /p:Configuration=Release
54 changes: 54 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release

on:
release:
types: [published]
jobs:
all_projects:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.302'
- name: Build GitHub Releases draft artifacts
env:
RELEASE_NOTES: |
# ${{ github.event.release.name }}
${{ github.event.release.body }}
# run: dotnet test CSharpMath.CrossPlatform.slnf
run: | # https://github.com/dotnet/sdk/issues/10409, https://github.com/dotnet/sdk/issues/11417
# .NET Core MSBuild cannot parse , and ; correctly so we replace them with substitutions: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743
# https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
# ${parameter/pattern/string} If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced.
RELEASE_NOTES=${RELEASE_NOTES//,/%2C}
RELEASE_NOTES=${RELEASE_NOTES//;/%3B}
for p in\
"CSharpMath.CoreTests"\
"CSharpMath.Editor.Tests"\
"CSharpMath.Editor.Tests.FSharp"\
"CSharpMath.Evaluation.Tests"\
`# "CSharpMath.Ios" # https://github.com/dotnet/sdk/issues/11108 + https://github.com/release-drafter/release-drafter/issues/558`\
"CSharpMath.Rendering.Tests"\
"CSharpMath.Rendering.Text.Tests"\
"CSharpMath.Xaml.Tests"\
"CSharpMath.Xaml.Tests.NuGet"\
"Typography/Typography.TextBreak/Typography.TextBreak.UnitTests"
do
# -r for restore
dotnet msbuild -r -p:Configuration=Release -p:PackageVersion="${{ github.event.release.tag_name }}" -p:PackageReleaseNotes="$RELEASE_NOTES" "$p"
done
- name: Upload to GitHub Releases
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
file: .nupkgs/*
file_glob: true
overwrite: true
- name: Upload to NuGet
run: dotnet nuget push .nupkgs/* -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ name: Test
on: [push, pull_request]
jobs:
Core:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ubuntu-latest # release-drafter/release-drafter@v5 only works on Linux: https://github.com/release-drafter/release-drafter/issues/558
steps:
- name: Update draft on GitHub Releases
id: release_drafter
uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: cardinalby/git-get-release-action@v1
id: release_info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
releaseId: ${{ steps.release_drafter.outputs.id }}
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.301'
- name: Setup JDK # Needed to run ANTLR for AngouriMath
uses: actions/setup-java@v1
with:
java-version: '8'
dotnet-version: '3.1.302'
- name: Update dependencies in CSharpMath.Xaml.Tests.NuGet
run: |
dotnet tool install -g dotnet-outdated
Expand All @@ -29,13 +33,24 @@ jobs:
# retry 5 times since dotnet outdated fails often: https://github.com/jerriep/dotnet-outdated/issues/299
update || update || update || update || update
- name: Build and Test
env:
RELEASE_NOTES: |
# ${{ steps.release_info.outputs.name }}
${{ steps.release_info.outputs.body }}
# run: dotnet test CSharpMath.CrossPlatform.slnf
run: | # https://github.com/dotnet/sdk/issues/10409, https://github.com/dotnet/sdk/issues/11417
# .NET Core MSBuild cannot parse , and ; correctly so we replace them with substitutions: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743
# https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
# ${parameter/pattern/string} If pattern begins with ‘/’, all matches of pattern are replaced with string. Normally only the first match is replaced.
RELEASE_NOTES=${RELEASE_NOTES//,/%2C}
RELEASE_NOTES=${RELEASE_NOTES//;/%3B}
for p in\
"CSharpMath.CoreTests"\
"CSharpMath.Editor.Tests"\
"CSharpMath.Editor.Tests.FSharp"\
"CSharpMath.Evaluation.Tests"\
`# "CSharpMath.Ios" # https://github.com/dotnet/sdk/issues/11108 + https://github.com/release-drafter/release-drafter/issues/558`\
"CSharpMath.Rendering.Tests"\
"CSharpMath.Rendering.Text.Tests"\
"CSharpMath.Xaml.Tests"\
Expand All @@ -44,13 +59,28 @@ jobs:
do
dotnet add "$p" package Microsoft.NET.Test.Sdk # Update is required for GitHubActionsTestLogger to print anything
dotnet add "$p" package GitHubActionsTestLogger
dotnet test "$p" -c Release -l GitHubActions
# -r for restore
dotnet msbuild -r -p:Configuration=Release -p:PackageVersion=${{ steps.release_drafter.outputs.tag_name }}-ci-${{ github.sha }} -p:PackageReleaseNotes="$RELEASE_NOTES" "$p"
# --no-build because building again will produce additional NuGet packages without the PackageVersion setting above
dotnet test "$p" --no-build -c Release -l GitHubActions --blame
done
- uses: actions/upload-artifact@v2
if: always() # Run even when a previous step failed: https://stackoverflow.com/a/58859404/5429648
with:
name: CSharpMath.Rendering.Tests results (${{ matrix.os }})
name: CSharpMath.Rendering.Tests results
path: CSharpMath.Rendering.Tests/*/*.png
- name: Upload CI artifacts
uses: actions/upload-artifact@v2
if: always()
with:
name: NuGet packages
path: .nupkgs/
- name: Push CI artifacts to GitHub Packages registry
if: github.ref == 'refs/heads/master'
run: |
# Non-Windows platforms require --store-password-in-clear-text: https://github.com/NuGet/Home/issues/1851
dotnet nuget add source https://nuget.pkg.github.com/verybadcat/index.json -n github -u verybadcat -p ${{ secrets.GITHUB_TOKEN }} --store-password-in-clear-text
dotnet nuget push .nupkgs/ --source "github" --skip-duplicate
Ios:
runs-on: macos-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion CSharpMath.Editor.Tests/CaretTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public class CaretTimerResetsOnKeyPress {
await Task.Delay((int)MathKeyboard<TestFont, char>.DefaultBlinkMilliseconds - CaretBlinks.MillisecondBuffer);

Assert.Equal(MathKeyboardCaretState.Shown, keyboard.CaretState);
await Task.Delay(2 * CaretBlinks.MillisecondBuffer);
await Task.Delay(3 * CaretBlinks.MillisecondBuffer);
Assert.Equal(MathKeyboardCaretState.TemporarilyHidden, keyboard.CaretState);
}
}
Expand Down
29 changes: 13 additions & 16 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--Directory.Build.props: MSBuild properties that are included in every project-->
<!--Info: https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?view=vs-2019#directorybuildprops-and-directorybuildtargets-->
<Project InitialTargets="AppendCISignatureToPackageVersion">
<Project InitialTargets="SetDefaultPackageVersion">
<PropertyGroup Condition="$(MSBuildProjectName.StartsWith('CSharpMath'))"> <!--Don't apply to Typography projects-->
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
Expand All @@ -12,7 +12,7 @@

<!--NuGet properties: Ordered according to https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#pack-target-->
<PackageId>$(MSBuildProjectName)</PackageId>
<PackageVersion>0.4.2</PackageVersion>
<!--PackageVersion is set in the SetDefaultPackageVersion target below-->
<Authors>CSharpMath Contributors (verybadcat, Happypig375, charlesroddie, FoggyFinder)</Authors>
<Title>$(PackageId)</Title>
<!--Description property is defined in individual projects-->
Expand All @@ -25,15 +25,11 @@
math mathematics mathematical formula equation equations
expression tex latex render rendering display beautiful CSharpMath
</PackageTags>
<PackageReleaseNotes>
The 0.4 Avalonia Update brings the Avalonia front end!
0.4.1: Fixed Measure in CSharpMath.Rendering
0.4.2: Fixed TextPainter setting the position of display maths in the first line to above the canvas bounds
</PackageReleaseNotes>
<!--PackageReleaseNotes is not set by default and is set by CI-->
<RepositoryUrl>https://github.com/verybadcat/CSharpMath.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryBranch>master</RepositoryBranch>
<!--RepositoryCommit property is set dynamically below-->
<!--RepositoryCommit property is set in the SetDefaultPackageVersion target below-->

<!--SourceLink properties: Ordered according to https://github.com/dotnet/sourcelink#using-source-link-in-net-projects-->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
Expand All @@ -50,9 +46,6 @@
<NeutralLanguage>en</NeutralLanguage>
<RootNamespace>$(MSBuildProjectName)</RootNamespace> <!--Prefix namespace for embedded resources-->
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<AssemblyVersion>$(PackageVersion.Split('-')[0])</AssemblyVersion>
<FileVersion>$(AssemblyVersion)</FileVersion> <!--"File version" in DLL Details, $(AssemblyVersion) if unset-->
<Version>$(AssemblyVersion)</Version> <!--"Product version" in DLL Details, '1.0.0' if unset-->
</PropertyGroup>
<ItemGroup Condition="
$(MSBuildProjectName.StartsWith('CSharpMath'))
Expand All @@ -61,15 +54,19 @@
<None Include="$(MSBuildThisFileDirectory)Icon.png" Pack="true" PackagePath="" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
</ItemGroup>
<Target Name="AppendCISignatureToPackageVersion" Condition="$(MSBuildProjectName.StartsWith('CSharpMath'))">
<!--Also run for non-CSharpMath projects: Normalize PackageVersion or else error-->
<Target Name="SetDefaultPackageVersion">
<!--Setting StandardOutputImportance to Low ensures that EchoOff works: https://github.com/Microsoft/msbuild/issues/2826-->
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" EchoOff="true" StandardOutputImportance="Low">
<Output TaskParameter="ConsoleOutput" PropertyName="RepositoryCommit" />
</Exec>
<!-- Appending build date and time as metadata for version is blocked on https://github.community/t/bug-nuget-support-build-metadata-properly/117606 -->
<!-- <CreateProperty Value="$(PackageVersion)-ci-$(RepositoryCommit)+$([System.DateTime]::UtcNow.ToString('yyyy.MM.dd-HH.mm.ss'))"> -->
<CreateProperty Condition="!$([System.String]::IsNullOrEmpty($(CI))) And $(CI)" Value="$(PackageVersion)-ci-$(RepositoryCommit)">
<!--For local builds-->
<CreateProperty Condition="$(PackageVersion) == '1.0.0'" Value="99.99.99-localbuild-$(RepositoryCommit)">
<Output TaskParameter="Value" PropertyName="PackageVersion" />
</CreateProperty>
<!--For CI builds-->
<CreateProperty Value="$(PackageVersion.TrimStart('v'))">
<Output TaskParameter="Value" PropertyName="PackageVersion" />
</CreateProperty>
</Target>
</Project>
</Project>

0 comments on commit cecc4b0

Please sign in to comment.