Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 145 additions & 62 deletions .github/workflows/BuildDeploy.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,181 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_BuildDeploy --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: BuildDeploy

on:
push:
branches:
- main
workflow_dispatch:
inputs:
bump:
description: 'Release level'
required: true
type: choice
options:
- patch
- minor
- major

channel:
description: 'Release channel. none = stable RTM; alpha/beta/rc cut a pre-release.'
required: true
default: none
type: choice
options:
- none
- alpha
- beta
- rc

sourceRef:
description: 'Optional git ref (tag/branch/SHA) to release from. Leave blank to release from this branch.'
required: false
type: string
default: ''

permissions:
contents: write
id-token: write
packages: read

env:
configuration: Release

jobs:
windows-latest:
name: windows-latest
release:
runs-on: windows-latest

permissions: write-all
environment:
name: release
outputs:
semver2: ${{ steps.minver.outputs.NuGetPackageVersion }}
tag: ${{ steps.tagname.outputs.tag }}
prerelease: ${{ steps.tagname.outputs.prerelease }}
sourceSha: ${{ steps.sourcesha.outputs.sha }}
steps:
- uses: actions/checkout@v7
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ inputs.sourceRef }}
fetch-depth: 0

- name: Resolve built commit SHA
id: sourcesha
shell: bash
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"

- name: Compute version and tag
id: bump
uses: reactiveui/actions-common/.github/actions/compute-version-and-tag@main
with:
bump: ${{ inputs.bump }}
tag-prefix: v
pre-release-id: ${{ inputs.channel != 'none' && inputs.channel || '' }}
push-tag: 'false'

- name: Resolve release tag
id: tagname
shell: bash
run: |
{
echo "tag=${{ steps.bump.outputs.tag }}"
echo "prerelease=${{ steps.bump.outputs.prerelease }}"
} >> "$GITHUB_OUTPUT"

- name: Setup .NET
uses: actions/setup-dotnet@v5.3.0
with:
dotnet-version: |
dotnet-version: |
8.0.x
9.0.x
10.0.x
11.0.x
dotnet-quality: 'preview'
dotnet-quality: 'preview'
cache: true
cache-dependency-path: |
**/Directory.Packages.props
**/*.csproj
**/global.json
**/nuget.config

- name: Cache NuGet HTTP v3 feed responses
uses: actions/cache@v6
with:
path: '%LOCALAPPDATA%\NuGet\v3-cache'
key: ${{ runner.os }}-nugetv3-${{ hashFiles('**/Directory.Packages.props', '**/*.csproj', '**/global.json', '**/nuget.config') }}
restore-keys: |
${{ runner.os }}-nugetv3-

- name: Restore .NET workloads
shell: bash
working-directory: src
run: dotnet workload restore Extensions.Hosting.slnx --from-previous-sdk --skip-manifest-update

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
- name: Stamp version with MinVer
id: minver
uses: reactiveui/actions-common/.github/actions/minver@main
with:
setAllVars: true
- run: echo 'SemVer2=${{ steps.nbgv.outputs.SemVer2 }}'
tag-prefix: v
minimum-major-minor: '3.2'
auto-increment: minor
default-pre-release-identifiers: alpha.0
version-override: ${{ steps.bump.outputs.version }}

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v3
with:
vs-prerelease: true

- name: 'Cache: .nuke/temp, ~/.nuget/packages'
uses: actions/cache@v6
- name: Build
uses: reactiveui/actions-common/.github/actions/dotnet-build@main
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
configuration: ${{ env.configuration }}
src-folder: src
solution-file: Extensions.Hosting.slnx
create-packages: 'false'

- name: 'Run: Compile Pack'
run: ./build.cmd Pack
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
- name: Pack unsigned NuGet packages
shell: bash
working-directory: src
run: dotnet pack --no-restore --configuration "${{ env.configuration }}" Extensions.Hosting.slnx -o "${GITHUB_WORKSPACE}/packages"

- name: 'Publish: output'
- name: Upload unsigned packages
uses: actions/upload-artifact@v7
with:
name: output
path: output

- name: Changelog
uses: glennawatson/ChangeLog@v1
id: changelog

