Configure Renovate #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
env: | |
# Disable the .NET logo in the console output. | |
DOTNET_NOLOGO: true | |
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build. | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
# Disable sending .NET CLI telemetry to Microsoft. | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
BUILD_ARTIFACT_PATH: ${{github.workspace}}/build-artifacts | |
jobs: | |
version: | |
name: Identify build version | |
runs-on: ubuntu-latest | |
outputs: | |
BuildVersion: ${{steps.configureBuildVersion.outputs.BUILD_VERSION}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Fetch all Git tags | |
run: git fetch --prune --unshallow --tags | |
- name: Configure build version | |
id: configureBuildVersion | |
run: | | |
$githubRunId = $env:GITHUB_RUN_ID; | |
$prNumber = $env:PR_NUMBER; | |
$gitSourceVersion = git describe --tags --abbrev=7 --always 2>$1; | |
$gitSourceVersionSplit = [regex]::split($gitSourceVersion, "-(?=\d+-\w+)"); | |
$version = $(if($gitSourceVersionSplit.length -eq 1){"0.0.0"}else{$gitSourceVersionSplit[0]}); | |
$commitsSinceTag = '0'; | |
$commitHash = $gitSourceVersionSplit[0]; | |
if ($gitSourceVersionSplit.length -eq 2) { | |
$gitMetadata = $gitSourceVersionSplit[1].split("-"); | |
$commitsSinceTag = $gitMetadata[0]; | |
$commitHash = $gitMetadata[1]; | |
} | |
$buildMetadata = "$($commitHash)-$($githubRunId)"; | |
$customSuffix = $(if($prNumber -ne ''){"-PR$($prNumber)"}elseif($commitsSinceTag -ne '0'){"-dev"}); | |
echo "::set-output name=BUILD_VERSION::$($version)$($customSuffix)+$($buildMetadata)"; | |
shell: pwsh | |
env: | |
PR_NUMBER: ${{github.event.number}} | |
- name: Print build version | |
run: echo ${{steps.configureBuildVersion.outputs.BUILD_VERSION}} | |
build: | |
name: Build application | |
runs-on: ${{matrix.os}} | |
needs: version | |
env: | |
BUILD_VERSION: ${{needs.version.outputs.BuildVersion}} | |
strategy: | |
matrix: | |
runtimeIdentifier: [win-x64, linux-x64, linux-arm64] | |
include: | |
- runtimeIdentifier: win-x64 | |
os: windows-latest | |
- runtimeIdentifier: linux-x64 | |
os: ubuntu-latest | |
- runtimeIdentifier: linux-arm64 | |
os: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: dotnet --version && dotnet nuget list source && dotnet restore --verbosity normal | |
- name: Self-contained build | |
run: dotnet publish -c Release /p:Version=${{env.BUILD_VERSION}} --output ${{env.BUILD_ARTIFACT_PATH}} -r ${{matrix.runtimeIdentifier}} -p:PublishSingleFile=true --self-contained true | |
- name: Publish artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{matrix.runtimeIdentifier}} | |
path: ${{env.BUILD_ARTIFACT_PATH}} |