Skip to content

Commit

Permalink
WIP build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
kekonn committed Mar 19, 2024
1 parent 8706cb4 commit 614e3f4
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Package for release

on:
release:
types:
- released
pull_request:
types:
- ready_for_review

jobs:
plan:
name: Calculate package versions
runs-on: ubuntu-latest
outputs:
versionManifest: ${{ steps.versionManifest.outputs.versionManifest }}
steps:
- uses: actions/checkout@v4
name: Checkout
- uses: actions/cache@v4
- name: Get version manifest
shell: pwsh
id: versionManifest
run: |
Import-Module -Force .\Get-Versions.psm1
Write-Output "::debug::Generating package versions"
$versionManifest = Get-Versions
"versionManifest=$versionManifest" | 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' }}
name: Build for (${{ matrix.os }})
runs-on: ubuntu-latest
strategy:
matrix:
os: [windows, ubuntu]
environment: release
steps:
- uses: actions/checkout@v4
name: Checkout
- uses: actions/setup-dotnet@v4
name: Setup dotnet cli
with:
global-json-file: global.json
cache: true
- name: Build and restore
shell: pwsh


21 changes: 21 additions & 0 deletions Get-Versions.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function Get-Versions {
$versionFiles = Get-Item -Path src/**/version.yaml | Select-Object -ExpandProperty FullName
Write-Debug "Found the following version files:"
$versionFiles | ForEach-Object { $_ | Write-Debug }

$packageVersions = @{}
$versionFiles | ForEach-Object {
Write-Debug "Reading version file $_"
$packageName = Split-Path $_ -Parent | Split-Path -Leaf
$yamlVersion = (Get-Content $_ | ConvertFrom-Yaml).version
$semver = '{0}.{1}.{2}' -f $yamlVersion.major, $yamlVersion.minor, $yamlVersion.patch
$assemblyVersion = $semver + ".0"

$packageVersions[$packageName] = @{ 'SemVer' = $semver; 'AssemblyVersion' = $assemblyVersion; 'Root' = $(Split-Path $_ -Parent)}
}

$packageVersions | ConvertTo-Json | Write-Output
}

Install-Module -Name powershell-yaml -Force -AcceptLicense
Export-ModuleMember -Function Get-Versions

0 comments on commit 614e3f4

Please sign in to comment.