Skip to content

Commit

Permalink
Add build CI workflow with package artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Jul 30, 2024
1 parent a38c23f commit 259cd20
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
ContinuousIntegrationBuild: true
CiRunNumber: ${{ github.run_number }}
CiRunPushSuffix: ${{ github.ref_name }}-ci${{ github.run_number }}
CiRunPullSuffix: pull-${{ github.event.number }}-ci${{ github.run_number }}
jobs:
build:
strategy:
fail-fast: false
matrix:
configuration: [debug, release]
os: [ubuntu-latest, windows-latest]
include:
- os: windows-latest
configuration: release
collect-packages: true
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --no-restore --configuration ${{ matrix.configuration }}

- name: Pack
id: pack
if: matrix.collect-packages
env:
CiBuildVersionSuffix: ${{ github.event_name == 'push' && env.CiRunPushSuffix || env.CiRunPullSuffix }}
run: dotnet pack --no-build --configuration ${{ matrix.configuration }}

- name: Collect packages
uses: actions/upload-artifact@v4
if: matrix.collect-packages && steps.pack.outcome == 'success' && always()
with:
name: Packages
if-no-files-found: error
path: artifacts/package/${{matrix.configuration}}/**
2 changes: 2 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<Features>strict</Features>
</PropertyGroup>

<Import Project="build/Version.props" />

<ItemGroup>
<Content Include="..\LICENSE" PackagePath="/" />
<Content Include="..\icon.png" PackagePath="/" />
Expand Down
20 changes: 20 additions & 0 deletions build/Version.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>
<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' != 'true'">
<!-- When making local builds DevVersion can be overridden to generate multiple local versions -->
<DevVersion Condition="'$(DevVersion)' == ''">0</DevVersion>

<VersionSuffix>dev$(DevVersion)</VersionSuffix>
<_FileVersionRevision>$([MSBuild]::Add(60000, $(DevVersion)))</_FileVersionRevision>
</PropertyGroup>

<PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
<VersionSuffix>$(CiBuildVersionSuffix)</VersionSuffix>
<_FileVersionRevision>0</_FileVersionRevision>
<_FileVersionRevision Condition="'$(CiBuildVersionSuffix)' != '' and '$(CiRunNumber)' != ''">$(CiRunNumber)</_FileVersionRevision>
</PropertyGroup>

<PropertyGroup>
<!-- Force malformed versions to be an error -->
<WarningsAsErrors>$(WarningsAsErrors);CS7035</WarningsAsErrors>
</PropertyGroup>
</Project>

0 comments on commit 259cd20

Please sign in to comment.