-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
230 lines (199 loc) · 7.51 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
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
218
219
220
221
222
223
224
225
226
227
228
229
230
name: Build ShareX
on:
push:
branches:
- "**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
paths-ignore:
- "**/*.md"
- "**/*.gitignore"
- "**/*.gitattributes"
permissions:
contents: read
jobs:
build:
name: Build
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
configuration:
- Release
- Debug
- Steam
- MicrosoftStore
- MicrosoftStoreDebug
platform:
- Any CPU
env:
SOLUTION_FILE_PATH: ShareX.sln
ASSEMBLY_INFO_PATH: Directory.build.props
outputs:
APP_VERSION: ${{ env.APP_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: Set APP_VERSION
run: |
$content = Get-Content "${{ env.ASSEMBLY_INFO_PATH }}" -Raw
$pattern = '<Version>([0-9]+(?:\.[0-9]+){1,3})</Version>'
$match = [regex]::Match($content, $pattern)
$version = $match.Groups[1].Value
if ($env:GITHUB_REF -eq "refs/heads/develop") {
$version = "$version.$env:GITHUB_RUN_NUMBER"
$content = [regex]::Replace($content, $pattern, "<Version>$version</Version>")
Set-Content -Path "${{ env.ASSEMBLY_INFO_PATH }}" -Value "$content" -NoNewline
}
echo $version
echo "APP_VERSION=$version" >> $env:GITHUB_ENV
- name: Download API keys
env:
API_KEYS: ${{ secrets.API_KEYS }}
if: env.API_KEYS != ''
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: |
Invoke-WebRequest -Uri "$env:API_KEYS" -OutFile "ShareX.UploadersLib\APIKeys\APIKeysLocal.cs"
- name: Restore NuGet packages
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: nuget restore "${{ env.SOLUTION_FILE_PATH }}" -Project2ProjectTimeOut 300
- name: Build
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: msbuild -m -p:Configuration="${{ matrix.configuration }}" -p:Platform="${{ matrix.platform }}" "${{ env.SOLUTION_FILE_PATH }}"
- name: Setup
working-directory: ${{ env.GITHUB_WORKSPACE }}
run: |
& "ShareX.Setup\bin\${{ matrix.configuration }}\ShareX.Setup.exe" -silent -job "${{ matrix.configuration }}"
- name: Upload artifact (Setup)
if: matrix.configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: Setup
path: Output\ShareX-${{ env.APP_VERSION }}-setup.exe
- name: Upload artifact (Portable)
if: matrix.configuration == 'Release'
uses: actions/upload-artifact@v4
with:
name: Portable
path: Output\ShareX-${{ env.APP_VERSION }}-portable.zip
- name: Upload artifact (Debug)
if: matrix.configuration == 'Debug'
uses: actions/upload-artifact@v4
with:
name: Debug
path: Output\ShareX-${{ env.APP_VERSION }}-debug.zip
- name: Upload artifact (Steam)
if: matrix.configuration == 'Steam'
uses: actions/upload-artifact@v4
with:
name: Steam
path: Output\ShareX-${{ env.APP_VERSION }}-Steam.zip
- name: Upload artifact (MicrosoftStore)
if: matrix.configuration == 'MicrosoftStore'
uses: actions/upload-artifact@v4
with:
name: MicrosoftStore
path: Output\ShareX-${{ env.APP_VERSION }}.appx
- name: Upload artifact (MicrosoftStoreDebug)
if: matrix.configuration == 'MicrosoftStoreDebug'
uses: actions/upload-artifact@v4
with:
name: MicrosoftStoreDebug
path: Output\ShareX-${{ env.APP_VERSION }}-debug.appx
release:
name: Release
needs: build
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/v')
runs-on: windows-latest
permissions:
contents: write
env:
REPO_DEV_BUILDS: ${{ github.repository_owner }}/DevBuilds
RELEASE_BODY_PATH: RELEASE_BODY.md
APP_VERSION: ${{ needs.build.outputs.APP_VERSION }}
steps:
- name: Download artifact (Setup)
uses: actions/download-artifact@v4
with:
name: Setup
path: Output
- name: Download artifact (Portable)
uses: actions/download-artifact@v4
with:
name: Portable
path: Output
- name: Download artifact (Debug)
if: github.ref == 'refs/heads/develop'
uses: actions/download-artifact@v4
with:
name: Debug
path: Output
- name: Download artifact (Steam)
if: github.ref == 'refs/heads/develop'
uses: actions/download-artifact@v4
with:
name: Steam
path: Output
- name: Download artifact (MicrosoftStore)
if: github.ref == 'refs/heads/develop'
uses: actions/download-artifact@v4
with:
name: MicrosoftStore
path: Output
- name: Download artifact (MicrosoftStoreDebug)
if: github.ref == 'refs/heads/develop'
uses: actions/download-artifact@v4
with:
name: MicrosoftStoreDebug
path: Output
- name: Create release body file
run: |
$checksums = Get-ChildItem -Path "Output\" -Recurse -File
| Sort-Object -Property Name
| ForEach-Object { "| $($_.Name) | ``$((Get-FileHash $_.FullName -Algorithm SHA256).Hash)`` |" }
| Out-String
$output = "| File | SHA256 |`r`n| --- | --- |`r`n$($checksums.Trim())"
echo $output >> $env:GITHUB_STEP_SUMMARY
if ($env:GITHUB_REF.StartsWith("refs/tags/v")) {
$output = "**Changelog:** https://getsharex.com/changelog#$env:GITHUB_REF_NAME`r`n`r`n$output"
}
echo $output
Set-Content -Path "${{ env.RELEASE_BODY_PATH }}" -Value "$output" -NoNewline
- name: Release (Dev)
env:
CUSTOM_GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
if: env.CUSTOM_GITHUB_TOKEN != '' && env.REPO_DEV_BUILDS != '' && github.ref == 'refs/heads/develop'
uses: softprops/action-gh-release@975c1b265e11dd76618af1c374e7981f9a6ff44a
with:
repository: ${{ env.REPO_DEV_BUILDS }}
token: ${{ env.CUSTOM_GITHUB_TOKEN }}
tag_name: v${{ env.APP_VERSION }}
name: ShareX ${{ env.APP_VERSION }} Dev
body_path: ${{ env.RELEASE_BODY_PATH }}
draft: false
prerelease: false
files: |
Output/ShareX-${{ env.APP_VERSION }}-setup.exe
Output/ShareX-${{ env.APP_VERSION }}-portable.zip
Output/ShareX-${{ env.APP_VERSION }}-debug.zip
Output/ShareX-${{ env.APP_VERSION }}-Steam.zip
Output/ShareX-${{ env.APP_VERSION }}.appx
Output/ShareX-${{ env.APP_VERSION }}-debug.appx
- name: Release (Stable)
env:
CUSTOM_GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
if: env.CUSTOM_GITHUB_TOKEN != '' && startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@975c1b265e11dd76618af1c374e7981f9a6ff44a
with:
repository: ${{ github.repository }}
token: ${{ env.CUSTOM_GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
name: ShareX ${{ env.APP_VERSION }}
body_path: ${{ env.RELEASE_BODY_PATH }}
draft: false
prerelease: true
files: |
Output/ShareX-${{ env.APP_VERSION }}-setup.exe
Output/ShareX-${{ env.APP_VERSION }}-portable.zip