- name: Create Release
uses: actions/create-release@v1.1.4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
name: unsigned-nuget
path: packages/*.nupkg
if-no-files-found: error

publish-nuget:
needs: release
runs-on: ubuntu-latest
environment:
name: release
permissions:
id-token: write
steps:
- name: Download unsigned packages
uses: actions/download-artifact@v8
with:
tag_name: ${{ steps.nbgv.outputs.SemVer2 }}
release_name: ${{ steps.nbgv.outputs.SemVer2 }}
body: |
${{ steps.changelog.outputs.commitLog }}

- name: 'Run: Deploy'
run: ./build.cmd Deploy
env:
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
name: unsigned-nuget

- name: Setup .NET
uses: actions/setup-dotnet@v5

- name: NuGet login (OIDC trusted publishing)
id: nuget-login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841
with:
user: ${{ secrets.NUGET_USER }}

- name: Push to NuGet
shell: bash
run: |
for pkg in *.nupkg; do
dotnet nuget push "$pkg" --source https://api.nuget.org/v3/index.json --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}"
done

create-release:
needs: [release, publish-nuget]
uses: reactiveui/actions-common/.github/workflows/workflow-common-create-release.yml@main
with:
version: ${{ needs.release.outputs.semver2 }}
tag: ${{ needs.release.outputs.tag }}
target: ${{ needs.release.outputs.sourceSha }}
prerelease: ${{ needs.release.outputs.prerelease == 'true' }}
artifactName: unsigned-nuget
28 changes: 2 additions & 26 deletions .github/workflows/BuildOnly.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_BuildOnly --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: BuildOnly

on:
Expand All @@ -33,19 +17,12 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v5.3.0
with:
dotnet-version: |
dotnet-version: |
8.0.x
9.0.x
10.0.x
11.0.x
dotnet-quality: 'preview'

- name: NBGV
id: nbgv
uses: dotnet/nbgv@master
with:
setAllVars: true
- run: echo 'SemVer2=${{ steps.nbgv.outputs.SemVer2 }}'
dotnet-quality: 'preview'

- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v3
Expand All @@ -68,7 +45,6 @@ jobs:
working-directory: 'src'
run: |
dotnet test --solution Extensions.Hosting.slnx \
--no-build \
--configuration Release \
--coverage \
--coverage-output-format cobertura \
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.300" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.8.0" />
<PackageVersion Include="Microsoft.WindowsAppSDK" Version="2.2.0" />
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.10.85" />
<PackageVersion Include="MinVer" Version="7.0.0" />
<PackageVersion Include="NuGet.Protocol" Version="7.6.0" />
<PackageVersion Include="Nuke.Common" Version="10.1.0" />
<PackageVersion Include="PublicApiGenerator" Version="11.5.4" />
Expand Down
6 changes: 2 additions & 4 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Nuke.Common;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.NerdbankGitVersioning;
using Nuke.Common.Tools.DotNet;
using Serilog;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
Expand Down Expand Up @@ -32,15 +32,14 @@ sealed partial class Build : NukeBuild

[GitRepository] readonly GitRepository Repository;
readonly Solution Solution = SolutionFile.ReadSolution();
[NerdbankGitVersioning] readonly NerdbankGitVersioning NerdbankVersioning;
[Parameter][Secret] readonly string NuGetApiKey;
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

AbsolutePath PackagesDirectory => RootDirectory / "output";

Target Print => _ => _
.Executes(() => Log.Information("NerdbankVersioning = {Value}", NerdbankVersioning.NuGetPackageVersion));
.Executes(() => Log.Information("MinVerVersionOverride = {Value}", Environment.GetEnvironmentVariable("MinVerVersionOverride") ?? "<auto>"));

Target Clean => _ => _
.Before(Restore)
Expand Down Expand Up @@ -85,7 +84,6 @@ sealed partial class Build : NukeBuild
DotNetPack(settings => settings
.SetConfiguration(Configuration)
.SetNoBuild(true)
.SetVersion(NerdbankVersioning.NuGetPackageVersion)
.SetOutputDirectory(PackagesDirectory)
.CombineWith(packableProjects, (packSettings, project) =>
packSettings.SetProject(project)));
Expand Down
5 changes: 0 additions & 5 deletions build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@

<ItemGroup>
<PackageReference Include="CP.Nuke.BuildTools" />
<PackageReference Include="Nerdbank.GitVersioning" />
<PackageReference Include="Nuke.Common" />
</ItemGroup>

<ItemGroup>
<PackageDownload Include="nbgv" Version="[3.10.85]" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>

<!-- MinVer (versioning) — replaces Nerdbank.GitVersioning. Floor at 3.2
so untagged builds produce 3.2.x-alpha.0.<height> until a v3.2.x
(or later) tag is reachable. -->
<PropertyGroup>
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
<MinVerDefaultPreReleaseIdentifiers>alpha.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerTagPrefix>v</MinVerTagPrefix>
<MinVerMinimumMajorMinor>3.2</MinVerMinimumMajorMinor>
</PropertyGroup>

<PropertyGroup Condition="'$(IsTestProject)' == 'true'">
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
<TUnitImplicitUsings>false</TUnitImplicitUsings>
Expand Down Expand Up @@ -72,6 +82,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MinVer" PrivateAssets="all" />
<PackageReference Include="StyleSharp.Analyzers" PrivateAssets="all" />
<PackageReference Include="Roslynator.Analyzers" PrivateAssets="All" />
</ItemGroup>
Expand Down
Loading