-
Notifications
You must be signed in to change notification settings - Fork 7
235 lines (204 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
231
232
233
234
235
name: Build
on:
push:
branches:
- master
- 'feature/**'
- 'bugfix/**'
- 'github/**'
workflow_dispatch:
jobs:
build:
name: Build
outputs:
# accessible from other jobs as ${{needs.experiments.outputs.version}}
version: ${{steps.version.outputs.version}}
strategy:
matrix:
os: [windows-latest]
arch: [amd64, x86]
charset: [unicode]
include:
- os: windows-latest
arch: x86
charset: ansi
runs-on: ${{matrix.os}}
defaults:
run:
shell: cmd
steps:
- id: version
name: Version
shell: python
run: |
import os
from datetime import datetime, timezone
date = datetime.now(tz=timezone.utc)
with open(os.getenv('GITHUB_OUTPUT'), "a") as fout:
print( f"version={date.year%100}.{date.month}.{date.day}.${{github.run_number}}")
fout.write(f"version={date.year%100}.{date.month}.{date.day}.${{github.run_number}}")
- name: Upgrade msys2/mingw32
if: matrix.arch == 'x86'
uses: msys2/setup-msys2@v2
with:
msystem: mingw32
release: false
update: true
install: git mingw-w64-i686-toolchain
- name: Upgrade msys2/mingw64
if: matrix.arch == 'amd64'
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
release: false
update: true
install: mingw-w64-x86_64-toolchain
- name: Checkout
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Patch version
working-directory: src/nscurl
run: py -3 _set_version.py --version=${{steps.version.outputs.version}}
- name: Checkout vcpkg
uses: actions/checkout@v4
with:
repository: 'Microsoft/vcpkg'
path: vcpkg/clone
- name: Setup vcpkg cache
uses: actions/cache@v4
with:
path: vcpkg/archives
key: ${{runner.os}}-${{matrix.arch}}-${{matrix.charset}}-${{hashFiles('vcpkg/overlay_*', 'vcpkg/clone/ports/curl', 'vcpkg/clone/ports/openssl', 'vcpkg/clone/ports/nghttp2', 'vcpkg/clone/ports/zlib', 'vcpkg/clone/ports/brotli', 'vcpkg/clone/ports/zstd')}}
# -----------------------------------------------------------------------
- name: Build
run: _build.bat mingw release ${{matrix.arch}} ${{matrix.charset}}
# -----------------------------------------------------------------------
- name: List `packages` files
run: dir /s /b /a-d packages
- name: Upload versions.json
if: matrix.arch == 'x86' && matrix.charset == 'unicode'
uses: actions/upload-artifact@v4
with:
name: versions
path: Release-mingw-${{matrix.arch}}-${{matrix.charset}}/versions.json
- name: Upload plugin
uses: actions/upload-artifact@v4
with:
name: package-${{matrix.arch}}-${{matrix.charset}}
path: packages/Release-mingw-${{matrix.arch}}-${{matrix.charset}}/*
- name: Upload curl
if: matrix.charset == 'unicode'
uses: actions/upload-artifact@v4
with:
name: curl-${{matrix.arch}}
path: packages/Release-mingw-${{matrix.arch}}-curl/*
package:
name: Final Package
needs: build
runs-on: windows-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: package-*
merge-multiple: true
- name: Upload final package
uses: actions/upload-artifact@v4
with:
name: NScurl
path: artifacts/*
# Install an NSIS fork with amd64 support
# note: NSIS-negrutiu sits in C:\Program Files\NSIS
# note: NSIS-official sits in C:\Program Files (x86)\NSIS
- name: Install NSIS-negrutiu
shell: cmd
run: |
setlocal enabledelayedexpansion
set version=3.10.7422.0
set arch=amd64
curl -L --fail -o nsis-%version%-negrutiu-%arch%.exe https://github.com/negrutiu/nsis/releases/download/v%version%/nsis-%version%-negrutiu-%arch%.exe || exit /b !errorlevel!
echo installing...
nsis-%version%-negrutiu-%arch%.exe /S
- name: Build NSIS example (x86-unicode)
shell: cmd
run: |
set PATH=%ProgramFiles%\NSIS;%PATH%
"%ProgramFiles%\NSIS\makensis.exe" /V4 /DPLUGIN_DIR=..\..\Plugins\x86-unicode artifacts\Examples\NScurl\NScurl-Test.nsi
- name: Build NSIS example (x86-ansi)
shell: cmd
run: |
set PATH=%ProgramFiles%\NSIS;%PATH%
makensis.exe /V4 /DPLUGIN_DIR=..\..\Plugins\x86-ansi /DANSI artifacts\Examples\NScurl\NScurl-Test.nsi
- name: Build NSIS example (amd64-unicode)
shell: cmd
run: |
set PATH=%ProgramFiles%\NSIS;%PATH%
makensis.exe /V4 /DPLUGIN_DIR=..\..\Plugins\amd64-unicode /DAMD64 artifacts\Examples\NScurl\NScurl-Test.nsi
- name: Upload NSIS examples
uses: actions/upload-artifact@v4
with:
name: NScurl-Examples
path: artifacts/Examples/NScurl/NScurl-Test-*.exe
release:
name: Release Draft
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/github/')
needs: [build, package]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
# note: we're using dawidd6/action-download-artifact@v5 because of `skip_unpack`
- name: Download artifacts
uses: dawidd6/action-download-artifact@v5
with:
path: artifacts
name: ^NScurl$|^NScurl-Examples$|^versions$
name_is_regexp: true
run_id: ${{github.run_id}}
skip_unpack: true
# note: we need `versions` artifact unzipped
- name: Download versions.json
uses: actions/download-artifact@v4
with:
path: artifacts
pattern: versions
merge-multiple: true
- name: Read versions.json
id: versions
shell: python
run: |
import os
with open('artifacts/versions.json') as fin:
with open(os.getenv('GITHUB_OUTPUT'), "a") as fout:
fout.write(f"versions_json={fin.read()}")
- name: Prepare release notes
shell: python
run: |
lines = []
with open(".github/workflows/release-body.md") as fin:
line = fin.read()
line = line.replace('{version-engines}', '${{fromJson(steps.versions.outputs.versions_json).curl_md}}')
line = line.replace('{version-gcc}', '${{fromJson(steps.versions.outputs.versions_json).gcc}}')
line = line.replace('{url-workflow}', 'https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}')
lines.append(line)
with open(".github/workflows/release-body.md", "w") as fout:
for line in lines:
fout.write(line)
- name: Create GitHub release draft
uses: ncipollo/release-action@v1
with:
# note: `tag` is the release key
tag: release-candidate
name: v${{needs.build.outputs.version}}
artifacts: artifacts/*
bodyFile: .github/workflows/release-body.md
draft: true
makeLatest: true
allowUpdates: true
updateOnlyUnreleased: true
artifactErrorsFailBuild: true
removeArtifacts: true