-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (84 loc) · 3.5 KB
/
main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 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
"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
}