Skip to content

Commit

Permalink
Creating initial debug build WF w/ helper action
Browse files Browse the repository at this point in the history
Making an initial debug build CI workflow, and a helper action for interfacing with MSBuild. Loosely based on WinNUT workflows.
  • Loading branch information
gbakeman committed Apr 28, 2024
1 parent 581ae47 commit 85a8e51
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/actions/msbuild-helper/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-reference
# Requires Windows Server runner

name: "MSBuild-Helper"
description: "Execute Visual Studio's MSBuild system on a Project or Solution with desired settings."

branding:
icon: "loader"
color: "green"

inputs:
directory:
description: "Full path where MSBuild should look for Project (or Solution) definition file, default to current working dir."
required: false
default: ""

build-config:
description: "Solution configuration to use when building."
required: true

# https://andrewlock.net/version-vs-versionsuffix-vs-packageversion-what-do-they-all-mean/#version
version:
description: "Version string to pass to MSBuild. Ex. 0.1.0, 1.2.3.5, 99.0.3-rc-preview-2-final"
required: false

verbosity:
description: "Modify the verbosity of MSBuild. Options: q[uiet], m[inimal], n[ormal] (default), d[etailed], and diag[nostic]."
required: false
default: "normal"

outputs:
buildOutputDir:
description: "Final directory of Project or Solution output(s)."
value: ${{ steps.vars.outputs.BUILD_OUTPUT_DIR }}

logFile:
description: "Location of the MSBuild log file."
value: "msbuild.log"

runs:
using: "composite"
steps:
# Need to define "global" variables for this script. See https://github.com/orgs/community/discussions/51280#discussioncomment-8726096
- name: Set variables
id: vars
shell: pwsh
run: |
echo "BUILD_OUTPUT_DIR=${{ runner.temp }}\msbuild-out" >> $env:GITHUB_OUTPUT
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Build Solution
id: build
shell: pwsh
run: >
msbuild ${{ inputs.directory }} -nologo -fileLogger -verbosity:${{ inputs.verbosity }}
-property:Configuration=${{ inputs.build-config }}
-property:Version=${{ inputs.version }}
-property:OutDir=${{ steps.vars.outputs.BUILD_OUTPUT_DIR }}
40 changes: 40 additions & 0 deletions .github/workflows/build-debug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: build-debug

on:
workflow_dispatch:

pull_request:
paths:
- "**.cs"
- "**.csproj"

jobs:
build-debug:
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Run MSBuild
id: msbuild
uses: ./.github/actions/msbuild-helper
with:
directory: "AGauge\\AGauge.csproj"
build-config: "Debug"
version: ${{ vars.VER_RELEASE }}.*

- name: Get AssemblyVersion generated by msbuild
id: getversion
uses: berglie/assembly-version/get@v1
with:
directory: ${{ steps.msbuild.outputs.buildOutputDir }}

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: AGauge-Debug-v${{ steps.getversion.outputs.version }}
path: |
${{ steps.msbuild.outputs.buildOutputDir }}
${{ steps.msbuild.outputs.logFile }}
if-no-files-found: error

0 comments on commit 85a8e51

Please sign in to comment.