-
Notifications
You must be signed in to change notification settings - Fork 7
137 lines (108 loc) · 5.14 KB
/
Marathon.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
name: Marathon
on:
push:
branches: [ master ]
env:
VERSION: "1.0"
PROFILE_WIN_32: win-x86
PROFILE_WIN_64: win-x64
PROFILE_LINUX_64: linux-x64
PROFILE_OSX_64: osx-x64
SOLUTION_FILE: Marathon.sln
MARATHON_PROJECT: ${{github.workspace}}\Marathon\Marathon.csproj
MARATHON_CLI_PROJECT: ${{github.workspace}}\Marathon.CLI\Marathon.CLI.csproj
NUGET_SOURCE: https://api.nuget.org/v3/index.json
jobs:
build:
# Use the current configuration as the job name.
name: ${{matrix.configuration}}
# Use the 'windows-2022' image for CI.
runs-on: windows-2022
# Use the following configurations for building.
strategy:
matrix:
configuration: [ Debug, Release ]
steps:
# Downloads the latest Git repository for Marathon.
- name: Clone Marathon
uses: actions/checkout@v2
# Installs the required SDKs for .NET.
- name: Install .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
# Restores the NuGet packages from the solution for all projects.
- name: Restore NuGet Packages
working-directory: ${{github.workspace}}
run: nuget restore ${{env.SOLUTION_FILE}}
# Patches the version number using the last 'Windows' workflow run number and the latest 'Marathon' workflow run number.
- name: Patch Version Number
run: |
$version = "${{env.VERSION}}." + (45 + ${{github.run_number}})
echo "VERSION_RESOLVE=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
# Builds Marathon using the PowerShell script.
- name: Build Marathon
working-directory: ${{github.workspace}}
run: ./Build.ps1 -BuildAll -Clean -CommitID ${{github.sha}} -Configuration ${{matrix.configuration}} -Version ${{env.VERSION_RESOLVE}}
# Uploads the compiled Marathon artifacts.
- name: Upload Marathon Artifacts
uses: actions/upload-artifact@v2
with:
name: Marathon-${{matrix.configuration}}
path: ${{github.workspace}}\Marathon\bin\${{matrix.configuration}}\net6.0\publish\
# Uploads the compiled Marathon.CLI artifacts for 'win-x86'.
- name: Upload Marathon.CLI Artifacts for Windows (x86)
uses: actions/upload-artifact@v2
with:
name: Marathon.CLI-${{matrix.configuration}}-${{env.PROFILE_WIN_32}}
path: ${{github.workspace}}\Marathon.CLI\bin\${{matrix.configuration}}\net6.0\${{env.PROFILE_WIN_32}}\
# Uploads the compiled Marathon.CLI artifacts for 'win-x64'.
- name: Upload Marathon.CLI Artifacts for Windows (x64)
uses: actions/upload-artifact@v2
with:
name: Marathon.CLI-${{matrix.configuration}}-${{env.PROFILE_WIN_64}}
path: ${{github.workspace}}\Marathon.CLI\bin\${{matrix.configuration}}\net6.0\${{env.PROFILE_WIN_64}}\
# Uploads the compiled Marathon.CLI artifacts for 'linux-x64'.
- name: Upload Marathon.CLI Artifacts for Linux
uses: actions/upload-artifact@v2
with:
name: Marathon.CLI-${{matrix.configuration}}-${{env.PROFILE_LINUX_64}}
path: ${{github.workspace}}\Marathon.CLI\bin\${{matrix.configuration}}\net6.0\${{env.PROFILE_LINUX_64}}\
# Uploads the compiled Marathon.CLI artifacts for 'osx-x64'.
- name: Upload Marathon.CLI Artifacts for macOS
uses: actions/upload-artifact@v2
with:
name: Marathon.CLI-${{matrix.configuration}}-${{env.PROFILE_OSX_64}}
path: ${{github.workspace}}\Marathon.CLI\bin\${{matrix.configuration}}\net6.0\${{env.PROFILE_OSX_64}}\
publish:
name: Publish
# Use the 'windows-2022' image for CI.
runs-on: windows-2022
steps:
# Downloads the latest Git repository for Marathon.
- name: Clone Marathon
uses: actions/checkout@v2
# Installs the required SDKs for .NET.
- name: Install .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
# Restores the NuGet packages from the solution for all projects.
- name: Restore NuGet Packages
working-directory: ${{github.workspace}}
run: nuget restore ${{env.SOLUTION_FILE}}
# Patches the version number using the last 'Windows' workflow run number and the latest 'Marathon' workflow run number.
- name: Patch Version Number
run: |
$version = "${{env.VERSION}}." + (45 + ${{github.run_number}})
echo "VERSION_RESOLVE=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
# Patches the assembly information stored in 'Marathon.csproj' and 'Marathon.CLI.csproj' to use the current workflow version.
- name: Patch Version Information
run: |
./.github/workflows/Patch-Version.ps1 -ProjectPath "${{env.MARATHON_PROJECT}}" -Version ${{env.VERSION_RESOLVE}} -CommitID ${{github.sha}}
# Builds Marathon and packs it into a NuGet package.
- name: Create NuGet Package
run: dotnet pack "${{env.MARATHON_PROJECT}}" /p:Configuration=Release
# Publishes the compiled package to NuGet.
- name: Publish to NuGet
run: dotnet nuget push "${{github.workspace}}\Marathon\bin\Release\Marathon.${{env.VERSION_RESOLVE}}.nupkg" -k ${{secrets.NUGET_KEY}} -s ${{env.NUGET_SOURCE}}