-
Notifications
You must be signed in to change notification settings - Fork 5
288 lines (247 loc) · 9.43 KB
/
build_main.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
name: Build
on:
push:
branches: [ main ]
tags: [ 'v*' ]
env:
version: "1.0.1"
jobs:
build:
runs-on: windows-2019
outputs:
package_version: ${{ env.PACKAGE_VERSION }}
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Ensure .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Install Build Dependencies
run: |
choco install meson
choco install ninja
choco install nasm
echo "C:\Program Files\NASM" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:\Program Files\Meson" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Set Version from Tag
if: startsWith(github.ref, 'refs/tags/v') == true
run: |
$version = "${{ github.ref }}" -replace "refs/tags/v", ""
echo "PACKAGE_VERSION=$version" >> $env:GITHUB_ENV
echo "Version: $version"
- name: Set Version
if: startsWith(github.ref, 'refs/tags/v') == false
run: echo "PACKAGE_VERSION=${{ env.version }}-dev.${{ GITHUB.RUN_NUMBER }}" >> $env:GITHUB_ENV
- name: Build
run: dotnet build -c Release
working-directory: ./src/FileOnQ.Imaging.Heif
- name: Pack
run: dotnet pack -c Release -o ../../ /p:Version=${{ env.PACKAGE_VERSION }} /p:PackageVersion=${{ env.PACKAGE_VERSION }}
working-directory: ./src/FileOnQ.Imaging.Heif
- name: Upload NuGet Package
uses: actions/upload-artifact@v2
with:
name: Packages
path: |
*.nupkg
*.snupkg
test-integration:
needs: build
runs-on: ${{ matrix.os }}
outputs:
package_version: ${{ needs.build.outputs.package_version }}
strategy:
matrix:
include:
- os: windows-2019
architecture: 'AnyCPU'
framework: 'net48'
- os: windows-2019
architecture: 'x86'
framework: 'net48'
- os: windows-2019
architecture: 'x64'
framework: 'net48'
- os: windows-2019
architecture: 'AnyCPU'
framework: 'net5'
- os: windows-2019
architecture: 'x86'
framework: 'net5'
- os: windows-2019
architecture: 'x64'
framework: 'net5'
- os: windows-2019
architecture: 'AnyCPU'
framework: 'net6'
- os: windows-2019
architecture: 'x86'
framework: 'net6'
- os: windows-2019
architecture: 'x64'
framework: 'net6'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Ensure .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Copy Nupkg
shell: powershell
run: Copy-Item Packages\* -Destination .
- name: Update NuGet
run: dotnet add package FileOnQ.Imaging.Heif --version ${{ needs.build.outputs.package_version }}
working-directory: ./tests/FileOnQ.Imaging.Heif.Tests.${{ matrix.architecture }}
- name: Test ${{ matrix.architecture }}
run: dotnet test -c Release --logger:"console;verbosity=detailed" --filter TestCategory=Integration
working-directory: ./tests/FileOnQ.Imaging.Heif.Tests.${{ matrix.architecture }}
test-console-app:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-2019
architecture: 'AnyCPU'
framework: 'net48'
- os: windows-2019
architecture: 'x86'
framework: 'net48'
- os: windows-2019
architecture: 'x64'
framework: 'net48'
- os: windows-2019
architecture: 'AnyCPU'
framework: 'net5'
- os: windows-2019
architecture: 'x86'
framework: 'net5'
- os: windows-2019
architecture: 'x64'
framework: 'net5'
- os: windows-2019
architecture: 'AnyCPU'
framework: 'net6'
- os: windows-2019
architecture: 'x86'
framework: 'net6'
- os: windows-2019
architecture: 'x64'
framework: 'net6'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Ensure .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Copy Nupkg
shell: powershell
run: Copy-Item Packages\* -Destination .
- name: Update NuGet
run: dotnet add package FileOnQ.Imaging.Heif --version ${{ needs.build.outputs.package_version }}
working-directory: ./samples/ConsoleApp/ConsoleApp.${{ matrix.framework }}.${{ matrix.architecture }}
- name: Run Console App
run: dotnet run -c Release
working-directory: ./samples/ConsoleApp/ConsoleApp.${{ matrix.framework }}.${{ matrix.architecture }}
build-win-forms-app:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-2019
framework: 'net5'
- os: windows-2019
framework: 'net48'
- os: windows-2019
framework: 'net6'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: 'true'
- name: Ensure .NET 6 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.101
- name: Ensure .NET 5 SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.302
- name: Download Artifacts
uses: actions/download-artifact@v2
- name: Copy Nupkg
shell: powershell
run: Copy-Item Packages\* -Destination .
- name: Update NuGet
run: dotnet add package FileOnQ.Imaging.Heif --version ${{ needs.build.outputs.package_version }}
working-directory: ./samples/WinformsApp/WinformsApp.${{ matrix.framework }}
- name: Build WinForms App (Any CPU)
run: dotnet build -c Release /p:Platform=AnyCPU
working-directory: ./samples/WinformsApp/WinformsApp.${{ matrix.framework }}
- name: Build WinForms App (x86)
run: dotnet build -c Release /p:Platform=x86
working-directory: ./samples/WinformsApp/WinformsApp.${{ matrix.framework }}
- name: Build WinForms App (x64)
run: dotnet build -c Release /p:Platform=x64
working-directory: ./samples/WinformsApp/WinformsApp.${{ matrix.framework }}
nuget-publish:
if: startsWith(github.ref, 'refs/tags/v') == true
needs: [test-integration, test-console-app, build-win-forms-app]
runs-on: windows-2019
steps:
- name: Download Packages
uses: actions/download-artifact@v2
with:
name: Packages
- name: Set NuGet API Key
run: nuget setapikey ${{ secrets.NUGET_API_KEY }}
- name: Publish NuGet Packages
run: nuget push *.nupkg -Source https://api.nuget.org/v3/index.json
create-release:
if: startsWith(github.ref, 'refs/tags/v') == true
needs: [test-integration, test-console-app, build-win-forms-app]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: NPM Install GitHub-Release-Notes
run: npm install github-release-notes -g
- name: Release Notes - Add Issues
run: gren release --username=FileOnQ --token=${{ secrets.GITHUB_TOKEN }} --repo=Imaging.Heif --override --ignore-tags-with="preview"
- name: Release Notes - Add PRs
run: |
$release = Invoke-WebRequest -URI https://api.github.com/repos/FileOnQ/Imaging.Heif/releases/tags/v${{ needs.test-integration.outputs.package_version }} -Method GET -Headers @{"Accept"="application/vnd.github.v3+json"} -UseBasicParsing
$releaseContent = ConvertFrom-Json $release.Content
$generateNotes = Invoke-WebRequest -URI https://api.github.com/repos/FileOnQ/Imaging.Heif/releases/generate-notes -Method POST -Headers @{"Authorization"="Bearer ${{ secrets.GITHUB_TOKEN }}"; "Accept"="application/vnd.github.v3+json"} -Body '{"tag_name":"${{ needs.test-integration.outputs.package_version }}"}' -UseBasicParsing
$generateNotesContent = ConvertFrom-Json $generateNotes.Content
$body = $releaseContent.Body + $generateNotesContent.Body
echo $body
$uri = "https://api.github.com/repos/FileOnQ/Imaging.Heif/releases/" + $releaseContent.id
$json = ConvertTo-Json @{"body"=$body} -Compress
$response = Invoke-RestMethod -URI $uri -Method PATCH -Headers @{"Authorization"="Bearer ${{ secrets.GITHUB_TOKEN }}"; "Accept"="application/vnd.github.v3+json"} -Body $json -UseBasicParsing -ContentType "text/plain; charset=utf-8"