Skip to content

Package for release #23

Package for release

Package for release #23

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
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 | Out-File -FilePath versionManifest.json
$summary = "### Version manifest `r`n" + '```json' + "`r`n" + $versionManifest + "`r`n" + '````'
$summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
- uses: actions/upload-artifact@v4
name: Upload versionManifest.json
with:
name: artifacts-plan-version-manifest
path: versionManifest.json
build-release:
needs:
- plan
if: ${{ (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
- uses: actions/download-artifact@v4
name: Download version manifest
id: download
with:
name: artifacts-plan-version-manifest
path: version-manifest
- 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 { "- $_`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
"Version manifest directory: ``${{ steps.download.outputs.download-path }}```r`n" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
"Directory contents:`r`n" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
ls "${{ steps.download.outputs.download-path }}" | ForEach-Object { "- $_" | 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
run: |
$versionManifest = Get-Content -Path "${{ steps.download.outputs.download-path }}/versionManifest.json" | ConvertFrom-Json -AsHashTable
Write-Output "::debug::Decoded version manifest: $versionManifest"
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
}