Skip to content

Commit 7f6b505

Browse files
authored
Merge pull request #9 from datalust/ci/actions
Port to GitHub Actions
2 parents e877a84 + a61fb1f commit 7f6b505

File tree

10 files changed

+110
-95
lines changed

10 files changed

+110
-95
lines changed

.github/workflows/ci.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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-latest
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: 9.0.x
29+
- name: Compute build number
30+
shell: bash
31+
run: |
32+
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+2300))" >> $GITHUB_ENV
33+
- name: Build and Publish
34+
env:
35+
DOTNET_CLI_TELEMETRY_OPTOUT: true
36+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
shell: pwsh
39+
run: |
40+
./Build.ps1

Build.ps1

+63-31
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,81 @@
1-
# This script originally (c) 2016 Serilog Contributors - license Apache 2.0
1+
Write-Output "build: Tool versions follow"
22

3-
echo "build: Build started"
3+
dotnet --version
4+
dotnet --list-sdks
5+
6+
Write-Output "build: Build started"
47

58
Push-Location $PSScriptRoot
9+
try {
10+
if(Test-Path .\artifacts) {
11+
Write-Output "build: Cleaning ./artifacts"
12+
Remove-Item ./artifacts -Force -Recurse
13+
}
614

7-
if(Test-Path .\artifacts) {
8-
echo "build: Cleaning .\artifacts"
9-
Remove-Item .\artifacts -Force -Recurse
10-
}
15+
& dotnet restore --no-cache
16+
17+
$dbp = [Xml] (Get-Content .\Directory.Version.props)
18+
$versionPrefix = $dbp.Project.PropertyGroup.VersionPrefix
1119

12-
& dotnet restore --no-cache
13-
if($LASTEXITCODE -ne 0) { exit 1 }
20+
Write-Output "build: Package version prefix is $versionPrefix"
1421

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"]
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+
$commitHash = $(git rev-parse --short HEAD)
26+
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1827

19-
echo "build: Version suffix is $suffix"
28+
Write-Output "build: Package version suffix is $suffix"
29+
Write-Output "build: Build version suffix is $buildSuffix"
2030

21-
foreach ($src in ls src/*) {
22-
Push-Location $src
31+
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true
32+
if($LASTEXITCODE -ne 0) { throw "Build failed" }
2333

24-
echo "build: Packaging project in $src"
34+
foreach ($src in Get-ChildItem src/*) {
35+
Push-Location $src
2536

26-
if ($suffix) {
27-
& dotnet publish -c Release -o ./obj/publish --version-suffix=$suffix
28-
& dotnet pack -c Release -o ..\..\artifacts --no-build --version-suffix=$suffix
29-
} else {
30-
& dotnet publish -c Release -o ./obj/publish
31-
& dotnet pack -c Release -o ..\..\artifacts --no-build
37+
Write-Output "build: Packaging project in $src"
38+
39+
if ($suffix) {
40+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts --version-suffix=$suffix
41+
} else {
42+
& dotnet pack -c Release --no-build --no-restore -o ../../artifacts
43+
}
44+
if($LASTEXITCODE -ne 0) { throw "Packaging failed" }
45+
46+
Pop-Location
3247
}
33-
if($LASTEXITCODE -ne 0) { exit 1 }
3448

35-
Pop-Location
36-
}
49+
if(Test-Path .\test) {
50+
foreach ($test in Get-ChildItem test/*.Tests) {
51+
Push-Location $test
3752

38-
foreach ($test in ls test/*.Tests) {
39-
Push-Location $test
53+
Write-Output "build: Testing project in $test"
4054

41-
echo "build: Testing project in $test"
55+
& dotnet test -c Release --no-build --no-restore
56+
if($LASTEXITCODE -ne 0) { throw "Testing failed" }
4257

43-
& dotnet test -c Release
44-
if($LASTEXITCODE -ne 0) { exit 3 }
58+
Pop-Location
59+
}
60+
}
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+
}
4572

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+
}
79+
} finally {
4680
Pop-Location
4781
}
48-
49-
Pop-Location

Directory.Version.props

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<VersionPrefix>1.0.0</VersionPrefix>
4+
</PropertyGroup>
5+
</Project>

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Seq.Input.RabbitMQ [![Build status](https://ci.appveyor.com/api/projects/status/lxab9qqdtqupk6y4?svg=true)](https://ci.appveyor.com/project/datalust/seq-input-rabbitmq)
1+
# Seq.Input.RabbitMQ [![CI](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml/badge.svg)](https://github.com/datalust/seq-input-rabbitmq/actions/workflows/ci.yml)
22

33
A Seq custom input that pulls events from RabbitMQ. **Requires Seq 5.1+.**
44

appveyor.yml

-23
This file was deleted.

example/Demo/Demo.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<OutputType>Exe</OutputType>
66
</PropertyGroup>
77

seq-input-rabbitmq.sln

-9
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sln", "sln", "{7D1D14F7-D40
1212
EndProject
1313
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{704915B0-6D95-4CF8-ACC2-5ED939A2913C}"
1414
EndProject
15-
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{BE42997A-5927-46E1-AFB5-C1D7A255212E}"
16-
EndProject
1715
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ", "src\Seq.Input.RabbitMQ\Seq.Input.RabbitMQ.csproj", "{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}"
1816
EndProject
19-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Seq.Input.RabbitMQ.Tests", "test\Seq.Input.RabbitMQ.Tests\Seq.Input.RabbitMQ.Tests.csproj", "{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}"
20-
EndProject
2117
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "example", "example", "{584683E5-0578-42F0-A958-3AAB3661AA9E}"
2218
EndProject
2319
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo", "example\Demo\Demo.csproj", "{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}"
@@ -32,10 +28,6 @@ Global
3228
{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
3329
{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
3430
{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0}.Release|Any CPU.Build.0 = Release|Any CPU
35-
{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36-
{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Debug|Any CPU.Build.0 = Debug|Any CPU
37-
{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.ActiveCfg = Release|Any CPU
38-
{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008}.Release|Any CPU.Build.0 = Release|Any CPU
3931
{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
4032
{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Debug|Any CPU.Build.0 = Debug|Any CPU
4133
{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -46,7 +38,6 @@ Global
4638
EndGlobalSection
4739
GlobalSection(NestedProjects) = preSolution
4840
{E80E7949-A3AE-4C7C-9083-9FE9EE1F78E0} = {704915B0-6D95-4CF8-ACC2-5ED939A2913C}
49-
{9FF2C707-DD8D-4B9C-97A7-4E9F0D9D0008} = {BE42997A-5927-46E1-AFB5-C1D7A255212E}
5041
{99D4AAE3-35B3-4BE1-AA5F-7CC8E6B49A07} = {584683E5-0578-42F0-A958-3AAB3661AA9E}
5142
EndGlobalSection
5243
GlobalSection(ExtensibilityGlobals) = postSolution

src/Seq.Input.RabbitMQ/Seq.Input.RabbitMQ.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netstandard2.0</TargetFramework>
4-
<VersionPrefix>1.0.0</VersionPrefix>
54
<Description>Ingest events into Seq directly from RabbitMQ</Description>
65
<Authors>Datalust and Contributors</Authors>
76
<PackageTags>seq-app</PackageTags>

test/Seq.Input.RabbitMQ.Tests/Seq.Input.RabbitMQ.Tests.csproj

-15
This file was deleted.

test/Seq.Input.RabbitMQ.Tests/UnitTest1.cs

-14
This file was deleted.

0 commit comments

Comments
 (0)