Skip to content

CI

CI #107

Workflow file for this run

name: CI
permissions:
contents:
write
pull-requests:
write
pages:
write
id-token:
write
on:
push:
branches: [ main ]
paths:
- .github/workflows/*
- src/**/*
- tests/**/*
pull_request:
branches: [ main ]
types:
- opened
- synchronize
workflow_dispatch:
inputs:
versionPrefix:
type: string
description: e.g 1.1.1
default: ""
versionSuffix:
type: string
description: e.g alpha.1
default: "alpha"
publish:
type: boolean
description: run dotnet publish?
default: true
removePrereleases:
type: boolean
description: nuget unlist preleases?
default: false
configuration:
description: build configuration
required: false
default: Release
type: choice
options:
- Debug
- Release
verbosity:
description: build log verbosity
required: false
default: minimal
type: choice
options:
- quiet
- minimal
- normal
- detailed
- diagnostic
jobs:
parameters:
runs-on: ubuntu-latest
outputs:
versionSuffix: ${{ steps.parameters.outputs.versionSuffix }}
versionPrefix: ${{ steps.parameters.outputs.versionPrefix }}
configuration: ${{ steps.parameters.outputs.configuration }}
verbosity: ${{ steps.parameters.outputs.verbosity }}
publish: ${{ steps.parameters.outputs.publish }}
package: ${{ steps.parameters.outputs.package }}
publishSymbols: ${{ steps.parameters.outputs.publishSymbols }}
removePrereleases: ${{ steps.parameters.outputs.removePrereleases }}
runTests: ${{ steps.parameters.outputs.runTests }}
runCoverage: ${{ steps.parameters.outputs.runCoverage }}
steps:
- name: nuget secret verification
env:
NUGET: ${{ secrets.NUGET }}
if: "${{ env.NUGET == '' }}"
uses: actions/github-script@v3
with:
script: |
core.setFailed('"nuget" secret is missing')
- name: Setting up parameters
id: parameters
shell: pwsh
run: |
Write-Host "Setting up parameters"
$branch = "main"
$conf = "${{github.event.inputs.configuration}}"
$verb = "${{github.event.inputs.verbosity}}"
$publ = "${{github.event.inputs.publish}}"
$removePrereleases = "${{github.event.inputs.removePrereleases}}"
$prefix = "${{github.event.inputs.versionPrefix}}"
$suffix = "${{github.event.inputs.versionSuffix}}"
$bnr = "${{github.run_number}}"
Write-Host "baseRef: ${{github.base_ref}}"
Write-Host "event_name: ${{github.event_name}}"
Write-Host "action: ${{github.event.action}}"
Write-Host "pull_request.merged: ${{github.event.pull_request.merged}}"
$commitMode = "noop"
if($commitMode -eq "noop" && "${{github.event_name}}" -eq "workflow_dispatch") {
$commitMode = "dispatch" }
if($commitMode -eq "noop" && "$branch|pull_request|closed|true" -eq "${{github.base_ref}}|${{github.event_name}}|${{github.event.action}}|${{github.event.pull_request.merged}}") {
$commitMode = "pushMerge" }
if($commitMode -eq "noop" && "$branch|push" -eq "${{github.base_ref}}|${{github.event_name}}") {
$commitMode = "push" }
$data = @{ #prefix #suffix #configuration #verbosity #publish #removeprerelease
"dispatch" = @("$prefix", "$suffix", "$conf", "$verb", "$publ", "$removePrereleases")
"push" = @("", "alpha.$bnr", "Release", "n", "true", "false")
"pushMerge" = @("", "beta.$bnr", "Release", "n", "true", "false")
"noop" = @("", "noop", "Release", "n", "false", "false")
};
$names = @("versionPrefix","versionSuffix","configuration","verbosity","publish","removePrereleases")
if($data[$commitMode] -eq $null){
Write-Host "Unidentified commit mode $commitMode"
echo "Commit mode could not be identified." >> $env:GITHUB_STEP_SUMMARY
exit 1;
}
$names += "package";
$names += "publishSymbols";
$names += "runTests";
$names += "runCoverage";
$data[$commitMode] += $data[$commitMode][4]
$data[$commitMode] += $data[$commitMode][4]
$data[$commitMode] += $data[$commitMode][4]
$data[$commitMode] += $data[$commitMode][4]
foreach($item in $names){
$index = $names.IndexOf($item)
Write-Host "$item=$($data[$commitMode][$index])"
echo "$item=$($data[$commitMode][$index])" >> $env:GITHUB_OUTPUT
echo "$item=$($data[$commitMode][$index])" >> $env:GITHUB_STEP_SUMMARY
}
package:
needs: parameters
uses: taori/actions/.github/workflows/nupkg.yml@v9
with:
solutionPath: src/Amusoft.DotnetNew.Tests.sln
packProjects: src/Amusoft.DotnetNew.Tests/Amusoft.DotnetNew.Tests.csproj
versionSuffix: ${{ needs.parameters.outputs.versionSuffix }}
versionPrefix: ${{ needs.parameters.outputs.versionPrefix }}
package: ${{ needs.parameters.outputs.package == 'true' }}
publish: ${{ needs.parameters.outputs.publish == 'true' }}
publishSymbols: ${{ needs.parameters.outputs.publishSymbols == 'true' }}
removePrereleases: ${{ needs.parameters.outputs.removePrereleases == 'true' }}
skipTests: ${{ needs.parameters.outputs.runTests == 'false' }}
configuration: ${{ needs.parameters.outputs.configuration }}
verbosity: ${{ needs.parameters.outputs.verbosity }}
runCoverage: ${{ needs.parameters.outputs.runCoverage == 'true' }}
testArguments: "--filter Category!=SkipInCI"
concurrencyAbortable: true
coverageThreshold: '85 95'
dotnetVersion: 6.0.x
secrets:
nuget: ${{ secrets.NUGET }}