forked from gibbed/SteamAchievementManager
-
-
Notifications
You must be signed in to change notification settings - Fork 4
151 lines (135 loc) · 4.91 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Build
run-name: Build ${{ github.event_name == 'workflow_call' && inputs.version || github.ref_name }} by ${{ github.actor }}
env:
PACKAGES: ${{ github.workspace }}\.nuget\packages
VERSION: 0.0.1
# these are all set in the set-vars step
ARTIFACT_NAME: ''
BUILD_DATE: ''
BUILD_DATE_LONG: ''
BUILD_TYPE: ''
CONFIGURATION: ''
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'
required: false
type: string
outputs:
artifact-name:
description: 'The name of the build artifact'
value: ${{ jobs.build.outputs.artifact-name }}
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
outputs:
artifact-name: ${{ steps.set-vars.outputs.artifact-name }}
steps:
- name: Checkout
id: git-checkout
uses: actions/checkout@v4
- name: Setup .NET
id: setup-dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Cache Restore
id: cache-restore
uses: actions/cache/restore@v4
with:
path: ${{ env.PACKAGES }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
- name: Restore dependencies
id: dotnet-restore
run: dotnet restore .\src\SAM_NoTests.slnf --packages ${{ env.PACKAGES }}
- name: Cache Save
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: Set Vars
id: set-vars
run: |
$now = Get-Date
$longTs = $now.ToString('yyyy-MM-dd')
$ts = $now.ToString('yy.MM.dd')
$buildType = "${{ inputs.is_release && 'release' || 'debug' }}"
$artifactName = $buildType -eq 'release' ? "SAM_${{ inputs.version }}" : [string]::Format('SAM_{0}_{1}.{2}', $buildType, $ts, '${{ github.run_number }}')
$configuration = $buildType -eq 'release' ? 'Release' : 'Debug'
Write-Host "Build Date : " -NoNewLine
Write-Host "$($PSStyle.Foreground.BrightCyan)$longTs ($ts)$($PSStyle.Reset)"
Write-Host "Build Type : " -NoNewLine
Write-Host "$($PSStyle.Foreground.BrightCyan)$buildType$($PSStyle.Reset)"
Write-Host "Artifact Name : " -NoNewLine
Write-Host "$($PSStyle.Foreground.BrightCyan)$artifactName$($PSStyle.Reset)"
Write-Host "Configuration : " -NoNewLine
Write-Host "$($PSStyle.Foreground.BrightCyan)$configuration$($PSStyle.Reset)"
echo "BUILD_DATE=$ts" >> $env:GITHUB_ENV
echo "BUILD_DATE_LONG=$longTs" >> $env:GITHUB_ENV
echo "BUILD_TYPE=$buildType" >> $env:GITHUB_ENV
echo "CONFIGURATION=$configuration" >> $env:GITHUB_ENV
echo "ARTIFACT_NAME=$artifactName" >> $env:GITHUB_ENV
echo "artifact-name=$artifactName" >> $env:GITHUB_OUTPUT
- name: Publish SAM
id: dotnet-publish
run: dotnet publish .\src\SAM\SAM.csproj -o publish -c ${{ env.CONFIGURATION }} -a x86 --no-restore /p:Version=${{ inputs.version || env.VERSION }}
- name: Stage Artifacts
id: stage-artifacts
run: |
$publishDir = Get-Item publish | Select-Object -ExpandProperty FullName
$stagedFiles = gci $publishDir -Recurse -File | Sort-Object Extension, FullName | select -ExpandProperty FullName
Write-Host ""
Write-Host "$($PSStyle.Bold)Staged Artifacts$($PSStyle.BoldOff)"
Write-Host ""
foreach ($stagedFile in $stagedFiles)
{
$relPath = [System.IO.Path]::GetRelativePath($publishDir, $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
}
else {
$color = $PSStyle.Foreground.BrightWhite
}
Write-Host "- $color$relPath$($PSStyle.Reset)"
}
- name: Upload a Build Artifact
id: artifact-upload
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: publish
if-no-files-found: error