Skip to content

Package for release #14

Package for release

Package for release #14

Workflow file for this run

# Plan and package for release
# On PRs, only the plan step is executed to output the version manifest.
name: Package for release
on:
workflow_dispatch: # For testing purposes
release:
types:
- released
pull_request:
branches:
- main
jobs:
plan:
name: Calculate package versions
runs-on: ubuntu-latest
outputs:
versionManifest: ${{ steps.versionManifest.outputs.versionManifest }}
steps:
- uses: actions/checkout@v4
name: Checkout
with:
fetch-depth: 1
- name: Get version manifest
shell: pwsh
id: versionManifest
run: |
Import-Module -Force .\Build-Functions.psm1
Write-Output "::debug::Generating package versions"
$versionManifest = Get-Versions
"versionManifest='$($versionManifest | ConvertTo-Json)'" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
$summary = "### Version manifest `r`n" + '```json' + "`r`n" + $versionManifest + "`r`n" + '````'
$summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
build-release:
needs:
- plan
if: ${{ fromJson(needs.plan.outputs.versionManifest) != null && (github.event_name == 'release' || github.event_name == 'workflow_dispatch') }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [win, linux]
environment: release
name: Build for ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
name: Checkout
- name: Summarize
shell: pwsh
run: |
Import-Module -Force .\Build-Functions.psm1
"## Build environment summary" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"Package lock file locations:`r`n" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
Get-LockFiles | ForEach-Object { "`t- $_`r`n" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append }
"`r`n" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"Working directory: `$(pwd)`" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
- uses: actions/setup-dotnet@v4
name: Setup dotnet cli
with:
global-json-file: global.json
cache: true
cache-dependency-path: src/*/packages.lock.json
- name: Restore (locked)
shell: pwsh
run: dotnet restore --locked-mode
- name: Build
shell: pwsh
env:
VERSION_MANIFEST: ${{ needs.plan.outputs.versionManifest }}
run: |
Write-Output "::debug::Encoded version manifest: $env:VERSION_MANIFEST"
$versionManifest = $env:VERSION_MANIFEST | ConvertFrom-Json
Write-Output "::debug::Decoded version manifest: $versionManifest"
$versionManifest = $versionManifest | ConvertFrom-Json -AsHashTable
foreach ($app in $versionManifest.GetEnumerator()) {
$packageVersion = $app.Value.SemVer
Write-Output "::debug::Building package " + $app.Key + " with version " + $packageVersion
"Build output for package ${app.Key} with version ${packageVersion}:`r`n" + '```' | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
dotnet build --no-restore $app.Value.Root -c Release --os ${{ matrix.os }} --no-self-contained `
-p:PackageRequireLicenseAcceptance=true `
-p:PackageLicenseFile=LICENSE `
-p:Version=$packageVersion `
-p:PackageProjectUrl=$env:REPO_URL `
-p:RepositoryUrl=$env:REPO_URL `
| Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
'```' | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
}