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
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
name: LagoVista.Core Package Canary
name: Go Compile Yourself

on:
pull_request:
branches:
- master
push:
branches:
- 'feature/**'
pull_request:
branches:
- master
workflow_dispatch:
inputs:
publish:
description: Publish LagoVista.Core to GitHub Packages
required: true
type: boolean
default: false
version:
description: LagoVista.Core semantic version
description: Package version to build
required: true
type: string
default: 5.0.0
publish:
description: Publish the package to the shared GitHub Packages feed
required: true
type: boolean
default: false

permissions:
contents: read

jobs:
build-pack:
build-package:
runs-on: windows-latest
timeout-minutes: 30

env:
PACKAGE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version || '5.0.0' }}
PACKAGE_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version || format('5.0.0-feature.{0}', github.run_number) }}
PACKAGE_SOURCE: https://nuget.pkg.github.com/nuviot/index.json
NUGET_GITHUB_TOKEN: ${{ secrets.NUGET_GITHUB_TOKEN }}

Expand All @@ -43,31 +43,33 @@
dotnet-version: 9.0.x

- name: Setup NuGet
uses: NuGet/setup-nuget@v2

Check failure on line 46 in .github/workflows/go-compile-yourself.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use full commit SHA hash for this dependency.

See more on https://sonarcloud.io/project/issues?id=LagoVista_Core&issues=AaBOzPvArqHCjlC5UK5Q&open=AaBOzPvArqHCjlC5UK5Q&pullRequest=13

- name: Add GitHub Packages source
- name: Configure shared package feed
if: ${{ env.NUGET_GITHUB_TOKEN != '' }}
shell: pwsh
run: |
dotnet nuget remove source github 2>$null
dotnet nuget remove source nuviot 2>$null
dotnet nuget add source "$env:PACKAGE_SOURCE" `
--name github `
--name nuviot `
--username "${{ github.actor }}" `
--password "$env:NUGET_GITHUB_TOKEN" `
--store-password-in-clear-text

- name: Build and pack LagoVista.Core
- name: Build and pack repository packages
shell: pwsh
run: ./Build-GitHubPackages.ps1 -Version $env:PACKAGE_VERSION

- name: Upload package artifact
- name: Upload package build
uses: actions/upload-artifact@v4
with:
name: LagoVista.Core-${{ env.PACKAGE_VERSION }}
path: artifacts/packages/LagoVista.Core.${{ env.PACKAGE_VERSION }}.nupkg
path: |
artifacts/packages/LagoVista.Core.${{ env.PACKAGE_VERSION }}.nupkg
artifacts/package-catalog.json
if-no-files-found: error

- name: Publish to GitHub Packages
- name: Publish package
if: ${{ github.event_name == 'workflow_dispatch' && inputs.publish }}
shell: pwsh
run: |
Expand All @@ -77,7 +79,7 @@

$package = "artifacts/packages/LagoVista.Core.$env:PACKAGE_VERSION.nupkg"
dotnet nuget push $package `
--source github `
--source nuviot `
--api-key "$env:NUGET_GITHUB_TOKEN" `
--skip-duplicate

Expand Down
35 changes: 33 additions & 2 deletions Build-GitHubPackages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ param(
[string]$Version = '5.0.0',

[Parameter(Mandatory = $false)]
[string]$OutputDirectory = './artifacts/packages'
[string]$OutputDirectory = './artifacts/packages',

[Parameter(Mandatory = $false)]
[string]$CatalogPath = './artifacts/package-catalog.json'
)

$ErrorActionPreference = 'Stop'
Expand All @@ -15,6 +18,7 @@ Set-Location $repoRoot
$projectPath = Join-Path $repoRoot 'src/LagoVista.Core/LagoVista.Core.csproj'
$nuspecPath = Join-Path $repoRoot 'src/LagoVista.Core/Package.nuspec'
$outputPath = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $OutputDirectory))
$catalogFullPath = [System.IO.Path]::GetFullPath((Join-Path $repoRoot $CatalogPath))

if (-not (Test-Path $projectPath)) { throw "Project not found: $projectPath" }
if (-not (Test-Path $nuspecPath)) { throw "NuSpec not found: $nuspecPath" }
Expand All @@ -23,6 +27,7 @@ if (Test-Path $outputPath) {
Remove-Item -Recurse -Force $outputPath
}
New-Item -ItemType Directory -Force -Path $outputPath | Out-Null
New-Item -ItemType Directory -Force -Path (Split-Path $catalogFullPath -Parent) | Out-Null

Write-Host "Building LagoVista.Core package $Version"
Write-Host "Output: $outputPath"
Expand All @@ -45,7 +50,7 @@ if ($internalDependencies.Count -gt 0) {
throw "LagoVista.Core canary must not have internal LagoVista dependencies. Found: $names"
}

# Stamp only the CI checkout. The committed NuSpec remains historical source metadata.
# Stamp only the build checkout. The committed NuSpec remains historical source metadata.
$metadata.version = $Version
$settings = New-Object System.Xml.XmlWriterSettings
$settings.Indent = $true
Expand Down Expand Up @@ -80,4 +85,30 @@ if (-not (Test-Path $packagePath)) {
throw "Expected package was not produced: $packagePath"
}

$sourceRepository = if ($env:GITHUB_REPOSITORY) { $env:GITHUB_REPOSITORY } else { 'LagoVista/Core' }
$sourceCommit = if ($env:GITHUB_SHA) { $env:GITHUB_SHA } else { (git rev-parse HEAD).Trim() }
$sourceRef = if ($env:GITHUB_REF_NAME) { $env:GITHUB_REF_NAME } else { (git branch --show-current).Trim() }

$catalog = [ordered]@{
schemaVersion = 1
generatedUtc = [DateTime]::UtcNow.ToString('o')
source = [ordered]@{
repository = $sourceRepository
commit = $sourceCommit
ref = $sourceRef
}
packages = @(
[ordered]@{
id = 'LagoVista.Core'
version = $Version
file = [System.IO.Path]::GetFileName($packagePath)
targetFrameworks = @('netstandard2.0')
internalDependencies = @()
}
)
}

$catalog | ConvertTo-Json -Depth 8 | Set-Content -Path $catalogFullPath -Encoding utf8

Write-Host "Created $packagePath"
Write-Host "Created $catalogFullPath"
Loading