-
Notifications
You must be signed in to change notification settings - Fork 63
182 lines (160 loc) · 10.2 KB
/
Copy pathBuild.yml
File metadata and controls
182 lines (160 loc) · 10.2 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Build Solution
on:
workflow_call:
jobs:
Build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
BUILD_CONFIGURATION: Release
steps:
# ------------------------------------------------------------------------------------------------------
# Createin version Tag & Number variables - only for CD Job
# ------------------------------------------------------------------------------------------------------
- name: Create Version Environment Variable - Windows
if: ${{github.workflow == 'CD' && runner.os == 'Windows'}}
id: set_version_windows
run: |
if ($env:GITHUB_EVENT_INPUTS_REVISION -ne 0) {
Write-Output "Alpha Version"
Write-Output "gingernumber=${{ github.event.inputs.major}}.${{ github.event.inputs.minor}}.${{ github.event.inputs.build}}.${{ github.event.inputs.revision}}" >> $env:GITHUB_ENV
} elseif ($env:GITHUB_EVENT_INPUTS_BUILD -ne 0 -and $env:GITHUB_EVENT_INPUTS_REVISION -eq 0) {
Write-Output "Beta Version"
Write-Output "gingernumber=${{ github.event.inputs.major}}.${{ github.event.inputs.minor}}.${{ github.event.inputs.build}}.${{ github.event.inputs.revision}}" >> $env:GITHUB_ENV
} elseif ($env:GITHUB_EVENT_INPUTS_BUILD -eq 0 -and $env:GITHUB_EVENT_INPUTS_REVISION -eq 0) {
Write-Output "Official Version"
Write-Output "gingernumber=${{ github.event.inputs.major}}.${{ github.event.inputs.minor}}.${{ github.event.inputs.build}}.${{ github.event.inputs.revision}}" >> $env:GITHUB_ENV
}
- name: Create Version Environment Variable - Linux and macOS
if: ${{github.workflow == 'CD' && (runner.os == 'Linux' || runner.os == 'macOS')}}
id: set_version_unix
run: |
if [[ ${{github.event.inputs.revision}} != 0 ]]; then
echo "Alpha Version"
echo "gingernumber=${{ github.event.inputs.major}}.${{ github.event.inputs.minor}}.${{ github.event.inputs.build}}.${{ github.event.inputs.revision}}" >> $GITHUB_ENV
elif [[ ${{github.event.inputs.build}} != 0 && ${{github.event.inputs.revision}} == 0 ]]; then
echo "Beta Version"
echo "gingernumber=${{ github.event.inputs.major}}.${{ github.event.inputs.minor}}.${{ github.event.inputs.build}}.${{ github.event.inputs.revision}}" >> $GITHUB_ENV
elif [[ ${{github.event.inputs.build}} == 0 && ${{github.event.inputs.revision}} == 0 ]]; then
echo "Official Version"
echo "gingernumber=${{ github.event.inputs.major}}.${{ github.event.inputs.minor}}.${{ github.event.inputs.build}}.${{ github.event.inputs.revision}}" >> $GITHUB_ENV
fi
- name: Print Version Environment Variable
if: ${{github.workflow == 'CD'}}
run: |
echo "GingerNumber Version: ${{ env.gingernumber}}"
# ------------------------------------------------------------------------------------------------------
# Copy Ginger repo
# ------------------------------------------------------------------------------------------------------
- uses: actions/checkout@v6
# ------------------------------------------------------------------------------------------------------
# Update Ginger Version
# ------------------------------------------------------------------------------------------------------
- name: 'Update Assembly - Windows'
if: ${{github.workflow == 'CD' && runner.os == 'Windows'}}
run: |
$save=((Get-Content .\Ginger\GingerCoreCommon/GingerCoreCommon.csproj) -replace '<AssemblyVersion>*.*.*.*</AssemblyVersion>','<AssemblyVersion>${{ env.gingernumber}}</AssemblyVersion>') -replace '<FileVersion>*.*.*.*</FileVersion>','<FileVersion>${{ env.gingernumber}}</FileVersion>'
echo $save > .\Ginger\GingerCoreCommon/GingerCoreCommon.csproj
$save=(Get-Content .\Ginger\GingerInstallerScript.iss) -replace '#define MyAppVersion "*.*.*.*"','#define MyAppVersion "${{ env.gingernumber}}"'
echo $save > .\Ginger\GingerInstallerScript.iss
$save=(Get-Content .\Ginger\GingerInstallerScriptGithub.iss) -replace '#define MyAppVersion "*.*.*.*"','#define MyAppVersion "${{ env.gingernumber}}"'
echo $save > .\Ginger\GingerInstallerScriptGithub.iss
- name: 'Update Assembly - Linux'
if: ${{github.workflow == 'CD' && runner.os == 'Linux'}}
run: |
sed -i 's/<AssemblyVersion>.*<\/AssemblyVersion>/<AssemblyVersion>${{ env.gingernumber}}<\/AssemblyVersion>/' ./Ginger/GingerCoreCommon/GingerCoreCommon.csproj
sed -i 's/<FileVersion>.*<\/FileVersion>/<FileVersion>${{ env.gingernumber}}<\/FileVersion>/' ./Ginger/GingerCoreCommon/GingerCoreCommon.csproj
sed -i 's/#define MyAppVersion ".*"/#define MyAppVersion "${{ env.gingernumber}}"/' ./Ginger/GingerInstallerScript.iss
sed -i 's/#define MyAppVersion ".*"/#define MyAppVersion "${{ env.gingernumber}}"/' ./Ginger/GingerInstallerScriptGithub.iss
- name: 'Update Assembly - macOS'
if: ${{github.workflow == 'CD' && runner.os == 'macOS'}}
run: |
sed -i '' 's/<AssemblyVersion>.*<\/AssemblyVersion>/<AssemblyVersion>${{ env.gingernumber}}<\/AssemblyVersion>/' ./Ginger/GingerCoreCommon/GingerCoreCommon.csproj
sed -i '' 's/<FileVersion>.*<\/FileVersion>/<FileVersion>${{ env.gingernumber}}<\/FileVersion>/' ./Ginger/GingerCoreCommon/GingerCoreCommon.csproj
sed -i '' 's/#define MyAppVersion ".*"/#define MyAppVersion "${{ env.gingernumber}}"/' ./Ginger/GingerInstallerScript.iss
sed -i '' 's/#define MyAppVersion ".*"/#define MyAppVersion "${{ env.gingernumber}}"/' ./Ginger/GingerInstallerScriptGithub.iss
- name: 'Print OS type'
run: |
echo "Running on ${{ runner.os }}"
# ------------------------------------------------------------------------------------------------------
# Install .Net core SDK 10.0.103
# ------------------------------------------------------------------------------------------------------
- name: 'Install .NET 10'
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.103
# ------------------------------------------------------------------------------------------------------
# Install Mono - for Ubuntu as pre-requisite for building Ginger
# ------------------------------------------------------------------------------------------------------
- name: 'Install Mono - Linux'
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y mono-complete
- name: 'Install Mono - macOS'
if: runner.os == 'macOS'
run: brew install mono
# ------------------------------------------------------------------------------------------------------
# Install Nuget tool v1.0.5
# ------------------------------------------------------------------------------------------------------
- name: 'Setup Nuget'
uses: Nuget/setup-nuget@v2.0.1
# ------------------------------------------------------------------------------------------------------
# Restore Ginger solution NuGet packages
# ------------------------------------------------------------------------------------------------------
- name: 'Restore nuget packages'
run: nuget restore ./Ginger/Ginger.sln
# ------------------------------------------------------------------------------------------------------
# Build && Publish Ginger Solution
# ------------------------------------------------------------------------------------------------------
- name: 'Add msbuild to PATH'
if: runner.os == 'Windows'
uses: microsoft/setup-msbuild@v2
- name: 'Build Ginger Windows Solution'
if: runner.os == 'Windows'
run: msbuild ./Ginger/Ginger.sln /p:DebugSymbols=true /p:DebugType=full /p:Configuration=$env:BUILD_CONFIGURATION
- name: 'Publish GingerRuntime - Linux'
if: runner.os == 'Linux'
run: dotnet publish ./Ginger/GingerRuntime/GingerRuntime.csproj --runtime linux-x64 --self-contained true -c Release
- name: 'Publish GingerRuntime - macOS'
if: runner.os == 'macOS'
run: dotnet publish ./Ginger/GingerRuntime/GingerRuntime.csproj --runtime osx-x64 --self-contained true -c Release
# ------------------------------------------------------------------------------------------------------
# Upload Artifacts
# ------------------------------------------------------------------------------------------------------
- name: Cache static site content - Windows
id: cache_windows
if: runner.os == 'Windows'
uses: actions/cache@v5
with:
path:
./**
key:
cache-site-windows-${{github.run_number}}
enableCrossOsArchive:
true
- name: Cache static site content - Linux
id: cache_linux
if: runner.os == 'Linux'
uses: actions/cache@v5
with:
path:
./**
key:
cache-site-linux-${{ github.run_number }}
enableCrossOsArchive:
true
- name: Cache static site content - macOS
id: cache_macos
if: runner.os == 'macOS'
uses: actions/cache@v5
with:
path:
./**
key:
cache-site-macos-${{ github.run_number }}
enableCrossOsArchive:
true