Skip to content
Merged
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
48 changes: 48 additions & 0 deletions .github/actions/purview-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Purview Build

description: >-
Installs the pinned Purview.Build dotnet tool from the Purview-Dev GitHub Packages feed and runs
it against the repository. Configuration flows through job environment variables (Build__*,
Release__*, NuGet__*, PublishLocalNuGet__*) and secrets (NUGET_APIKEY, GITHUB_TOKEN,
LOCAL_NUGET_FEED_PATH).

inputs:
build-version:
description: Exact Purview.Build package version to run.
required: true
dotnet-version:
description: .NET SDK used by the consuming repository.
required: false
default: 10.0.x

runs:
using: composite
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ inputs.dotnet-version }}

- name: Authenticate to Purview-Dev packages
shell: bash
run: >-
dotnet nuget add source
"https://nuget.pkg.github.com/purview-dev/index.json"
--name purview-dev
--username "${{ github.actor }}"
--password "${{ github.token }}"
--store-password-in-clear-text

- name: Install pinned shared build
shell: bash
run: >-
dotnet tool install Purview.Build
--tool-path "${{ runner.temp }}/purview-build"
--source "https://nuget.pkg.github.com/purview-dev/index.json"
--version "${{ inputs.build-version }}"

- name: Run shared build
shell: bash
run: "${{ runner.temp }}/purview-build/purview-build"
env:
GITHUB_TOKEN: ${{ github.token }}
34 changes: 21 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@ jobs:
run: dotnet restore src/Purview.Build/Purview.Build.csproj --locked-mode
- name: Build gate
run: dotnet build src/Purview.Build/Purview.Build.csproj --configuration Release --no-restore --warnaserror
- name: Pack gate
run: dotnet pack src/Purview.Build/Purview.Build.csproj --configuration Release --no-build --output artifacts
- name: Install packed tool
- name: Read version
id: version
shell: bash
run: |
VERSION=$(dotnet msbuild src/Purview.Build/Purview.Build.csproj -getProperty:Version -nologo)
dotnet tool install Purview.Build --tool-path "$RUNNER_TEMP/purview-build" --add-source artifacts --version "$VERSION"
echo "$RUNNER_TEMP/purview-build" >> "$GITHUB_PATH"
- name: Installed-tool smoke gate
VERSION=$(node -p "require('./package.json').version")
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]]; then
echo "package.json version '$VERSION' is not SemVer." >&2
exit 1
fi
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Pack tool
run: >-
purview-build
--Build:Solution=src/Purview.Build/Purview.Build.csproj
--Build:VersionFile=testassets/version.json
--Build:Lint=false
--Build:Test=false
--Build:Pack=false
dotnet pack src/Purview.Build/Purview.Build.csproj
--configuration Release --no-build --output artifacts
-p:Version=${{ steps.version.outputs.version }}
-p:PackageVersion=${{ steps.version.outputs.version }}
- name: Install packed tool
shell: bash
run: |
dotnet tool install Purview.Build --tool-path "$RUNNER_TEMP/purview-build" --add-source artifacts --version "${{ steps.version.outputs.version }}"
- name: Dogfood — the project builds itself
env:
GITHUB_TOKEN: ${{ github.token }}
run: "$RUNNER_TEMP/purview-build/purview-build"
62 changes: 54 additions & 8 deletions .github/workflows/purview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,60 @@ on:
workflow_call:
inputs:
build-version:
description: Exact Purview.Build package version to run
description: Exact Purview.Build package version to run.
required: true
type: string
dotnet-version:
description: .NET SDK used by the consuming repository
description: .NET SDK used by the consuming repository.
required: false
default: 10.0.x
type: string
release-mode:
description: Release__Mode passed to the pipeline (None, NuGet, GitHubRelease, LocalNuGet).
required: false
default: None
type: string
run-tests:
description: Enable discovered tests (Build__RunTests).
required: false
default: true
type: boolean
run-lint:
description: Enable CSharpier linting (Build__RunLint).
required: false
default: true
type: boolean
run-pack:
description: Enable packing (Build__RunPack).
required: false
default: true
type: boolean
validate-pack:
description: Enable pack validation (Build__ValidatePack).
required: false
default: true
type: boolean
test-filter:
description: Test filter (Build__TestFilter), e.g. "/*/*/*/*[Category=Unit]".
required: false
type: string
test-projects:
description: Comma-separated test project names/globs to run (Build__TestProjects).
required: false
type: string
secrets:
NUGET_API_KEY:
NUGET_APIKEY:
required: false

