-
Notifications
You must be signed in to change notification settings - Fork 2
217 lines (179 loc) · 7.11 KB
/
msbuild.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
name: 'Build & Release UCP3 backend'
on:
workflow_dispatch:
inputs:
release_message:
description: 'Message to write in the release'
required: true
type: string
default: '[Changelog](https://github.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch3/wiki/Changelog#)'
pre_release:
description: 'Pre release?'
required: true
default: true
type: boolean
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .
RELEASE_BODY: ''
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Add MSBuild to PATH
uses: microsoft/[email protected]
- name: Prepare signing by exporting secret to file
shell: pwsh
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
UCP3_SIGNING_CERTIFICATE_CONTENTS: ${{ secrets.UCP3_SIGNING_CERTIFICATE_CONTENTS }}
run: |
Set-Content -Value "$env:UCP3_SIGNING_CERTIFICATE_CONTENTS" -Path "$($env:GITHUB_WORKSPACE)\ucp3-module-signing-key.pem" -Force
- name: Run build script dev build
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
UCP3_READ_PACKAGES: ${{ secrets.UCP3_READ_PACKAGES }}
shell: pwsh
run: |
.\scripts\build.ps1 -What all -BuildType Release -NugetToken "$env:UCP3_READ_PACKAGES" -Certificate "$($env:GITHUB_WORKSPACE)\ucp3-module-signing-key.pem"
- name: Run build script release build
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
UCP3_READ_PACKAGES: ${{ secrets.UCP3_READ_PACKAGES }}
shell: pwsh
run: |
.\scripts\build.ps1 -What all -BuildType ReleaseSecure -NugetToken "$env:UCP3_READ_PACKAGES" -Certificate "$($env:GITHUB_WORKSPACE)\ucp3-module-signing-key.pem"
- name: Add UCP3 version to the github environment
shell: pwsh
run: |
Import-Module powershell-yaml
$f = Get-Content -Path "version.yml" -Raw
$vyml = ConvertFrom-Yaml $f
$version_string = "$($vyml.major).$($vyml.minor).$($vyml.patch)";
$env:UCP_VERSION = $version_string
echo "UCP_VERSION=$version_string" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Generate a snapshot UCP3 artifact name
shell: pwsh
run: |
$name = "$env:GITHUB_SHA".SubString(0, 10)
$type1 = "DevRelease"
$type2 = "Release"
$version = $env:UCP_VERSION
$env:UCP_NAME_RELEASE = "UCP3-$version-$name"
$env:UCP_NAME_DEVRELEASE = "UCP3-$version-$name-Developer"
$env:UCP_NAME_NUPKG = "UCP3-$version-$name-nupkg"
echo "UCP_NAME_RELEASE=$($env:UCP_NAME_RELEASE)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "UCP_NAME_DEVRELEASE=$($env:UCP_NAME_DEVRELEASE)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "UCP_NAME_NUPKG=$($env:UCP_NAME_NUPKG)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Upload UCP3 dev release as an artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.UCP_NAME_DEVRELEASE }}
path: Release/ucp-package/*
retention-days: 1
- name: Upload UCP3 release as an artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.UCP_NAME_RELEASE }}
path: ReleaseSecure/ucp-package/*
retention-days: 1
- name: Upload UCP3 nupkg for devs as an artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.UCP_NAME_NUPKG }}
path: dll/*.nupkg
retention-days: 1
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: zip artifacts
shell: pwsh
run: |
pushd artifacts
$artifactDirs = Get-ChildItem -Directory
foreach($artifactDir in $artifactDirs) {
$dirName = $artifactDir.name
pushd $artifactDir
7z a -tzip -m0=Copy "..\$dirName.zip" *
popd
}
popd
- name: Create changelog URL
run: |
$m = "${{ inputs.release_message }}"
$t = "[Changelog](https://github.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch3/wiki/Changelog#)"
if ( $m.Contains($t) ) {
## Get the version
$v = $env:UCP_VERSION
$vm = $v.Replace(".", "") # Needed this way for pound urls
## Create the version URL
$url = $t.Replace("#", "#v$vm")
$n = $m.Replace($t, $url)
## Write the url
echo "RELEASE_BODY=$n" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} else {
echo "RELEASE_BODY=$m" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
shell: pwsh
- name: Create latest.json
shell: pwsh
run: |
$url = ${{ steps.auto_update.outputs.upload_url }}
$tag = 'v${{ env.UCP_VERSION }}'
$baseUrl = "https://github.com/UnofficialCrusaderPatch/UnofficialCrusaderPatch3/releases/download/$($tag)/"
$latest = @{
'version' = "$env:UCP_VERSION"
'sha' = "$env:GITHUB_SHA"
'notes' = "$env:RELEASE_BODY"
'pub_date' = Get-Date -Format "o"
'build_date' = "$(git log -1 --format=%cd --date=iso-strict)"
'base_url' = "$baseUrl"
'builds' = @{
'Developer' = @{
'url' = "$($baseUrl)$($env:UCP_NAME_DEVRELEASE).zip"
}
'Release' = @{
'url' = "$($baseUrl)$($env:UCP_NAME_RELEASE).zip"
}
}
}
ConvertTo-Json $latest | Set-Content -Path latest.json
- name: Create GitHub release
uses: 'marvinpinto/action-automatic-releases@latest'
id: auto_update
with:
repo_token: '${{ secrets.GITHUB_TOKEN }}'
automatic_release_tag: 'v${{ env.UCP_VERSION }}'
prerelease: ${{ inputs.pre_release }}
draft: false
title: 'UCP3: v${{ env.UCP_VERSION }}'
files: |
artifacts/*.zip
latest.json
- name: Ping UCP3-extensions-repo (create branch for this release)
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
if: false
run: |
gh repo clone UnofficialCrusaderPatch/UCP3-extensions-store
cd UCP3-extensions-store
$branchLatest = git branch -a |
Where-Object {$_ -match "remotes/origin/[0-9]+[.][0-9]+[.][0-9]+"} |
Sort-Object {[semver]( $_.Split("remotes/origin/"))[1]} -Descending |
Select-Object -First 1 |
ForEach-Object {$_.Split("remotes/origin/")[1]}
git checkout -b ${{ env.UCP_VERSION }} origin/$branchLatest
git push --set-upstream origin ${{ env.UCP_VERSION }}
- name: Push release to auto updater
if: ${{ inputs.pre_release == false }}
uses: exuanbo/actions-deploy-gist@v1
with:
token: '${{ secrets.UCP3_MACHINE_GIST_TOKEN }}'
gist_id: 6a7c1de585ed6d60d9ce318c1825d9a7
file_path: latest.json
file_type: text