diff --git a/.github/workflows/BuildDeploy.yml b/.github/workflows/BuildDeploy.yml index c7d86de..c7b1c75 100644 --- a/.github/workflows/BuildDeploy.yml +++ b/.github/workflows/BuildDeploy.yml @@ -1,98 +1,181 @@ -# ------------------------------------------------------------------------------ -# -# -# 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 -# -# -# ------------------------------------------------------------------------------ - 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 diff --git a/.github/workflows/BuildOnly.yml b/.github/workflows/BuildOnly.yml index 2270fdb..ab533e1 100644 --- a/.github/workflows/BuildOnly.yml +++ b/.github/workflows/BuildOnly.yml @@ -1,19 +1,3 @@ -# ------------------------------------------------------------------------------ -# -# -# 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 -# -# -# ------------------------------------------------------------------------------ - name: BuildOnly on: @@ -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 @@ -68,7 +45,6 @@ jobs: working-directory: 'src' run: | dotnet test --solution Extensions.Hosting.slnx \ - --no-build \ --configuration Release \ --coverage \ --coverage-output-format cobertura \ diff --git a/Directory.Packages.props b/Directory.Packages.props index 8d0b503..511f665 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -23,7 +23,7 @@ - + diff --git a/build/Build.cs b/build/Build.cs index e52c4ea..faf60a8 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -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; @@ -32,7 +32,6 @@ 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; @@ -40,7 +39,7 @@ sealed partial class Build : NukeBuild AbsolutePath PackagesDirectory => RootDirectory / "output"; Target Print => _ => _ - .Executes(() => Log.Information("NerdbankVersioning = {Value}", NerdbankVersioning.NuGetPackageVersion)); + .Executes(() => Log.Information("MinVerVersionOverride = {Value}", Environment.GetEnvironmentVariable("MinVerVersionOverride") ?? "")); Target Clean => _ => _ .Before(Restore) @@ -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))); diff --git a/build/_build.csproj b/build/_build.csproj index 0f27490..20030eb 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -13,12 +13,7 @@ - - - - - diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 6f90fd7..d33a270 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -40,6 +40,16 @@ true + + + minor + alpha.0 + v + 3.2 + + true false @@ -72,6 +82,7 @@ + diff --git a/src/Extensions.Hosting.slnx b/src/Extensions.Hosting.slnx index 4a989a3..532784a 100644 --- a/src/Extensions.Hosting.slnx +++ b/src/Extensions.Hosting.slnx @@ -10,6 +10,15 @@ + + + + + + + + + @@ -19,7 +28,6 @@ - @@ -31,19 +39,12 @@ - - - - - - - diff --git a/version.json b/version.json deleted file mode 100644 index 08313f7..0000000 --- a/version.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "3.1", - "publicReleaseRefSpec": [ - "^refs/heads/main$", - "^refs/heads/master$", - "^refs/heads/v\\d+(?:\\.\\d+)?$" - ], - - "nugetPackageVersion": { "semVer": 2 }, - - "cloudBuild": { - "setVersionVariables": true, - "buildNumber": { "enabled": false } - } -}