Skip to content

Commit

Permalink
Add CI/CD (#2)
Browse files Browse the repository at this point in the history
# Modifications
- Add build-publish workflow with GitVersion
- Formatting / Typos
  • Loading branch information
Twinki14 authored Dec 30, 2023
1 parent 87def65 commit c615213
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ contact_links:
about: Official Serilog repository for Serilog-specific help & assistance
- name: Visit the Serilog Wiki
url: https://github.com/serilog/serilog/wiki
about: Official wiki page for Serilog, provides you with more complex examples, though there's no guarentee they work wit v2.12.0
about: Official wiki page for Serilog, provides you with more complex examples, though there's no guarentee they work with v2.12.0
72 changes: 72 additions & 0 deletions .github/workflows/build-publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Build - Publish
on:
push:
workflow_dispatch:
inputs:
publish:
type: boolean
default: false
description: Publish package

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

env:
is-default-branch: ${{ github.ref_name == github.event.repository.default_branch }}
is-tag: ${{ startsWith(github.ref, 'refs/tags/') }}
do-manual-publish: ${{ github.event_name == 'workflow_dispatch' && inputs.publish == true }}

jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup - GitVersion
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
preferLatestVersion: true

- name: Setup - .NET Framework 4.8
run: |
choco install netfx-4.8-devpack -y
dotnet --version # Verify installation
- name: Setup - .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
source-url: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
env:
NUGET_AUTH_TOKEN: ${{ github.token }}

- name: GitVersion
id: git-version
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true

- name: Dotnet - Restore
run: dotnet restore

- name: Dotnet - Build
run: dotnet build -c Release --no-restore

- name: Dotnet - Test
run: dotnet test --filter Serilog.Tests -c Release --no-restore

- name: Dotnet - Pack
run: dotnet pack -c Release --no-restore

- name: Publish - NuGet
if: ${{ env.is-tag == 'true' }}
run: dotnet nuget push **/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate

- name: Publish - GitHub
if: ${{ env.is-default-branch == 'true' || env.is-tag == 'true' || env.do-manual-publish == 'true' }}
run: dotnet nuget push **/*.nupkg --skip-duplicate
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Workaround for https://github.com/dotnet/sdk/pull/908 -->
<Target Name="GetPackagingOutputs" />
<PropertyGroup>
<LangVersion>12</LangVersion>
<LangVersion>10</LangVersion>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<Nullable>enable</Nullable>
Expand Down
11 changes: 11 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mode: ContinuousDelivery
branches:
main:
regex: ^v2.12.0-cfx$
mode: ContinuousDeployment
tag: ci
track-merge-target: true
ignore:
sha: []
merge-message-formats: {}
tag-prefix: "v"
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.0",
"version": "6.0.0",
"allowPrerelease": false,
"rollForward": "latestFeature"
}
Expand Down
4 changes: 2 additions & 2 deletions src/Serilog/Serilog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<TreatSpecificWarningsAsErrors />
<TargetFramework>net45</TargetFramework>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'net452' ">
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
<DefineConstants>$(DefineConstants);FEATURE_REMOTING;FEATURE_HASHTABLE</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
33 changes: 18 additions & 15 deletions test/Serilog.Tests/Serilog.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,28 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.10.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.10.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" PrivateAssets="all" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.11.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.8.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="17.8.0" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net452' ">
Expand All @@ -28,16 +43,4 @@
<PropertyGroup Condition=" '$(TargetFramework)' == 'net48' ">
<DefineConstants>$(DefineConstants);TEST_FEATURE_APPDOMAIN;FEATURE_ASYNCLOCAL;FEATURE_GETCURRENTMETHOD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<DefineConstants>$(DefineConstants);FEATURE_ASYNCLOCAL</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<DefineConstants>$(DefineConstants);FEATURE_ASYNCLOCAL;FEATURE_DEFAULT_INTERFACE;FEATURE_SPAN;FEATURE_ASYNCDISPOSABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<DefineConstants>$(DefineConstants);FEATURE_ASYNCLOCAL;FEATURE_DEFAULT_INTERFACE;FEATURE_SPAN;FEATURE_ASYNCDISPOSABLE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<DefineConstants>$(DefineConstants);FEATURE_ASYNCLOCAL;FEATURE_DEFAULT_INTERFACE;FEATURE_SPAN;FEATURE_DATE_AND_TIME_ONLY;FEATURE_ITUPLE;FEATURE_ASYNCDISPOSABLE</DefineConstants>
</PropertyGroup>
</Project>

0 comments on commit c615213

Please sign in to comment.