Skip to content

Commit 9262ae2

Browse files
johnkorsclaude
andcommitted
Migrate build to Bullseye and wire it into GH Actions
Replaces raw dotnet restore/build/test/pack/nuget-push calls in the workflows with a single Bullseye build project (build/) exposing restore, build, test, pack and publish targets, so local and CI builds run through the same pipeline. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent cf0d3bb commit 9262ae2

6 files changed

Lines changed: 87 additions & 14 deletions

File tree

.github/workflows/CI.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ jobs:
2323
dotnet-version: |
2424
10.0.x
2525
11.0.x
26-
- name: Restore dependencies
27-
run: dotnet restore source
28-
- name: Build
29-
run: dotnet build --no-restore source
30-
- name: Test
31-
run: dotnet test --no-build source
26+
- name: Build & Test
27+
run: dotnet run --project build -- test
3228
env:
3329
Slackbot_SlackApiKey_BotUser: ${{ secrets.SLACKBOT_SLACKAPIKEY_BOTUSER }}
3430
Slackbot_SlackApiKey_SlackApp: ${{ secrets.SLACKBOT_SLACKAPIKEY_SLACKAPP }}

.github/workflows/PreRelease.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ jobs:
2727
uses: gittools/actions/gitversion/execute@v0
2828
with:
2929
useConfigFile: true
30-
- name: Pack
31-
run: dotnet pack source /p:Version=${{ steps.gitversion.outputs.NuGetVersionV2 }}-${{ steps.gitversion.outputs.ShortSha }} /p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }} /p:PackageReleaseNotes="https://github.com/$GITHUB_REPOSITORY/releases/tag/${{ steps.gitversion.outputs.NuGetVersionV2 }}" -o ./releases
32-
- name: Publish
33-
run: dotnet nuget push ./releases/**/*.nupkg -k=${{ secrets.NUGETORGAPIKEY }} -s=nuget.org
30+
- name: Pack & Publish
31+
run: dotnet run --project build -- publish
32+
env:
33+
BUILD_VERSION: ${{ steps.gitversion.outputs.NuGetVersionV2 }}-${{ steps.gitversion.outputs.ShortSha }}
34+
BUILD_INFORMATIONAL_VERSION: ${{ steps.gitversion.outputs.informationalVersion }}
35+
BUILD_RELEASE_NOTES: https://github.com/${{ github.repository }}/releases/tag/${{ steps.gitversion.outputs.NuGetVersionV2 }}
36+
NUGET_API_KEY: ${{ secrets.NUGETORGAPIKEY }}

.github/workflows/Release.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,13 @@ jobs:
2727
uses: gittools/actions/gitversion/execute@v0
2828
with:
2929
useConfigFile: true
30-
- name: Pack
31-
run: dotnet pack source /p:Version=${{ steps.gitversion.outputs.majorMinorPatch }} /p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }} /p:PackageReleaseNotes="https://github.com/$GITHUB_REPOSITORY/releases/tag/${{ steps.gitversion.outputs.majorMinorPatch }}" -o ./releases
32-
- name: Publish
33-
run: dotnet nuget push ./releases/**/*.nupkg -k=${{ secrets.NUGETORGAPIKEY }} -s=nuget.org
30+
- name: Pack & Publish
31+
run: dotnet run --project build -- publish
32+
env:
33+
BUILD_VERSION: ${{ steps.gitversion.outputs.majorMinorPatch }}
34+
BUILD_INFORMATIONAL_VERSION: ${{ steps.gitversion.outputs.informationalVersion }}
35+
BUILD_RELEASE_NOTES: https://github.com/${{ github.repository }}/releases/tag/${{ steps.gitversion.outputs.majorMinorPatch }}
36+
NUGET_API_KEY: ${{ secrets.NUGETORGAPIKEY }}
3437
- run: git log $(git describe --tags --abbrev=0)..HEAD --oneline
3538
- name: Generate CHANGELOG.md
3639
id: releasenotes

build/Build.csproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net10.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<IsPackable>false</IsPackable>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Bullseye" Version="6.2.0" />
13+
<PackageReference Include="SimpleExec" Version="13.1.0" />
14+
</ItemGroup>
15+
16+
</Project>

