feat: el-install binary + SDK bundle release
This commit is contained in:
@@ -59,6 +59,46 @@ jobs:
|
||||
echo "gen3 (self-hosted) elc built"
|
||||
dist/platform/elc --version || true
|
||||
|
||||
# Build elb binary
|
||||
- name: Build elb
|
||||
run: |
|
||||
mkdir -p dist/bin
|
||||
dist/platform/elc elb.el > dist/elb.c
|
||||
gcc -O2 \
|
||||
-I el-compiler/runtime \
|
||||
dist/elb.c \
|
||||
el-compiler/runtime/el_runtime.c \
|
||||
-lcurl -lpthread \
|
||||
-o dist/bin/elb
|
||||
chmod +x dist/bin/elb
|
||||
echo "elb built"
|
||||
|
||||
# Build epm binary (epm lives at repo root, not inside lang/)
|
||||
- name: Build epm
|
||||
run: |
|
||||
dist/platform/elc ../epm/src/epm.el > dist/epm.c
|
||||
gcc -O2 \
|
||||
-I el-compiler/runtime \
|
||||
dist/epm.c \
|
||||
el-compiler/runtime/el_runtime.c \
|
||||
-lcurl -lpthread \
|
||||
-o dist/bin/epm
|
||||
chmod +x dist/bin/epm
|
||||
echo "epm built"
|
||||
|
||||
# Build el-install binary
|
||||
- name: Build el-install
|
||||
run: |
|
||||
dist/platform/elc tools/install/el-install.el > dist/el-install.c
|
||||
gcc -O2 \
|
||||
-I el-compiler/runtime \
|
||||
dist/el-install.c \
|
||||
el-compiler/runtime/el_runtime.c \
|
||||
-lcurl -lpthread \
|
||||
-o dist/bin/el-install
|
||||
chmod +x dist/bin/el-install
|
||||
echo "el-install built"
|
||||
|
||||
- name: Run tests — text
|
||||
run: |
|
||||
ELC="$(pwd)/dist/platform/elc" \
|
||||
@@ -83,8 +123,24 @@ jobs:
|
||||
EL_HOME="$(pwd)" \
|
||||
bash tests/html_sanitizer/run.sh
|
||||
|
||||
# Publish / update the `latest` release with the three SDK assets
|
||||
# Bundle the SDK tarball — runs from the repo root to reference lang/ paths correctly
|
||||
- name: Bundle SDK tarball
|
||||
working-directory: ${{ github.workspace }}
|
||||
run: |
|
||||
mkdir -p dist/sdk/bin dist/sdk/runtime
|
||||
cp lang/dist/platform/elc dist/sdk/bin/elc
|
||||
cp lang/dist/bin/elb dist/sdk/bin/elb
|
||||
cp lang/dist/bin/epm dist/sdk/bin/epm
|
||||
cp lang/el-compiler/runtime/el_runtime.c dist/sdk/runtime/
|
||||
cp lang/el-compiler/runtime/el_runtime.h dist/sdk/runtime/
|
||||
cp lang/runtime/*.el dist/sdk/runtime/
|
||||
tar -czf dist/el-sdk-latest.tar.gz -C dist/sdk .
|
||||
echo "SDK tarball bundled: dist/el-sdk-latest.tar.gz"
|
||||
ls -lh dist/el-sdk-latest.tar.gz
|
||||
|
||||
# Publish / update the `latest` release with all SDK assets
|
||||
- name: Publish latest release
|
||||
working-directory: ${{ github.workspace }}
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||
GITEA_API: https://git.neuralplatform.ai/api/v1
|
||||
@@ -130,9 +186,14 @@ jobs:
|
||||
"${GITEA_API}/repos/${REPO}/releases/${RELEASE_ID}/assets"
|
||||
}
|
||||
|
||||
upload_asset dist/platform/elc elc
|
||||
upload_asset el-compiler/runtime/el_runtime.c el_runtime.c
|
||||
upload_asset el-compiler/runtime/el_runtime.h el_runtime.h
|
||||
# Per-file assets (downstream CI needs these individually)
|
||||
upload_asset lang/dist/platform/elc elc
|
||||
upload_asset lang/el-compiler/runtime/el_runtime.c el_runtime.c
|
||||
upload_asset lang/el-compiler/runtime/el_runtime.h el_runtime.h
|
||||
|
||||
# SDK bundle and installer binary
|
||||
upload_asset dist/el-sdk-latest.tar.gz el-sdk-latest.tar.gz
|
||||
upload_asset lang/dist/bin/el-install el-install
|
||||
|
||||
echo "Release published successfully"
|
||||
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
// tools/install/el-install.el — El SDK installer
|
||||
//
|
||||
// Downloads and installs the El SDK from the latest Gitea release.
|
||||
//
|
||||
// Usage:
|
||||
// el-install # installs to ~/.el (default prefix)
|
||||
// el-install /opt/el # installs to custom prefix
|
||||
//
|
||||
// After installation, add to your shell rc:
|
||||
// export PATH="$HOME/.el/bin:$PATH"
|
||||
// export EL_HOME="$HOME/.el"
|
||||
|
||||
// ── Imports ───────────────────────────────────────────────────────────────────
|
||||
|
||||
import "../../runtime/string.el"
|
||||
import "../../runtime/env.el"
|
||||
import "../../runtime/fs.el"
|
||||
import "../../runtime/exec.el"
|
||||
import "../../runtime/json.el"
|
||||
import "../../runtime/http.el"
|
||||
|
||||
// ── Constants ─────────────────────────────────────────────────────────────────
|
||||
|
||||
fn gitea_releases_url() -> String {
|
||||
return "https://git.neuralplatform.ai/api/v1/repos/neuron-technologies/el/releases/tags/latest"
|
||||
}
|
||||
|
||||
fn sdk_asset_name() -> String {
|
||||
return "el-sdk-latest.tar.gz"
|
||||
}
|
||||
|
||||
// ── Helpers ───────────────────────────────────────────────────────────────────
|
||||
|
||||
// find_asset_url scans the Gitea release JSON for the asset named target_name
|
||||
// and returns its browser_download_url. Returns "" if not found.
|
||||
fn find_asset_url(release_json: String, target_name: String) -> String {
|
||||
let assets_raw: String = json_get_raw(release_json, "assets")
|
||||
if str_eq(assets_raw, "") {
|
||||
return ""
|
||||
}
|
||||
let n: Int = json_array_len(assets_raw)
|
||||
let i: Int = 0
|
||||
while i < n {
|
||||
let asset: String = json_array_get(assets_raw, i)
|
||||
let name: String = json_get(asset, "name")
|
||||
if str_eq(name, target_name) {
|
||||
return json_get(asset, "browser_download_url")
|
||||
}
|
||||
let i = i + 1
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ── Main ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
fn main() -> Void {
|
||||
// 1. Determine install prefix
|
||||
let argv: [String] = args()
|
||||
let home: String = env("HOME")
|
||||
|
||||
let prefix: String = home + "/.el"
|
||||
let argc: Int = el_list_len(argv)
|
||||
// argv[0] is the program name; argv[1] is the first user argument
|
||||
if argc > 1 {
|
||||
let first_arg: String = el_list_get(argv, 1)
|
||||
if !str_eq(first_arg, "") {
|
||||
let prefix = first_arg
|
||||
}
|
||||
}
|
||||
|
||||
let bin_dir: String = prefix + "/bin"
|
||||
let runtime_dir: String = prefix + "/runtime"
|
||||
|
||||
println("El SDK installer")
|
||||
println(" prefix : " + prefix)
|
||||
|
||||
// 2. Create directory structure
|
||||
let ok_bin: Bool = fs_mkdir(bin_dir)
|
||||
if !ok_bin {
|
||||
// fs_mkdir returns false if dir already exists on some impls; try exec
|
||||
exec("mkdir -p " + bin_dir)
|
||||
}
|
||||
let ok_rt: Bool = fs_mkdir(runtime_dir)
|
||||
if !ok_rt {
|
||||
exec("mkdir -p " + runtime_dir)
|
||||
}
|
||||
// Ensure both dirs exist via exec regardless
|
||||
exec("mkdir -p " + bin_dir + " " + runtime_dir)
|
||||
|
||||
// 3. Fetch release metadata from Gitea API
|
||||
println(" Fetching release metadata...")
|
||||
let release_json: String = http_get(gitea_releases_url())
|
||||
if str_eq(release_json, "") {
|
||||
println("Error: failed to fetch release metadata from Gitea")
|
||||
exit_program(1)
|
||||
}
|
||||
|
||||
// 4. Find the SDK tarball download URL
|
||||
let download_url: String = find_asset_url(release_json, sdk_asset_name())
|
||||
if str_eq(download_url, "") {
|
||||
println("Error: asset '" + sdk_asset_name() + "' not found in release")
|
||||
exit_program(1)
|
||||
}
|
||||
println(" Downloading " + sdk_asset_name() + "...")
|
||||
|
||||
// 5. Download tarball to a temp file
|
||||
let tmp_path: String = "/tmp/el-sdk-latest.tar.gz"
|
||||
let headers: Map<String, String> = {}
|
||||
let downloaded: Bool = http_get_to_file(download_url, headers, tmp_path)
|
||||
if !downloaded {
|
||||
println("Error: download failed")
|
||||
exit_program(1)
|
||||
}
|
||||
|
||||
// 6. Extract into prefix
|
||||
println(" Extracting to " + prefix + "...")
|
||||
let tar_cmd: String = "tar -xzf " + tmp_path + " -C " + prefix
|
||||
let tar_out: String = exec(tar_cmd)
|
||||
// Clean up temp file
|
||||
exec("rm -f " + tmp_path)
|
||||
|
||||
// 7. Make binaries executable
|
||||
exec("chmod +x " + bin_dir + "/*")
|
||||
|
||||
// 8. Print success and shell setup instructions
|
||||
println("")
|
||||
println("El SDK installed to " + prefix + " — add this to your shell rc:")
|
||||
println(" export PATH=\"$HOME/.el/bin:$PATH\"")
|
||||
println(" export EL_HOME=\"$HOME/.el\"")
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package "el-install" {
|
||||
version "0.1.0"
|
||||
description "El SDK installer"
|
||||
edition "2026"
|
||||
}
|
||||
|
||||
build {
|
||||
entry "el-install.el"
|
||||
}
|
||||
Reference in New Issue
Block a user