Skip to content

Commit 1600d57

Browse files
authored
Merge pull request #19 from nblumhardt/actions-build
Update to Actions build, update dependencies
2 parents d86aa61 + 6b9b126 commit 1600d57

File tree

7 files changed

+94
-45
lines changed

7 files changed

+94
-45
lines changed

.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: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,78 @@
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
13-
if($LASTEXITCODE -ne 0) { exit 1 }
1416

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

19-
echo "build: Version suffix is $suffix"
20+
Write-Output "build: Package version prefix is $versionPrefix"
2021

21-
foreach ($src in ls src/*) {
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"]
25+
26+
Write-Output "build: Package version suffix is $suffix"
27+
28+
foreach ($src in Get-ChildItem src/*) {
2229
Push-Location $src
2330

24-
echo "build: Packaging project in $src"
31+
Write-Output "build: Packaging project in $src"
2532

2633
if ($suffix) {
2734
& dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix
28-
& dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix
35+
& dotnet pack -c Release -o ../../artifacts --no-build --version-suffix=$suffix
2936
} else {
3037
& dotnet publish -c Release -o ./obj/publish
31-
& dotnet pack -c Release -o ..\..\artifacts --no-build
38+
& dotnet pack -c Release -o ../../artifacts --no-build
3239
}
33-
if($LASTEXITCODE -ne 0) { exit 1 }
40+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
3441

3542
Pop-Location
3643
}
3744

38-
foreach ($test in ls test/*.Tests) {
45+
Write-Output "build: Checking complete solution builds"
46+
& dotnet build
47+
if($LASTEXITCODE -ne 0) { throw "Solution build failed" }
48+
49+
foreach ($test in Get-ChildItem test/*.Tests) {
3950
Push-Location $test
4051

41-
echo "build: Testing project in $test"
52+
Write-Output "build: Testing project in $test"
4253

4354
& dotnet test -c Release
44-
if($LASTEXITCODE -ne 0) { exit 3 }
55+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
4556

4657
Pop-Location
4758
}
4859

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

Directory.Build.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionPrefix>1.0.1</VersionPrefix>
4+
</PropertyGroup>
5+
</Project>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Seq.App.HttpRequest [![Build status](https://ci.appveyor.com/api/projects/status/63ki29bjjgk8htn3/branch/dev?svg=true)](https://ci.appveyor.com/project/datalust/seq-app-httprequest/branch/dev) [![NuGet Package](https://img.shields.io/nuget/vpre/seq.app.httprequest)](https://nuget.org/packages/seq.app.httprequest)
1+
# Seq.App.HttpRequest [![NuGet Package](https://img.shields.io/nuget/vpre/seq.app.httprequest)](https://nuget.org/packages/seq.app.httprequest)
22

33
Send events and notifications from Seq to a remote HTTP/REST/Webhook endpoint. Requires Seq 2021.4 or better.
44

appveyor.yml

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

seq-app-httprequest.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{0F8E84A5-952
1515
ProjectSection(SolutionItems) = preProject
1616
.gitattributes = .gitattributes
1717
.gitignore = .gitignore
18-
appveyor.yml = appveyor.yml
1918
Build.ps1 = Build.ps1
2019
LICENSE = LICENSE
2120
README.md = README.md
2221
Run.ps1 = Run.ps1
22+
Directory.Build.props = Directory.Build.props
2323
EndProjectSection
2424
EndProject
2525
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "asset", "asset", "{AC60371C-2888-45BB-9770-2A690DEA80FA}"

src/Seq.App.HttpRequest/Seq.App.HttpRequest.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<Description>Send events and notifications from Seq to a remote HTTP/REST/WebHook endpoint.</Description>
5-
<VersionPrefix>1.0.1</VersionPrefix>
65
<Authors>Datalust, Serilog Contributors</Authors>
76
<TargetFramework>net6.0</TargetFramework>
87
<PackageTags>seq-app</PackageTags>
@@ -23,7 +22,7 @@
2322
<ItemGroup>
2423
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
2524
<PackageReference Include="Seq.Apps" Version="2023.4.0" />
26-
<PackageReference Include="Seq.Syntax" Version="1.0.0" />
25+
<PackageReference Include="Seq.Syntax" Version="1.1.0-*" />
2726
</ItemGroup>
2827

2928
<ItemGroup>

0 commit comments

Comments
 (0)