-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.yml
More file actions
497 lines (428 loc) · 20.3 KB
/
action.yml
File metadata and controls
497 lines (428 loc) · 20.3 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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
name: 'Arturo Builder'
description: 'Setup Arturo environment'
branding:
icon: terminal
color: purple
inputs:
mode:
description: 'Build mode (mini, full, docgen, safe)'
default: 'full'
token:
description: 'GITHUB_TOKEN secret'
required: true
arch:
description: 'Target architecture (amd64, arm64, js)'
default: 'amd64'
src:
description: 'Arturo version/ref to use'
default: ''
metadata:
description: 'Embeddable build metadata'
default: ''
os:
description: 'Target OS (linux, windows, macos, freebsd, web)'
default: 'linux'
support:
description: 'Build support level (empty=standard, legacy=older systems)'
default: 'standard'
create_artifact:
description: 'Whether to create and upload artifact'
default: 'false'
artifact_version:
description: 'Version string for artifact naming'
default: ''
do:
description: 'Action to perform (fetch, compile)'
default: 'fetch'
from:
description: 'Source repository for fetch (stable, latest)'
default: 'stable'
artifacts_only:
description: 'Skip environment setup, just download and upload artifacts (only works with do=fetch)'
default: 'false'
release:
description: 'Make an official release (compile mode only)'
default: 'false'
runs:
using: "composite"
steps:
######################################
######################################
## INITIAL SETUP
######################################
######################################
- name: Detect build configuration
run: |
# Detect OS
if [ -z "${{ inputs.os }}" ] || [ "${{ inputs.os }}" = "linux" ]; then
case "${{ runner.os }}" in
Linux) detected_os="linux" ;;
macOS) detected_os="macos" ;;
Windows) detected_os="windows" ;;
*) detected_os="linux" ;;
esac
else
detected_os="${{ inputs.os }}"
fi
# Detect architecture
if [ -z "${{ inputs.arch }}" ] || [ "${{ inputs.arch }}" = "amd64" ]; then
case "${{ runner.arch }}" in
ARM64) detected_arch="arm64" ;;
X64) detected_arch="amd64" ;;
*) detected_arch="amd64" ;;
esac
else
detected_arch="${{ inputs.arch }}"
fi
# Determine support level
detected_support="${{ inputs.support }}"
if [ -z "$detected_support" ] || [ "$detected_support" = "standard" ]; then
if [ "${{ runner.os }}" = "Linux" ]; then
UBUNTU_VERSION=$(lsb_release -rs 2>/dev/null || echo "24.04")
if [[ "$UBUNTU_VERSION" < "24.04" ]]; then
detected_support="legacy"
else
detected_support="standard"
fi
else
detected_support="standard"
fi
fi
if [ "${{ inputs.mode }}" != "full" ] && [ "${{ inputs.mode }}" != "" ]; then
detected_support="standard"
fi
# Correctly handle web/js builds
if [ "$detected_os" = "web" ] || [ "$detected_arch" = "js" ]; then
detected_os="web"
detected_mode="mini"
detected_build_mode="web"
artifact_arch="js"
build_arch="amd64"
else
detected_mode="${{ inputs.mode }}"
[ -z "$detected_mode" ] && detected_mode="full"
detected_build_mode="$detected_mode"
artifact_arch="$detected_arch"
build_arch="$detected_arch"
fi
# Export to environment
echo "os=$detected_os" >> $GITHUB_ENV
echo "arch=$build_arch" >> $GITHUB_ENV
echo "artifact_arch=$artifact_arch" >> $GITHUB_ENV
echo "mode=$detected_mode" >> $GITHUB_ENV
echo "build_mode=$detected_build_mode" >> $GITHUB_ENV
echo "support=$detected_support" >> $GITHUB_ENV
echo "src=${{ inputs.src }}" >> $GITHUB_ENV
echo "metadata=${{ inputs.metadata }}" >> $GITHUB_ENV
echo "release=${{ inputs.release }}" >> $GITHUB_ENV
shell: bash
- name: Determine artifact name
run: |
if [ "${{ inputs.do }}" = "compile" ]; then
artifact_base="arturo-${{ inputs.artifact_version }}"
else
artifact_base="arturo-nightly"
fi
artifact_name="${artifact_base}-${{ env.os }}-${{ env.artifact_arch }}"
if [ "${{ env.mode }}" != "full" ] && [ "${{ env.mode }}" != "web" ]; then
artifact_name="${artifact_name}-${{ env.mode }}"
fi
if [ "${{ env.support }}" = "legacy" ]; then
artifact_name="${artifact_name}-legacy"
fi
echo "artifact_name=$artifact_name" >> $GITHUB_ENV
shell: bash
- name: Export runtime flags
run: |
if [ "${{ env.os }}" = "web" ] || [ "${{ env.mode }}" = "safe" ]; then
echo "arturoCanRun=false" >> $GITHUB_ENV
else
echo "arturoCanRun=true" >> $GITHUB_ENV
fi
shell: bash
- name: Debug
run: |
echo "======================================"
echo "Arturo Builder Configuration"
echo "======================================"
echo "Mode: ${{ inputs.do == 'compile' && 'COMPILE FROM SOURCE' || 'FETCH RELEASE' }}"
echo "From: ${{ inputs.from }}"
echo "Artifacts Only: ${{ inputs.artifacts_only }}"
echo "Runner OS: ${{ runner.os }}"
echo "Runner Arch: ${{ runner.arch }}"
echo "======================================"
echo "Target OS: ${{ env.os }}"
echo "Target Arch: ${{ env.arch }}"
echo "Artifact Arch: ${{ env.artifact_arch }}"
echo "Build Mode: ${{ env.mode }}"
echo "Support Level: ${{ env.support }}"
echo "Source Ref: ${{ env.src != '' && env.src || '(latest)' }}"
echo "Metadata: ${{ env.metadata != '' && env.metadata || '(none)' }}"
echo "Release: ${{ env.release == 'true' && 'yes' || 'no' }}"
echo "Artifact Name: ${{ env.artifact_name }}"
echo "======================================"
shell: bash
######################################
######################################
## FETCH RELEASE & ARTIFACTS-ONLY
######################################
######################################
- name: Determine latest release and fetch artifact
if: inputs.do == 'fetch'
id: release-info
run: |
REPO="${{ inputs.from == 'stable' && 'arturo-lang/arturo' || 'arturo-lang/nightly' }}"
echo "Fetching latest release from $REPO..."
LATEST_RELEASE=$(curl -s -H "Authorization: token ${{ inputs.token }}" \
"https://api.github.com/repos/${REPO}/releases/latest" | \
jq -r '.tag_name')
if [ -z "$LATEST_RELEASE" ] || [ "$LATEST_RELEASE" = "null" ]; then
echo "ERROR: Could not find latest release in $REPO"
exit 1
fi
echo "Latest release: $LATEST_RELEASE"
echo "release_tag=$LATEST_RELEASE" >> $GITHUB_OUTPUT
# Handle version formatting based on release type
if [ "${{ inputs.from }}" = "stable" ]; then
VERSION=$(echo $LATEST_RELEASE | sed 's/^v//')
FULL_ARTIFACT_NAME="arturo-${VERSION}-${{ env.os }}-${{ env.artifact_arch }}"
else
VERSION=$(echo $LATEST_RELEASE | tr -d '-')
FULL_ARTIFACT_NAME="arturo-nightly.${VERSION}-${{ env.os }}-${{ env.artifact_arch }}"
fi
[ "${{ env.mode }}" != "full" ] && [ "${{ env.mode }}" != "web" ] && FULL_ARTIFACT_NAME="${FULL_ARTIFACT_NAME}-${{ env.mode }}"
[ "${{ env.support }}" = "legacy" ] && FULL_ARTIFACT_NAME="${FULL_ARTIFACT_NAME}-legacy"
echo "artifact_name=$FULL_ARTIFACT_NAME" >> $GITHUB_OUTPUT
echo "Artifact to download: $FULL_ARTIFACT_NAME"
# If artifacts-only mode, download and extract immediately
if [ "${{ inputs.artifacts_only }}" = "true" ]; then
echo "=========================================="
echo "ARTIFACTS-ONLY MODE - Skipping environment setup"
echo "=========================================="
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST_RELEASE}/${FULL_ARTIFACT_NAME}.zip"
echo "Downloading: $DOWNLOAD_URL"
curl -fsSL -H "Authorization: token ${{ inputs.token }}" "$DOWNLOAD_URL" -o arturo-artifact.zip
# Extract to standard location for upload
mkdir -p arturo-bin
unzip -q arturo-artifact.zip -d arturo-bin
echo "arturoDistPath=arturo-bin" >> $GITHUB_ENV
echo "Artifact ready for upload"
ls -lah arturo-bin/
fi
shell: bash
######################################
######################################
## DEPENDENCIES
######################################
######################################
- name: Install dependencies (Linux)
if: (env.os == 'linux' || env.os == 'web') && inputs.artifacts_only != 'true'
run: |
# Multiple update attempts to handle mirror sync issues
for i in 1 2 3; do
sudo apt-get update && break
echo "Update attempt $i failed, retrying..."
sleep 5
done
if [ "${{ env.mode }}" != "mini" ]; then
sudo apt-get install -y libgtk-3-dev libmpfr-dev
if [ "${{ env.support }}" = "legacy" ]; then
for i in 1 2 3; do
sudo apt-get install -y --allow-downgrades libwebkit2gtk-4.0-dev && break || \
sudo apt-get install -y libwebkit2gtk-4.0-dev && break
echo "Webkit install attempt $i failed, retrying..."
sudo apt-get update
sleep 10
done
else
for i in 1 2 3; do
sudo apt-get install -y --allow-downgrades libwebkit2gtk-4.1-dev && break || \
sudo apt-get install -y libwebkit2gtk-4.1-dev && break
echo "Webkit install attempt $i failed, retrying..."
sudo apt-get update
sleep 10
done
fi
fi
if [ "${{ inputs.do }}" = "compile" ] && [ "${{ env.os }}" = "web" ]; then
npm install -g uglify-js
fi
shell: bash
- name: Install dependencies + Build (FreeBSD)
if: env.os == 'freebsd' && inputs.artifacts_only != 'true'
uses: vmactions/freebsd-vm@v1
with:
usesh: true
sync: rsync
copyback: true
prepare: |
pkg update -f
pkg install -y wget curl bash ca_root_nss jq
if [ "${{ env.mode }}" = "full" ]; then
pkg install -y gtk3 mpfr webkit2-gtk_41
fi
if [ "${{ inputs.do }}" = "compile" ]; then
pkg install -y nim git
if [ "${{ env.mode }}" = "full" ]; then
pkg install -y pkgconf openssl
fi
fi
run: |
if [ "${{ inputs.do }}" = "compile" ]; then
echo "=========================================="
echo "Building Arturo on FreeBSD..."
echo "=========================================="
git clone --recursive https://github.com/arturo-lang/arturo.git arturo-src
cd arturo-src
git config --global --add safe.directory '*'
if [ -n "${{ env.src }}" ]; then
git fetch origin ${{ env.src }}
git checkout FETCH_HEAD
fi
${{ env.metadata != '' && format('echo "{0}" > version/metadata', env.metadata) || '' }}
export PATH="/usr/local/nim/bin/:$PATH"
./build.nims --install --mode ${{ env.build_mode }} --log${{ env.release == 'true' && ' --release' || '' }}
cd ..
cp -r $HOME/.arturo/bin/* /usr/local/bin/
rm -rf arturo-src
else
echo "=========================================="
echo "Fetching Arturo on FreeBSD..."
echo "=========================================="
REPO="${{ inputs.from == 'stable' && 'arturo-lang/arturo' || 'arturo-lang/nightly' }}"
curl -fsSL -H "Authorization: token ${{ inputs.token }}" \
"https://github.com/${REPO}/releases/download/${{ steps.release-info.outputs.release_tag }}/${{ steps.release-info.outputs.artifact_name }}.zip" \
-o /tmp/arturo.zip
unzip -q /tmp/arturo.zip -d /usr/local/bin
chmod +x /usr/local/bin/arturo*
fi
cd $GITHUB_WORKSPACE
mkdir -p arturo-bin
cp -r /usr/local/bin/arturo* arturo-bin/
echo "arturoDistPath=arturo-bin" >> $GITHUB_ENV
echo "Complete. Files in arturo-bin:"
ls -lah arturo-bin/
- name: Setup Msys & dependencies (Windows)
if: env.os == 'windows' && inputs.artifacts_only != 'true'
uses: msys2/setup-msys2@v2
with:
update: true
cache: true
install: >-
git
base-devel
p7zip
unzip
mingw-w64-x86_64-toolchain
${{ inputs.do == 'compile' && env.mode == 'full' && 'mingw-w64-x86_64-mpfr' || '' }}
######################################
######################################
## > FETCH (non-artifacts-only mode)
######################################
######################################
- name: Fetch & setup release
if: inputs.do == 'fetch' && env.os != 'freebsd' && inputs.artifacts_only != 'true'
shell: ${{ env.os == 'windows' && 'msys2 {0}' || 'bash' }}
run: |
REPO="${{ inputs.from == 'stable' && 'arturo-lang/arturo' || 'arturo-lang/nightly' }}"
curl -fsSL -H "Authorization: token ${{ inputs.token }}" \
"https://github.com/${REPO}/releases/download/${{ steps.release-info.outputs.release_tag }}/${{ steps.release-info.outputs.artifact_name }}.zip" \
-o /tmp/arturo.zip
INSTALL_DIR="${{ env.os == 'windows' && '/usr/bin' || '$HOME/.arturo/bin' }}"
mkdir -p "$INSTALL_DIR"
unzip -q /tmp/arturo.zip -d "$INSTALL_DIR"
chmod +x "$INSTALL_DIR"/arturo*
echo "$INSTALL_DIR" >> $GITHUB_PATH
echo "arturoDistPath=$INSTALL_DIR" >> $GITHUB_ENV
echo "Arturo installed successfully"
######################################
######################################
## > COMPILE
######################################
######################################
- name: Checkout Arturo repo (Linux/macOS/Windows)
if: inputs.do == 'compile' && env.os != 'freebsd'
uses: actions/checkout@v4
with:
repository: arturo-lang/arturo
submodules: recursive
path: arturo-src
ref: ${{ env.src }}
- name: Set build metadata (Linux/macOS/Windows)
if: inputs.do == 'compile' && env.os != 'freebsd' && env.metadata != ''
run: |
echo "${{ env.metadata }}" > arturo-src/version/metadata
shell: bash
##====================================
## Nim installation
##====================================
- name: Install Nim (Linux/Web)
if: inputs.do == 'compile' && (env.os == 'linux' || env.os == 'web')
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo >> /home/runner/.bashrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/runner/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install nim
echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH
shell: bash
- name: Install Nim (macOS)
if: inputs.do == 'compile' && env.os == 'macos'
run: |
brew update
brew install nim
shell: bash
- name: Install Nim (Windows)
if: inputs.do == 'compile' && env.os == 'windows'
run: |
mkdir nim
curl -L https://nim-lang.org/download/nim-2.2.8_x64.zip -o nim.zip
7z x nim.zip -onim
rm nim.zip
shell: msys2 {0}
##====================================
## Compilation
##====================================
- name: Build Arturo (Linux/macOS/Web)
if: inputs.do == 'compile' && (env.os == 'linux' || env.os == 'macos' || env.os == 'web')
run: |
cd arturo-src
./build.nims --install --mode ${{ env.build_mode }} --arch ${{ env.arch }} --log${{ env.release == 'true' && ' --release' || '' }}
echo "$HOME/.arturo/bin" >> $GITHUB_PATH
echo "arturoDistPath=$HOME/.arturo/bin" >> $GITHUB_ENV
cd ..
rm -rf arturo-src
shell: bash
- name: Build Arturo (Windows)
if: inputs.do == 'compile' && env.os == 'windows'
run: |
export PATH="${{ github.workspace }}/nim/nim-2.2.8/bin":$PATH
cd arturo-src
./build.nims --install --mode ${{ env.mode }} --log${{ env.release == 'true' && ' --release' || '' }}
cd ..
mkdir bin
if [ "${{ env.mode }}" = "full" ]; then
cp arturo-src/src/extras/webview/deps/dlls/x64/webview.dll bin
cp arturo-src/src/extras/webview/deps/dlls/x64/WebView2Loader.dll bin
curl -L https://arturo-lang.s3.amazonaws.com/libgmp-10.dll -o bin/libgmp-10.dll
curl -L https://arturo-lang.s3.amazonaws.com/libmpfr-6.dll -o bin/libmpfr-6.dll
curl -L https://arturo-lang.s3.amazonaws.com/sqlite3_64.dll -o bin/sqlite3_64.dll
curl -L https://arturo-lang.s3.amazonaws.com/libgcc_s_seh-1.dll -o bin/libgcc_s_seh-1.dll
fi
curl -L https://curl.se/ca/cacert.pem -o bin/cacert.pem
cp /mingw64/bin/libwinpthread-1.dll bin
cp arturo-src/bin/arturo.exe bin
cp bin/* /usr/bin
rm -rf arturo-src
echo "arturoDistPath=${{ github.workspace }}/bin" >> $GITHUB_ENV
shell: msys2 {0}
##====================================
## Upload
##====================================
- name: Upload artifact
if: inputs.create_artifact == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.release-info.outputs.artifact_name || env.artifact_name }}
path: ${{ env.arturoDistPath }}/*
include-hidden-files: false