Skip to content

Commit

Permalink
Update templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenCleary committed Dec 8, 2023
1 parent a90a5d4 commit a19c189
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 50 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/build.yml
@@ -1,4 +1,13 @@
# build.yml v1.4
# build.yml v1.6
# 1.6:
# - Use --getProperty:Version instead of Nito.ProjProps.
# - Updates: acitons/checkout@v4
# 1.5:
# - Use bash syntax
# - Avoid set-output
# - Updates: actions/cache@v3, actions/checkout@v3, actions/upload-artifact@v3, codecov/codecov-action@v3, WyriHaximus/github-action-get-previous-tag@v1
# - Work around SDK bug (https://github.com/dotnet/sdk/issues/17461)
# - Use pre-release ProjProps.
# 1.4 - Avoid set-env.
# 1.3 - Include tag workflow in this file.
# 1.2 - Define DOTNET_SKIP_FIRST_TIME_EXPERIENCE/NUGET_XMLDOC_MODE.
Expand All @@ -25,35 +34,35 @@ jobs:
env:
CONTEXT: ${{ toJson(github) }}
run: |
echo "Context: $Env:CONTEXT"
echo "Context is available above"
- name: Determine cache fallbacks
if: github.event_name != 'push'
id: cache_fallbacks
run: |
echo "::set-output name=nuget::nuget-"
echo "name=nuget::nuget-" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 0 # Required by WyriHaximus/github-action-get-previous-tag@v1

- name: Cache nuget
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/*.props') }}
restore-keys: ${{ steps.cache_fallbacks.outputs.nuget }}

- name: Get existing tag
id: existingtag
uses: WyriHaximus/github-action-get-previous-tag@0.2.0
uses: WyriHaximus/github-action-get-previous-tag@v1
continue-on-error: true

- name: Get current version
run: |
dotnet tool install --global Nito.ProjProps
echo "NEWTAG=v$(projprops --name version --output-format SingleValueOnly --project src --project-search)" >> $GITHUB_ENV
echo "NEWTAG=v$(dotnet build $(find src -name *.csproj | head --lines=1) --getProperty:Version)"
echo "NEWTAG=v$(dotnet build $(find src -name *.csproj | head --lines=1) --getProperty:Version)" >> $GITHUB_ENV
- name: Build
run: |
Expand All @@ -62,15 +71,15 @@ jobs:
dotnet pack --configuration Release --no-build
- name: Upload package artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: nuget-packages
path: |
**/*.nupkg
**/*.snupkg
- name: Publish code coverage
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

- name: Publish packages
if: env.NEWTAG != steps.existingtag.outputs.tag
Expand Down
48 changes: 14 additions & 34 deletions src/Directory.Build.props
@@ -1,6 +1,12 @@
<Project>
<!--
Directory.Build.props (src) v2.1
Directory.Build.props (src) v2.3
- 2.3:
- Remove old Coverlet workaround for .NET SDKs < 3.1.300
- Remove source link settings for .NET SDKs < 8
- Add trim/single-file/AOT checks.
- Add repo-scope README.md to package.
- 2.2 Migrate from FxCopAnalyzers to NetAnalyzers.
- 2.1 Specify LangVersion (required by Nullable for most libraries).
- 2.0 Move project-specific properties to `project.props`.
- 1.1 Remove workaround for .NET SDK bug that was necesary for coverlet to work.
Expand All @@ -15,22 +21,20 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<ContinuousIntegrationBuild Condition="'$(CI)'=='true'">true</ContinuousIntegrationBuild>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
</PropertyGroup>
<PropertyGroup Condition="'$(CI)'=='true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<!-- Package settings -->
<PropertyGroup>
<PackageProjectUrl>https://github.com/$(GITHUB_REPOSITORY)</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<!-- Icon file -->
<PropertyGroup>
Expand All @@ -40,17 +44,6 @@
<None Include="..\icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<!-- Source debugging -->
<PropertyGroup>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
</ItemGroup>

<!-- Include reference assemblies -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All"/>
Expand All @@ -60,17 +53,4 @@
<PropertyGroup Condition="'$(CI)'!='true'">
<VersionSuffix>dev</VersionSuffix>
</PropertyGroup>

<!-- Enable coverlet analysis on deterministic builds: https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/DeterministicBuild.md -->
<ItemGroup>
<SourceRoot Include="$(NuGetPackageRoot)" />
</ItemGroup>
<Target Name="CoverletGetPathMap"
DependsOnTargets="InitializeSourceRootMappedPaths"
Returns="@(_LocalTopLevelSourceRoot)"
Condition="'$(DeterministicSourcePaths)' == 'true'">
<ItemGroup>
<_LocalTopLevelSourceRoot Include="@(SourceRoot)" Condition="'%(SourceRoot.NestedRoot)' == ''"/>
</ItemGroup>
</Target>
</Project>
12 changes: 7 additions & 5 deletions test/Directory.Build.props
@@ -1,6 +1,8 @@
<Project>
<!--
Directory.Build.props (test) v1.0
Directory.Build.props (test) v1.2
- 1.2 Dependency updates.
- 1.1 Dependency updates.
- 1.0 Initial release.
-->

Expand All @@ -9,13 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit a19c189

Please sign in to comment.