-
-
Notifications
You must be signed in to change notification settings - Fork 7
207 lines (173 loc) · 7.13 KB
/
forkrun_release.yml
File metadata and controls
207 lines (173 loc) · 7.13 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
name: Build forkrun_ring.so (multiarch) and update frun.bash
on:
push:
paths:
- 'forkrun_ring.c'
- 'META'
- '.github/workflows/forkrun_release.yml'
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
build:
name: Build (${{ matrix.arch }})
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.arch == 'riscv64' }}
strategy:
fail-fast: false
matrix:
include:
# x86_64: The Triple Build (v2, v3, v4)
- arch: x86_64
platform: linux/amd64
docker_image: fedora:latest
# We handle flags manually in the script for this one
# AArch64
- arch: aarch64
platform: linux/arm64
docker_image: fedora:latest
extra_flags: "-march=armv8-a+crc"
# PPC64LE
- arch: ppc64le
platform: linux/ppc64le
docker_image: fedora:latest
extra_flags: ""
# S390X
- arch: s390x
platform: linux/s390x
docker_image: fedora:latest
extra_flags: ""
# RISC-V 64
- arch: riscv64
platform: linux/riscv64
docker_image: fedorariscv/base:latest
extra_flags: ""
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Build in Docker (${{ matrix.arch }})
run: |
set -e
mkdir -p artifacts
# We pass variables into the Docker container via environment variables
docker run --rm \
-v $PWD:/src \
-w /src \
--platform=${{ matrix.platform }} \
-e TARGET_ARCH="${{ matrix.arch }}" \
-e EXTRA_FLAGS="${{ matrix.extra_flags }}" \
${{ matrix.docker_image }} \
bash -c '
# 1. Install Dependencies (Fedora/RHEL style)
dnf install -y @development-tools gcc make bash-devel git grep sed binutils || \
(apt-get update && apt-get install -y gcc make libbash-dev git grep sed binutils)
# 2. Extract Version from META
FR_VERSION="unknown"
if [ -f META ]; then
FR_VERSION=$(grep -E "^VERSION:" META | sed -E "s/^VERSION:[ \t]*//")
fi
echo "Compiling Version: $FR_VERSION"
# 3. Define Common Flags
OPT_FLAGS="-O3 -flto=auto -fno-strict-aliasing -fno-semantic-interposition -fomit-frame-pointer -fno-math-errno -ftree-loop-im -ftree-loop-ivcanon -fPIC -Wl,-O1 -Wl,--as-needed -Wl,-Bsymbolic -ldl"
WARN_FLAGS="-DNDEBUG -Wall -Wextra "
INCLUDES="-I/usr/include/bash -I/usr/include/bash/include -I/usr/include/bash/builtins "
DEFS=(
"-DSHELL"
"-DHAVE_CONFIG_H"
"-DBUILD_OS=\"Linux\""
"-DFORKRUN_RING_VERSION=\"$FR_VERSION\""
"-DCOMPILER_FLAGS=\"$OPT_FLAGS\""
)
# Function to build specific variant
build_variant() {
local arch_name="$1"
local march_flag="$2"
local out_file="artifacts/forkrun_ring.${arch_name}.so"
echo ">>> Building $arch_name..."
# Dynamic Arch Definition
local ARCH_DEF="-DBUILD_ARCH=\"$arch_name\""
gcc forkrun_ring.c \
$OPT_FLAGS $WARN_FLAGS $INCLUDES \
"${DEFS[@]}" "$ARCH_DEF" \
-shared \
$march_flag \
-o "$out_file"
strip --strip-unneeded "$out_file"
# SANITY CHECK: Try to enable and run version check
echo ">>> Testing loadable..."
enable -f "$out_file" ring_version && \
ring_version -a || exit 1
enable -d ring_version
}
# 4. Logic Branch based on Architecture
if [ "$TARGET_ARCH" == "x86_64" ]; then
# The Triple Build
build_variant "x86-64-v2" "-march=x86-64-v2"
build_variant "x86-64-v3" "-march=x86-64-v3"
build_variant "x86-64-v4" "-march=x86-64-v4"
else
# Single Build
build_variant "$TARGET_ARCH" "$EXTRA_FLAGS"
fi
ls -l artifacts/
'
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: forkrun-libs-${{ matrix.arch }}
path: artifacts/*.so
embed:
name: Embed Base64 into frun.bash
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all_artifacts
- name: Flatten Artifacts and Update frun.bash
shell: bash
run: |
set +e # Turn off exit-on-error
set +o pipefail # Turn off pipefail
# 1. Ensure target directory exists
mkdir -p ring_loadables/forkrun-libs
# 2. Move all downloaded .so files into the target directory, overwriting old ones
find all_artifacts -name "*.so" -exec mv -f {} ring_loadables/forkrun-libs/ \;
# 3. Source the updater and run it
# Assuming update_frun_base64.bash defines the function 'update_frun_base64'
cd ring_loadables
source update_frun_base64.bash
cd forkrun-libs
update_frun_base64 ../../frun.bash
# 4. Clean up downloaded artifacts to keep working tree clean for the PR
cd ../../
rm -rf all_artifacts
- name: Verify Final Script
shell: bash
run: |
# Sanity check: Does the script run and load on the runner?
. ./frun.bash && ring_version -a || echo 'WARNING: frun.bash may not have been properly updated' >&2
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "build: update embedded ring loadables"
title: "🤖 Auto-Build: Update Ring Loadables"
body: |
This PR updates the embedded `forkrun_ring` binaries.
Generated by GitHub Actions Run: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
**Architectures:**
- x86_64 (v2, v3, v4)
- aarch64, ppc64le, s390x, riscv64
# Append the run_id to guarantee a unique branch name every time!
branch: "auto-build/update-loadables-${{ github.run_id }}"
delete-branch: true