permissions:
contents: write
packages: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
with:
Expand Down Expand Up @@ -51,5 +87,15 @@ jobs:
- name: Run shared build
env:
GITHUB_TOKEN: ${{ github.token }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: "${{ runner.temp }}/purview-build/purview-build"
# Consumer repos historically store the key under NUGET__APIKEY; some use NUGET_APIKEY.
# The tool reads the plain process env vars NUGET_APIKEY / NUGET_API_KEY.
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
NUGET_API_KEY: ${{ secrets.NUGET__APIKEY }}
Release__Mode: ${{ inputs.release-mode }}
Build__RunTests: ${{ inputs.run-tests }}
Build__RunLint: ${{ inputs.run-lint }}
Build__RunPack: ${{ inputs.run-pack }}
Build__ValidatePack: ${{ inputs.validate-pack }}
Build__TestFilter: ${{ inputs.test-filter }}
Build__TestProjects: ${{ inputs.test-projects }}
run: "${{ runner.temp }}/purview-build/purview-build"
137 changes: 137 additions & 0 deletions .github/workflows/purview-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Purview Release

on:
workflow_call:
inputs:
build-version:
description: Exact Purview.Build package version to run.
required: true
type: string
dotnet-version:
description: .NET SDK used by the consuming repository.
required: false
default: 10.0.x
type: string
release-mode:
description: Release__Mode passed to the pipeline (NuGet or GitHubRelease).
required: false
default: NuGet
type: string
release-branch:
description: >-
Branch that triggers this release (main or release). Used only for the concurrency group.
required: false
default: main
type: string
trusted-publishing:
description: Use NuGet Trusted Publishing (no API key) instead of an API key.
required: false
default: false
type: boolean
run-tests:
description: Enable discovered tests (Build__RunTests).
required: false
default: true
type: boolean
run-lint:
description: Enable CSharpier linting (Build__RunLint).
required: false
default: true
type: boolean
run-pack:
description: Enable packing (Build__RunPack).
required: false
default: true
type: boolean
validate-pack:
description: Enable pack validation (Build__ValidatePack).
required: false
default: true
type: boolean
test-filter:
description: Test filter (Build__TestFilter), e.g. "/*/*/*/*[Category=Unit]".
required: false
type: string
upload-artifacts:
description: Upload artifacts folder files as GitHub release assets (Release__UploadArtifacts).
required: false
default: false
type: boolean
secrets:
NUGET_APIKEY:
required: false

permissions:
contents: write
packages: read

concurrency:
group: purview-release-${{ inputs.release-branch }}
cancel-in-progress: false

jobs:
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
fetch-tags: true

- uses: actions/setup-dotnet@v6
with:
dotnet-version: ${{ inputs.dotnet-version }}

- name: Check for version bump
id: version
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
TAG="v$VERSION"
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "Version $VERSION is already tagged as $TAG. Skipping release."
echo "should_release=false" >> "$GITHUB_OUTPUT"
else
echo "New version $VERSION detected. Releasing $TAG."
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
fi

- name: Authenticate to Purview-Dev packages
if: steps.version.outputs.should_release == 'true'
run: >-
dotnet nuget add source
"https://nuget.pkg.github.com/purview-dev/index.json"
--name purview-dev
--username "${{ github.actor }}"
--password "${{ github.token }}"
--store-password-in-clear-text

- name: Install pinned shared build
if: steps.version.outputs.should_release == 'true'
run: >-
dotnet tool install Purview.Build
--tool-path "${{ runner.temp }}/purview-build"
--source "https://nuget.pkg.github.com/purview-dev/index.json"
--version "${{ inputs.build-version }}"

- name: Run release pipeline
if: steps.version.outputs.should_release == 'true'
env:
GITHUB_TOKEN: ${{ github.token }}
# Consumer repos historically store the key under NUGET__APIKEY; some use NUGET_APIKEY.
# The tool reads the plain process env vars NUGET_APIKEY / NUGET_API_KEY.
NUGET_APIKEY: ${{ secrets.NUGET_APIKEY }}
NUGET_API_KEY: ${{ secrets.NUGET__APIKEY }}
Release__Mode: ${{ inputs.release-mode }}
Release__UploadArtifacts: ${{ inputs.upload-artifacts }}
NuGet__TrustedPublishing: ${{ inputs.trusted-publishing }}
Build__RunTests: ${{ inputs.run-tests }}
Build__RunLint: ${{ inputs.run-lint }}
Build__RunPack: ${{ inputs.run-pack }}
Build__ValidatePack: ${{ inputs.validate-pack }}
Build__TestFilter: ${{ inputs.test-filter }}
run: "${{ runner.temp }}/purview-build/purview-build"
Loading