Skip to content

Commit d07267d

Browse files
committed
Update dependencies, migrate to GitHub Actions
1 parent 9980912 commit d07267d

14 files changed

Lines changed: 124 additions & 66 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# If this file is renamed, the incrementing run attempt number will be reset.
2+
3+
name: CI
4+
5+
on:
6+
push:
7+
branches: [ "dev", "main" ]
8+
pull_request:
9+
branches: [ "dev", "main" ]
10+
11+
env:
12+
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
13+
CI_TARGET_BRANCH: ${{ github.head_ref || github.ref_name }}
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-22.04
19+
20+
permissions:
21+
contents: write
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Setup
26+
uses: actions/setup-dotnet@v4
27+
with:
28+
dotnet-version: 8.0.x
29+
- name: Compute build number
30+
run: |
31+
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+200))" >> $GITHUB_ENV
32+
- name: Build and Publish
33+
env:
34+
DOTNET_CLI_TELEMETRY_OPTOUT: true
35+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
36+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
shell: pwsh
38+
run: |
39+
./Build.ps1

Build.ps1

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,77 @@
1-
# This script originally (c) 2016 Serilog Contributors - license Apache 2.0
2-
3-
echo "build: Build started"
1+
Write-Output "build: Build started"
42

53
Push-Location $PSScriptRoot
64

5+
Write-Output "build: Tool versions follow"
6+
7+
dotnet --version
8+
dotnet --list-sdks
9+
710
if(Test-Path .\artifacts) {
8-
echo "build: Cleaning .\artifacts"
9-
Remove-Item .\artifacts -Force -Recurse
11+
Write-Output "build: Cleaning ./artifacts"
12+
Remove-Item ./artifacts -Force -Recurse
1013
}
1114

1215
& dotnet restore --no-cache
1316

14-
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
15-
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
16-
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)).Replace("/", "-"))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
17+
$dbp = [Xml] (Get-Content .\Directory.Build.props)
18+
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
19+
20+
Write-Output "build: Package version prefix is $versionPrefix"
1721

18-
echo "build: Version suffix is $suffix"
22+
$branch = @{ $true = $env:CI_TARGET_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:CI_TARGET_BRANCH];
23+
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:CI_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:CI_BUILD_NUMBER];
24+
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)) -replace '([^a-zA-Z0-9\-]*)', '')-$revision"}[$branch -eq "main" -and $revision -ne "local"]
1925

