-
-
Notifications
You must be signed in to change notification settings - Fork 72
318 lines (271 loc) · 10.4 KB
/
build_release_template.yml
File metadata and controls
318 lines (271 loc) · 10.4 KB
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Reusable workflow for Github Action which builds release for specified revisions
#
# This script builds and packages a release for Linux, Windows, OSX and FreeBSD
# using the specified revision. The generated archives are returned as build
# artifacts
#
# Job overview:
# 1. Generates the documentation included in each release
# 2. Builds the actual release (using a matrix over all targets)
name: build-release
on:
# Only runs when called from another workflow
workflow_call:
inputs:
# Determines the branch for all repositories
release_branch:
type: string
required: true
description: Revision to build as a new release
installer_repo:
type: string
default: 'dlang/installer'
description: dlang/installer or any fork hosting installer_branch
installer_branch:
type: string
default: 'master'
description: Branch providing the build scripts
# Expose the commit hash of the built revisions for dmd / druntime / phobos
# (useful for error reporting / logs / ...)
outputs:
dmd-revision:
value: ${{ jobs.build-docs.outputs.dmd-revision }}
phobos-revision:
value: ${{ jobs.build-docs.outputs.phobos-revision }}
jobs:
# Build the documentation used by all releases
build-docs:
name: Build documentation for all repos
outputs:
dmd-revision: ${{ steps.get-revisions.outputs.dmd-revision }}
phobos-revision: ${{ steps.get-revisions.outputs.phobos-revision }}
steps:
# Clone all required repos
- name: Clone dmd
uses: actions/checkout@v4
with:
repository: 'dlang/dmd'
ref: ${{ inputs.release_branch }}
fetch-depth: 0
path: 'dmd'
- name: Clone phobos
uses: actions/checkout@v4
with:
repository: 'dlang/phobos'
ref: ${{ inputs.release_branch }}
fetch-depth: 0
path: 'phobos'
- name: Clone dlang.org
uses: actions/checkout@v4
with:
repository: 'dlang/dlang.org'
ref: ${{ inputs.release_branch }}
fetch-depth: 0
path: 'dlang.org'
# Fetch host compiler
- uses: dlang-community/setup-dlang@v1
name: Install host DMD to build the documentation
with:
compiler: dmd-latest
# Actually build the docs
- name: Build docs and man pages
shell: bash
run: |
set -euox pipefail
N=$(( 2 * $(nproc) ))
# Build minimal host compiler (sometimes not triggered by dlang.org/posix.mak)
make -j$N -C dmd
# Build docs and include the man pages
make -f posix.mak -j$N -C dlang.org release
cp -r dmd/generated/docs/man dlang.org/web/
# Save the generated documentation for the target-specific builds
- name: Upload generated docs as a temporary artifact
uses: actions/upload-artifact@v4
with:
name: dmd-documentation
path: dlang.org/web
retention-days: 1
if-no-files-found: error
- name: Determine revisions
id: get-revisions
shell: bash
run: |
set -euox pipefail
for REPO in dmd phobos
do
REV=$( git -C $REPO rev-parse HEAD )
echo "$REPO-revision=$REV" >> $GITHUB_OUTPUT
done
runs-on: ubuntu-latest
# Build and package a new release for each platform
build-all-releases:
name: Build release for ${{ matrix.target }} on ${{ matrix.os }}
needs: build-docs
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
target: linux
- os: macos-14
target: osx
- os: windows-2022
target: windows
# FreeBSD is built on an additional VM
- os: ubuntu-latest
target: freebsd
steps:
#################################################################
# Install the system dependencies required to build and run
# the actual release scripts
#
# Linux implementation based on `linux_both` in build_all.d and
# some additional experimentation to get curl working
#
- name: Install dependencies for linux
if: matrix.target == 'linux'
shell: bash
run: |
set -euox pipefail
# Install base dependencies (including multlib support)
sudo dpkg --add-architecture i386
sudo apt -y update
sudo apt -y install --no-install-recommends \
build-essential \
ca-certificates \
curl \
dpkg-dev \
fakeroot \
g++ \
g++-multilib \
gcc \
git \
gpg \
gpg-agent \
libcurl4 \
libcurl4-openssl-dev \
libcurl4:i386 \
libxml2 \
make \
p7zip-full \
rpm \
rsync \
unzip \
xz-utils
# Save some space
sudo apt clean
#################################################################
# Install latest LDC used to compile the release scripts and to
# determine the currently available version number
#
- uses: dlang-community/setup-dlang@v1
name: Install latest LDC
if: matrix.target != 'freebsd'
with:
compiler: ldc-latest
#################################################################
# Clone dlang/installer which provides the actual build scripts
#
- name: Clone installer repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.installer_repo }}
ref: ${{ inputs.installer_branch }}
#################################################################
# Load the generated documentation in the create_dmd_release folder
#
- name: Download docs generated by the previous job
uses: actions/download-artifact@v4
with:
name: dmd-documentation
path: create_dmd_release/docs
#################################################################
# Build for the current target using build_all.d from installer
#
- name: Fetch common resources and run build_all.d for ${{ matrix.target }}
id: build
if: matrix.target != 'freebsd'
shell: bash
run: |
set -euox pipefail
# Fetch GPG key used to sign the generated binaries
curl -fsS https://dlang.org/d-keyring.gpg -o d-keyring.gpg
gpg --import d-keyring.gpg
# Compile release builder
cd create_dmd_release
ldmd2 -g -m64 --link-defaultlib-debug -version=NoVagrant -i build_all.d
# Determine installed LDC version
LDC=$(head -n 1 < <(ldc2 --version) | cut -d'(' -f2 | cut -d')' -f1)
# Windows: set LDC_VSDIR
if [[ "${{ matrix.target }}" == "windows" ]]
then
export LDC_VSDIR='C:\Program Files\Microsoft Visual Studio\2022\Enterprise'
fi
# Build the release
./build_all --targets=${{ matrix.target }} "v$LDC" ${{ inputs.release_branch }}
- name: 'Windows: Build NSIS installer'
if: matrix.target == 'windows'
shell: cmd
run: |
:: install NSIS plugin from https://nsis.sourceforge.io/Inetc_plug-in
curl -fsSL https://nsis.sourceforge.io/mediawiki/images/c/c9/Inetc.zip -o inetc.zip || exit /b
7z x inetc.zip -y -bb1 "-oc:\Program Files (x86)\NSIS" || exit /b
:: unpack release .7z generated in previous step
:: chomp off the "v" prefix if there is one, as this is what build_all does
set release=${{ inputs.release_branch }}
if "%release:~0,1%"=="v" set release=%release:~1%
7z x create_dmd_release\build\dmd.%release%.windows.7z -odmd.windows || exit /b
@echo on
"c:\Program Files (x86)\NSIS\makensis" /version
for /f %%v in (dmd.windows\dmd2\src\VERSION) do set ver=%%v
cd windows || exit /b
"c:\Program Files (x86)\NSIS\makensis" /DVersion2=%ver% /DEmbedD2Dir=..\dmd.windows\dmd2 d2-installer.nsi || exit /b
ren dmd-%ver%.exe dmd-%release%.exe || exit /b
copy dmd-*.exe ..\create_dmd_release\build || exit /b
#################################################################
# FREEBSD: Build for the current target using build_all.d from installer
#
- name: Run build_all.d for FreeBSD in a dedicated VM
if: matrix.target == 'freebsd'
uses: cross-platform-actions/action@v0.23.0
with:
operating_system: freebsd
hypervisor: qemu
memory: 12G
cpu_count: 4
version: '13.2'
shell: bash
run: |
set -eux
sudo pkg install -y curl curlpp git gmake pkgconf gnupg rsync llvm19
# Import key used to sign binaries
curl -fsS https://dlang.org/d-keyring.gpg -o d-keyring.gpg
gpg d-keyring.gpg
# Install ldc
curl -fsS https://dlang.org/install.sh -o install.sh
bash install.sh ldc -p .
# Use absolute paths because activate doesn't work correctly
LDC_BIN=$PWD/ldc-*/bin
# Determine installed LDC version
LDC=$($LDC_BIN/ldc2 --version | head -n 1 | cut -d'(' -f2 | cut -d')' -f1)
# Determine additional linker flags to make -lcurl work
EXTRA_FLAGS="-L$(pkg-config --libs-only-L libcurl)"
# Actually build the release
cd create_dmd_release
$LDC_BIN/ldmd2 -g -m64 --link-defaultlib-debug -version=NoVagrant -i build_all.d $EXTRA_FLAGS
./build_all --targets=${{ matrix.target }} "v$LDC" ${{ inputs.release_branch }}
#################################################################
# Save the target-specific release as a artifact s.t. the next
# job(s) have access to all generated releases
#
- name: Upload generated release as a temporary artifact
uses: actions/upload-artifact@v4
with:
name: dmd-release-${{ matrix.target }}
path: |
create_dmd_release/build/*
!create_dmd_release/build/*.zip
retention-days: 1
if-no-files-found: error
runs-on: ${{ matrix.os }}