Skip to content

Commit

Permalink
Merge pull request #37 from FH-Inway/build-action
Browse files Browse the repository at this point in the history
👷 add build action
  • Loading branch information
milnet92 authored Sep 15, 2024
2 parents 555d846 + eaf95a3 commit fd0cf23
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .FSC-PS/environments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"name":"Dummy",
"settings":{
"buildVersion": "10.0.39",
"sourceBranch": "main",
"lcsEnvironmentId": "12345678-1234-1234-1234-123456789012",
"azVmname" : "Dummy",
"azVmrg" : "Dummy",
"cron":"0 0 31 2 *"
}
}
]
8 changes: 8 additions & 0 deletions .FSC-PS/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type":"FSCM",
"packageName": "MXTXppInterpreter",
"buildVersion": "10.0.39",
"ciBranches": "main,release",
"useLocalNuGetStorage":true,
"deploymentScheduler":false
}
5 changes: 5 additions & 0 deletions .github/BUILD.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"deploy": false,
"generatePackages": true,
"uploadPackageToLCS": false
}
6 changes: 6 additions & 0 deletions .github/FSC-PS-Settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"templateUrl": "https://github.com/fscpscollaborative/fscps",
"templateBranch": "main",
"runs-on": "windows-latest",
"metadataPath": "Metadata"
}
169 changes: 169 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
on:
pull_request:
workflow_dispatch:
inputs:
version:
description: 'Select FSCM Version. Use wildcard * to let settings .json files decide.'
required: false
default: '10.0.39'

includeTestModels:
type: boolean
default: false
description: Include test models

permissions:
contents: read

defaults:
run:
shell: pwsh

env:
FORCE_COLOR: 3

jobs:
Initialization:
runs-on: [ windows-latest ]
outputs:
type: ${{ steps.ReadSettings.outputs.type }}
source_branch: ${{ steps.ReadSettings.outputs.source_branch }}
versions: ${{ steps.ReadSettings.outputs.VersionsJson }}
environments: ${{ steps.ReadSettings.outputs.EnvironmentsJson }}
githubRunner: ${{ steps.ReadSettings.outputs.GitHubRunnerJson }}
steps:
- name: Support longpaths
run: git config --system core.longpaths true

- name: Checkout
uses: actions/checkout@v4.1.1

- name: Initialize the workflow
uses: fscpscollaborative/fscps.gh/WorkflowInitialize@v2.1
id: init
env:
secrets: ${{ toJson(secrets) }}

- name: Read settings
id: ReadSettings
uses: fscpscollaborative/fscps.gh/ReadSettings@v2.1
with:
version: ${{ inputs.version }}

BuildDotNet:
needs: [ Initialization ]
runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }}
strategy:
matrix:
version: ${{ fromJson(needs.Initialization.outputs.versions) }}
fail-fast: false
name: Build .NET ${{ matrix.version }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Setup NuGet
uses: nuget/setup-nuget@v2

- name: Restore NuGet packages
run: nuget restore Projects/XppInterpreter/XppInterpreter.csproj -PackagesDirectory Projects/XppInterpreter/packages

- name: Build
run: msbuild Projects/XppInterpreter/XppInterpreter.csproj /p:VersionSuffix=pr /p:Configuration=Release /p:Version=0.0.0.${{ github.event.pull_request.number }} /p:InformationalVersion=0.0.0.${{ github.event.pull_request.number }}-pr -fileLogger

- name: Upload XppInterpreter
uses: actions/upload-artifact@v4
with:
name: XppInterpreter
path: Projects/XppInterpreter/bin/Release

Build:
needs: [ Initialization, BuildDotNet ]
runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }}
strategy:
matrix:
version: ${{ fromJson(needs.Initialization.outputs.versions) }}
fail-fast: false
name: Build ${{ matrix.version }}
steps:
- name: Checkout
uses: actions/checkout@v4.1.1

- name: Download XppInterpreter
uses: actions/download-artifact@v4
with:
name: XppInterpreter
path: Metadata/MXppTools/bin

- name: Read settings
uses: fscpscollaborative/fscps.gh/ReadSettings@v2.1
with:
version: ${{ matrix.version }}

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2

- name: Setup NuGet
uses: nuget/setup-nuget@v2
with:
nuget-version: 5.10.x

- name: Run pipeline
uses: fscpscollaborative/fscps.gh/RunPipeline@v2.1
id: runpipeline
with:
type: ${{ needs.Initialization.outputs.type}}
version: ${{ matrix.version }}
settingsJson: ${{ env.Settings }}
secretsJson: ${{ env.RepoSecrets }}

- name: Publish artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ env.PACKAGE_NAME }}
path: ${{ env.ARTIFACTS_PATH }}/*.zip

- name: Add logs to job summary
run: |
$logFiles = Get-ChildItem -Path "${{ env.ARTIFACTS_PATH }}\Logs" -Recurse -Filter *.log
$summary = "# Logs `n`n"
if ($logFiles) {
foreach ($logFile in $logFiles) {
$content = Get-Content -Path $logFile
$summary += "## $logFile `n"
foreach ($line in $content) {
# if the line consists only of = or - characters
# (which would be interpreted as a setext heading
# (https://github.github.com/gfm/#setext-headings)),
# add a new line before it
if ($line -match "^[=-]+$") {
$summary += "`n$line`n"
} else {
$summary += $line + "`n"
}
}
}
}
$summary >> $env:GITHUB_STEP_SUMMARY
PostProcess:
if: ${{ !cancelled() }}
runs-on: ${{ fromJson(needs.Initialization.outputs.githubRunner) }}
needs: [ Initialization, Build ]
steps:
- name: Checkout
uses: actions/checkout@v4.1.1

- name: Read settings
uses: fscpscollaborative/fscps.gh/ReadSettings@v2.1

- name: Finalize the workflow
id: PostProcess
uses: fscpscollaborative/fscps.gh/WorkflowPostProcess@v2.1
with:
remove_current: ${{ needs.Initialization.outputs.environments == '' }}
settingsJson: ${{ env.Settings }}
secretsJson: ${{ env.RepoSecrets }}
Binary file removed Metadata/MXppTools/bin/Z.Expressions.Eval.dll
Binary file not shown.
1 change: 0 additions & 1 deletion Projects/XppInterpreter/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Z.Expressions.Eval" version="6.1.10" targetFramework="net472" />
</packages>
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ For development environments no additional security is needed, but if you run th
* **Macros** usage and declarations are not supported
* **Class declarations** are not supported
* **.NET namespaces** cannot be referenced

# Build Action
The GitHub build action is based on [FSC-PS for GitHub](https://github.com/fscpscollaborative/fscps).

# Build Status
[![(BUILD)](../../actions/workflows/build.yml/badge.svg)](../../actions/workflows/build.yml)

0 comments on commit fd0cf23

Please sign in to comment.