Skip to content

Commit ea5cddd

Browse files
committed
ci: add build pipeline
1 parent 168ead5 commit ea5cddd

File tree

3 files changed

+172
-54
lines changed

3 files changed

+172
-54
lines changed

.github/workflows/publish.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: publish
4+
on:
5+
workflow_dispatch: # Allow running the workflow manually from the GitHub UI
6+
push:
7+
branches:
8+
- 'main' # Run the workflow when pushing to the main branch
9+
pull_request:
10+
branches:
11+
- '*' # Run the workflow for all pull requests
12+
release:
13+
types:
14+
- published # Run the workflow when a new GitHub release is published
15+
16+
env:
17+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
18+
DOTNET_NOLOGO: true
19+
NuGetDirectory: ${{ github.workspace}}/nuget
20+
21+
defaults:
22+
run:
23+
shell: pwsh
24+
25+
jobs:
26+
create_nuget:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
32+
33+
# Install the .NET SDK indicated in the global.json file
34+
- name: Setup .NET
35+
uses: actions/setup-dotnet@v3
36+
37+
# Create the NuGet package in the folder from the environment variable NuGetDirectory
38+
- run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }}
39+
40+
# Publish the NuGet package as an artifact, so they can be used in the following jobs
41+
- uses: actions/upload-artifact@v3
42+
with:
43+
name: nuget
44+
if-no-files-found: error
45+
retention-days: 7
46+
path: ${{ env.NuGetDirectory }}/*.nupkg
47+
48+
validate_nuget:
49+
runs-on: ubuntu-latest
50+
needs: [ create_nuget ]
51+
steps:
52+
# Install the .NET SDK indicated in the global.json file
53+
- name: Setup .NET
54+
uses: actions/setup-dotnet@v3
55+
56+
# Download the NuGet package created in the previous job
57+
- uses: actions/download-artifact@v3
58+
with:
59+
name: nuget
60+
path: ${{ env.NuGetDirectory }}
61+
62+
- name: Install nuget validator
63+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
64+
65+
# Validate metadata and content of the NuGet package
66+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
67+
# If some rules are not applicable, you can disable them
68+
# using the --excluded-rules or --excluded-rule-ids option
69+
- name: Validate package
70+
run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg")
71+
72+
run_test:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v3
76+
- name: Setup .NET
77+
uses: actions/setup-dotnet@v3
78+
- name: Run tests
79+
run: dotnet test --configuration Release
80+
81+
deploy:
82+
# Publish only when creating a GitHub Release
83+
# https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
84+
# You can update this logic if you want to manage releases differently
85+
if: github.event_name == 'release'
86+
runs-on: ubuntu-latest
87+
needs: [ validate_nuget, run_test ]
88+
steps:
89+
# Download the NuGet package created in the previous job
90+
- uses: actions/download-artifact@v3
91+
with:
92+
name: nuget
93+
path: ${{ env.NuGetDirectory }}
94+
95+
# Install the .NET SDK indicated in the global.json file
96+
- name: Setup .NET Core
97+
uses: actions/setup-dotnet@v3
98+
99+
# Publish all NuGet packages to NuGet.org
100+
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
101+
# If you retry a failed workflow, already published packages will be skipped without error.
102+
- name: Publish NuGet package
103+
run: |
104+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
105+
dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate
106+
}

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"rollForward": "feature",
4+
"version": "8.0.100-preview.4.23260.5"
5+
}
6+
}
Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,69 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<PackageId>TimeProviderExtensions</PackageId>
5-
<Title>TimeProvider Extensions</Title>
6-
<Version>1.0.0-preview.1</Version>
7-
<Company>Egil Hansen</Company>
8-
<Authors>Egil Hansen</Authors>
9-
<Description>
10-
Extensions for `System.TimeProvider` API. It includes a test version of the `TimeProvider`, named `ManualTimeProvider`, that allows you to control the progress of time during testing deterministically.
11-
</Description>
12-
<Copyright>Egil Hansen</Copyright>
13-
<PackageProjectUrl>https://github.com/egil/TimeScheduler</PackageProjectUrl>
14-
<PackageReadmeFile>README.md</PackageReadmeFile>
15-
<RepositoryUrl>https://github.com/egil/TimeScheduler</RepositoryUrl>
16-
<RepositoryType>git</RepositoryType>
17-
<PackageLicenseFile>LICENSE</PackageLicenseFile>
18-
<PackageReleaseNotes>Release notes: https://github.com/egil/TimeScheduler/blob/main/CHANGELOG.md</PackageReleaseNotes>
19-
<PublishRepositoryUrl>true</PublishRepositoryUrl>
20-
<IncludeSymbols>true</IncludeSymbols>
21-
<EmbedUntrackedSources>true</EmbedUntrackedSources>
22-
</PropertyGroup>
3+
<PropertyGroup>
4+
<PackageId>TimeProviderExtensions</PackageId>
5+
<Title>TimeProvider Extensions</Title>
6+
<Company>Egil Hansen</Company>
7+
<Authors>Egil Hansen</Authors>
8+
<Description>
9+
Extensions for `System.TimeProvider` API. It includes a test version of the `TimeProvider`, named `ManualTimeProvider`, that allows you to control the progress of time during testing deterministically.
10+
</Description>
11+
<PackageTags>TimeProvider, testing</PackageTags>
12+
<Copyright>Egil Hansen</Copyright>
13+
<PackageProjectUrl>https://github.com/egil/TimeProviderExtensions</PackageProjectUrl>
14+
<PackageReadmeFile>README.md</PackageReadmeFile>
15+
<RepositoryUrl>https://github.com/egil/TimeProviderExtensions</RepositoryUrl>
16+
<RepositoryType>git</RepositoryType>
17+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
18+
<PackageReleaseNotes>Release notes: https://github.com/egil/TimeProviderExtensions/blob/main/CHANGELOG.md</PackageReleaseNotes>
19+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
20+
<IncludeSymbols>true</IncludeSymbols>
21+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
22+
<MinVerTagPrefix>v</MinVerTagPrefix>
23+
</PropertyGroup>
2324

24-
<PropertyGroup>
25-
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
26-
<ImplicitUsings>enable</ImplicitUsings>
27-
<Nullable>enable</Nullable>
28-
<Deterministic>true</Deterministic>
29-
<LangVersion>latest</LangVersion>
30-
<ImplicitUsings>enable</ImplicitUsings>
31-
<GenerateDocumentationFile>true</GenerateDocumentationFile>
32-
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
25+
<PropertyGroup>
26+
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
27+
<ImplicitUsings>enable</ImplicitUsings>
28+
<Nullable>enable</Nullable>
29+
<Deterministic>true</Deterministic>
30+
<LangVersion>latest</LangVersion>
31+
<ImplicitUsings>enable</ImplicitUsings>
32+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
33+
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
3334

34-
<!-- Used by code coverage -->
35-
<DebugType>full</DebugType>
36-
<DebugSymbols>true</DebugSymbols>
37-
</PropertyGroup>
35+
<!-- Used by code coverage -->
36+
<DebugType>full</DebugType>
37+
<DebugSymbols>true</DebugSymbols>
38+
</PropertyGroup>
3839

39-
<PropertyGroup Label="Analyzer settings">
40-
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
41-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
42-
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
43-
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
44-
<AnalysisLevel>latest-all</AnalysisLevel>
45-
</PropertyGroup>
40+
<PropertyGroup Label="Analyzer settings">
41+
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
42+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
43+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
44+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
45+
<AnalysisLevel>latest-all</AnalysisLevel>
46+
</PropertyGroup>
4647

47-
<ItemGroup>
48-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
49-
<PackageReference Include="Microsoft.Bcl.TimeProvider" Version="8.0.0-preview.*" />
50-
</ItemGroup>
48+
<ItemGroup>
49+
<PackageReference Include="DotNet.ReproducibleBuilds" Version="1.1.1">
50+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
51+
<PrivateAssets>all</PrivateAssets>
52+
</PackageReference>
53+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
54+
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="All" />
55+
<PackageReference Include="Microsoft.Bcl.TimeProvider" Version="8.0.0-preview.*" />
56+
</ItemGroup>
5157

52-
<ItemGroup>
53-
<None Include="..\..\LICENSE">
54-
<Pack>True</Pack>
55-
<PackagePath>\</PackagePath>
56-
</None>
57-
<None Include="..\..\README.md">
58-
<Pack>True</Pack>
59-
<PackagePath>\</PackagePath>
60-
</None>
61-
</ItemGroup>
58+
<ItemGroup>
59+
<None Include="..\..\LICENSE">
60+
<Pack>True</Pack>
61+
<PackagePath>\</PackagePath>
62+
</None>
63+
<None Include="..\..\README.md">
64+
<Pack>True</Pack>
65+
<PackagePath>\</PackagePath>
66+
</None>
67+
</ItemGroup>
6268

6369
</Project>

0 commit comments

Comments
 (0)