Updated create_release.yml #98
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 | |
env: | |
ARTIFACT: SAM | |
PACKAGES: ${{ github.workspace }}\.nuget\packages | |
VERSION: 0.0.1-alpha | |
on: | |
workflow_call: | |
inputs: | |
is_release: | |
description: 'True if this build is for a release, false otherwise' | |
default: false | |
type: boolean | |
version: | |
description: 'The semantic version number (e.g. "2.0.1-beta")' | |
default: '0.0.1-alpha' | |
required: false | |
type: string | |
workflow_dispatch: | |
push: | |
branches: [ "main", "master" ] | |
tags-ignore: | |
- v* | |
paths-ignore: | |
- 'resources/*' | |
- 'README.md' | |
- 'CHANGELOG.md' | |
- '.gitignore' | |
- '.gitattributes' | |
pull_request: | |
branches: [ "main", "master" ] | |
concurrency: | |
group: ${{ github.workflow }} | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- id: cache-restore | |
uses: actions/cache/restore@v4 | |
with: | |
path: ${{ env.PACKAGES }} | |
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} | |
- name: Restore dependencies | |
run: dotnet restore .\src\SAM_NoTests.slnf --packages ${{ env.PACKAGES }} | |
- id: cache-save | |
uses: actions/cache/save@v4 | |
if: steps.cache-restore.outputs.cache-hit != 'true' | |
with: | |
path: ${{ env.PACKAGES }} | |
key: ${{ steps.cache-restore.outputs.cache-primary-key }} | |
- name: Publish SAM | |
run: dotnet publish .\src\SAM\SAM.csproj -o publish -c Release -a x86 --no-restore /p:Version=${{ inputs.version || env.VERSION }} | |
- name: Publish SAM.Manager | |
run: dotnet publish .\src\SAM.Manager\SAM.Manager.csproj -o publish_manager -c Release -a x86 --no-restore /p:Version=${{ inputs.version || env.VERSION }} | |
- name: Stage Artifacts | |
run: | | |
$samDir = Get-Item publish | Select-Object -ExpandProperty FullName | |
$samManagerDir = Get-Item publish_manager | Select-Object -ExpandProperty FullName | |
cp $samManagerDir\* -Destination $samDir -Recurse -Force | |
$stagedFiles = gci $samDir -Recurse -File | select -ExpandProperty FullName | Sort-Object | |
Write-Host "" | |
Write-Host "::group::Staged Artifacts" | |
foreach ($stagedFile in $stagedFiles) | |
{ | |
$relPath = [System.IO.Path]::GetRelativePath($samDir, $stagedFile) | |
$ext = [System.IO.Path]::GetExtension($stagedFile) | |
$color = '' | |
if ($ext -eq '.exe') { | |
$color = $PSStyle.Foreground.BrightCyan | |
} | |
elseif ($ext -eq '.dll') { | |
$color = $PSStyle.Foreground.BrightMagenta | |
} | |
elseif ($ext -eq '.pdb') { | |
$color = $PSStyle.Foreground.BrightGreen | |
} | |
elseif ($ext -eq '.json' -or $ext -eq '.config') { | |
$color = $PSStyle.Foreground.BrightBlue | |
} | |
Write-Host "- $color$relPath$($PSStyle.Reset)" | |
} | |
Write-Host "::endgroup::" | |
- name: Upload a Build Artifact | |
id: artifact-upload | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT }} | |
path: publish | |
if-no-files-found: error |