build/Program.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Bullseye;
2+
using static Bullseye.Targets;
3+
using static SimpleExec.Command;
4+
5+
const string solution = "source/Slackbot.Net.sln";
6+
const string releasesDir = "releases";
7+
8+
const string Restore = "restore";
9+
const string Build = "build";
10+
const string Test = "test";
11+
const string Pack = "pack";
12+
const string Publish = "publish";
13+
14+
Target(Restore, () => RunAsync("dotnet", $"restore {solution}"));
15+
16+
Target(Build, new[] { Restore }, () => RunAsync("dotnet", $"build {solution} --no-restore"));
17+
18+
Target(Test, new[] { Build }, () => RunAsync("dotnet", $"test {solution} --no-build"));
19+
20+
Target(Pack, new[] { Build }, async () =>
21+
{
22+
var version = Environment.GetEnvironmentVariable("BUILD_VERSION");
23+
var informationalVersion = Environment.GetEnvironmentVariable("BUILD_INFORMATIONAL_VERSION");
24+
var releaseNotes = Environment.GetEnvironmentVariable("BUILD_RELEASE_NOTES");
25+
26+
var properties = "";
27+
if (!string.IsNullOrWhiteSpace(version))
28+
properties += $" /p:Version={version}";
29+
if (!string.IsNullOrWhiteSpace(informationalVersion))
30+
properties += $" /p:InformationalVersion={informationalVersion}";
31+
if (!string.IsNullOrWhiteSpace(releaseNotes))
32+
properties += $" /p:PackageReleaseNotes=\"{releaseNotes}\"";
33+
34+
await RunAsync("dotnet", $"pack {solution} -c Release -o {releasesDir}{properties}");
35+
});
36+
37+
Target(Publish, new[] { Pack }, async () =>
38+
{
39+
var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY")
40+
?? throw new InvalidOperationException("NUGET_API_KEY environment variable is required for publish");
41+
42+
foreach (var package in Directory.GetFiles(releasesDir, "*.nupkg", SearchOption.AllDirectories))
43+
await RunAsync("dotnet", $"nuget push \"{package}\" -k {apiKey} -s https://api.nuget.org/v3/index.json --skip-duplicate");
44+
});
45+
46+
Target("default", new[] { Test });
47+
48+
await RunTargetsAndExitAsync(args);

source/Slackbot.Net.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ EndProjectSection
2121
EndProject
2222
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWorld", "..\Samples\HelloWorld\HelloWorld.csproj", "{15519075-7574-4F9B-820F-D8F7190AF460}"
2323
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Build", "..\build\Build.csproj", "{A74FB1E7-9499-47E6-BDD0-4C5D8AEA0DF3}"
25+
EndProject
2426
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Slackbot.Net.Shared", "src\Slackbot.Net.Shared\Slackbot.Net.Shared.csproj", "{BA30DCAA-D5D0-4BA6-8DAE-562D3BAA9943}"
2527
EndProject
2628
Global
@@ -49,12 +51,17 @@ Global
4951
{BA30DCAA-D5D0-4BA6-8DAE-562D3BAA9943}.Debug|Any CPU.Build.0 = Debug|Any CPU
5052
{BA30DCAA-D5D0-4BA6-8DAE-562D3BAA9943}.Release|Any CPU.ActiveCfg = Release|Any CPU
5153
{BA30DCAA-D5D0-4BA6-8DAE-562D3BAA9943}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{A74FB1E7-9499-47E6-BDD0-4C5D8AEA0DF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{A74FB1E7-9499-47E6-BDD0-4C5D8AEA0DF3}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{A74FB1E7-9499-47E6-BDD0-4C5D8AEA0DF3}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{A74FB1E7-9499-47E6-BDD0-4C5D8AEA0DF3}.Release|Any CPU.Build.0 = Release|Any CPU
5258
EndGlobalSection
5359
GlobalSection(NestedProjects) = preSolution
5460
{E844F8E7-7D8B-4147-AED6-85EDF30717A2} = {ED8E20FC-B173-40FF-B447-D74B58FC27C6}
5561
{D6C3CE02-3D77-4313-AC43-1A8E990DCB9C} = {53AD07F7-25C8-4F0F-A551-4979D2DD08F3}
5662
{0B4A58E9-FF02-4942-9345-D9E255C5C87D} = {53AD07F7-25C8-4F0F-A551-4979D2DD08F3}
5763
{15519075-7574-4F9B-820F-D8F7190AF460} = {F22E2B7D-C611-4444-BBCB-F4FC4DAC956C}
5864
{BA30DCAA-D5D0-4BA6-8DAE-562D3BAA9943} = {53AD07F7-25C8-4F0F-A551-4979D2DD08F3}
65+
{A74FB1E7-9499-47E6-BDD0-4C5D8AEA0DF3} = {10CBAF56-F382-480E-B8BE-CBF270617AD8}
5966
EndGlobalSection
6067
EndGlobal

0 commit comments

Comments
 (0)