Skip to content

Add build.ps1 for multi-Roslyn build orchestration #49

Add build.ps1 for multi-Roslyn build orchestration

Add build.ps1 for multi-Roslyn build orchestration #49

Workflow file for this run

name: CI
on:
push:
branches-ignore:
- 'wip/**'
tags: [ 'v*' ]
paths-ignore:
- '*.md'
- '*.txt'
- '.git*'
pull_request:
branches-ignore:
- 'wip/**'
paths-ignore:
- '*.md'
- '*.txt'
- '.git*'
env:
CONFIGURATION: Release
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
build:
strategy:
matrix:
os: [windows-2022, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
dotnet-version: '8.0.x'
- name: Display .NET info
run: dotnet --info
- name: Restore tools
run: dotnet tool restore
- name: Build
run: dotnet pwsh ./build.ps1 -Build -Configuration ${{ env.CONFIGURATION }}
- name: Pack (Windows only)
if: runner.os == 'Windows'
shell: pwsh
run: |
$commitTimestamp = git log -1 --format=%cI
if ($LASTEXITCODE) { throw "Failed to get commit timestamp" }
$versionSuffix = ([datetimeoffset]$commitTimestamp).ToUniversalTime().ToString('yyyyMMdd''t''HHmm')
$releaseNotesFile = [System.IO.Path]::GetTempFileName()
$tag = '${{ github.ref_name }}'
$isTag = '${{ github.ref_type }}' -eq 'tag'
# if the tag starts with "v", as in "v1.0.0", assume it's a release
if ($isTag -and $tag -clike 'v*') {
$url = '${{ github.server_url }}/${{ github.repository }}'
Add-Content $releaseNotesFile -Encoding UTF8 "See: ${url}/releases/tag/$tag"
Add-Content $releaseNotesFile -Encoding UTF8 ''
# if tag ends in "-" followed by dot-separated identifiers...
if ($tag -match '(?<=-)[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$') {
$versionSuffix = $matches[0] # ...then use as suffix for pre-release
} else {
$versionSuffix = $null # ... else use no suffix for a release
}
}
Add-Content $releaseNotesFile -Encoding UTF8 "Commit @ ${{ github.sha }}"
$packParams = @{
Configuration = '${{ env.CONFIGURATION }}'
PackageReleaseNotesFile = $releaseNotesFile
}
if ($versionSuffix) {
$packParams.VersionSuffix = $versionSuffix
}
& ./build.ps1 -Pack @packParams
if ($LASTEXITCODE) { throw "Pack failed" }
Get-ChildItem -File -Filter docopt.net.*.nupkg dist |
Select-Object -ExpandProperty FullName |
ForEach-Object { dotnet sourcelink test $_; if ($LASTEXITCODE) { throw "SourceLink test failed for $_" } }
- name: Test
run: dotnet test --no-build --configuration ${{ env.CONFIGURATION }}
- name: Integration Tests (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: ./tests/Integration/run.ps1 -NoPack
- name: Integration Tests (Linux)
if: runner.os == 'Linux'
shell: pwsh
run: ./tests/Integration/run.ps1
- name: Upload NuGet packages
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: NuGet
path: dist/*.nupkg