20-
foreach ($src in ls src/*) {
26+
Write-Output "build: Package version suffix is $suffix"
27+
28+
foreach ($src in Get-ChildItem src/*) {
2129
Push-Location $src
2230

23-
echo "build: Packaging project in $src"
31+
Write-Output "build: Packaging project in $src"
2432

2533
if ($suffix) {
26-
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --include-source
34+
& dotnet pack -c Release -o ../../artifacts --version-suffix=$suffix
2735
} else {
28-
& dotnet pack -c Release -o ..\..\artifacts --include-source
36+
& dotnet pack -c Release -o ../../artifacts
2937
}
30-
if($LASTEXITCODE -ne 0) { exit 1 }
38+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
3139

3240
Pop-Location
3341
}
3442

35-
foreach ($test in ls test/*.Benchmarks) {
36-
Push-Location $test
37-
38-
echo "build: Building performance test project in $test"
39-
40-
& dotnet build -c Release
41-
if($LASTEXITCODE -ne 0) { exit 2 }
43+
Write-Output "build: Checking complete solution builds"
44+
& dotnet build
45+
if($LASTEXITCODE -ne 0) { throw "Solution build failed" }
4246

43-
Pop-Location
44-
}
4547

46-
foreach ($test in ls test/*.Tests) {
48+
foreach ($test in Get-ChildItem test/*.Tests) {
4749
Push-Location $test
4850

49-
echo "build: Testing project in $test"
51+
Write-Output "build: Testing project in $test"
5052

5153
& dotnet test -c Release
52-
if($LASTEXITCODE -ne 0) { exit 3 }
54+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
5355

5456
Pop-Location
5557
}
5658

5759
Pop-Location
60+
61+
if ($env:NUGET_API_KEY) {
62+
# GitHub Actions will only supply this to branch builds and not PRs. We publish
63+
# builds from any branch this action targets (i.e. main and dev).
64+
65+
Write-Output "build: Publishing NuGet packages"
66+
67+
foreach ($nupkg in Get-ChildItem artifacts/*.nupkg) {
68+
& dotnet nuget push -k $env:NUGET_API_KEY -s https://api.nuget.org/v3/index.json "$nupkg"
69+
if($LASTEXITCODE -ne 0) { throw "Publishing failed" }
70+
}
71+
72+
if (!($suffix)) {
73+
Write-Output "build: Creating release for version $versionPrefix"
74+
75+
iex "gh release create v$versionPrefix --title v$versionPrefix --generate-notes $(get-item ./artifacts/*.nupkg) $(get-item ./artifacts/*.snupkg)"
76+
}
77+
}

Directory.Build.props

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project>
2+
<PropertyGroup>
3+
<ImplicitUsings>enable</ImplicitUsings>
4+
<Nullable>enable</Nullable>
5+
<LangVersion>latest</LangVersion>
6+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
7+
<VersionPrefix>3.1.0</VersionPrefix>
8+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
9+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10+
<!-- The condition is required to support BenchmarkDotNet -->
11+
<SignAssembly Condition="Exists('../../assets/SerilogTracing.snk')">true</SignAssembly>
12+
<AssemblyOriginatorKeyFile>../../assets/SerilogTracing.snk</AssemblyOriginatorKeyFile>
13+
<IncludeSymbols>true</IncludeSymbols>
14+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
15+
<NoWarn>NETSDK1138</NoWarn>
16+
</PropertyGroup>
17+
</Project>

Superpower.sln

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AC295EEA-D31
77
EndProject
88
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "global", "global", "{66B005E9-A083-41E8-BD89-4D6E753CD8BF}"
99
ProjectSection(SolutionItems) = preProject
10-
appveyor.yml = appveyor.yml
1110
Benchmark.ps1 = Benchmark.ps1
1211
Build.ps1 = Build.ps1
1312
LICENSE = LICENSE

Superpower.sln.DotSettings

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
22
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=TypeParameters/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="T" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;</s:String>
3+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=2c62818f_002D621b_002D4425_002Dadc9_002D78611099bfcb/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Any" AccessRightKinds="Any" Description="Type parameters"&gt;&lt;ElementKinds&gt;&lt;Kind Name="TYPE_PARAMETER" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" WarnAboutPrefixesAndSuffixes="False" Prefix="T" Suffix="" Style="AaBb"&gt;&lt;ExtraRule Prefix="" Suffix="" Style="AA_BB" /&gt;&lt;/Policy&gt;&lt;/Policy&gt;</s:String>
4+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EPredefinedNamingRulesToUserRulesUpgrade/@EntryIndexedValue">True</s:Boolean>
35
<s:Boolean x:Key="/Default/UserDictionary/Words/=allocs/@EntryIndexedValue">True</s:Boolean>
46
<s:Boolean x:Key="/Default/UserDictionary/Words/=errloc/@EntryIndexedValue">True</s:Boolean>
57
<s:Boolean x:Key="/Default/UserDictionary/Words/=expsign/@EntryIndexedValue">True</s:Boolean>

appveyor.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "8.0.300",
3+
"version": "10.0.201",
44
"rollForward": "latestFeature"
55
}
66
}

sample/DateTimeTextParser/DateTimeParser.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<Nullable>enable</Nullable>
7+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
78
</PropertyGroup>
89

910
<ItemGroup>

sample/IntCalc/IntCalc.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<Nullable>enable</Nullable>
7+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
78
</PropertyGroup>
89

910
<ItemGroup>

sample/JsonParser/JsonParser.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net10.0</TargetFramework>
66
<Nullable>enable</Nullable>
7+
<GenerateDocumentationFile>false</GenerateDocumentationFile>
78
</PropertyGroup>
89

910
<ItemGroup>

0 commit comments

Comments
 (0)