Fix/prod build (#51)

* chore: add CI secrets management and local testing script

- Added ci-secrets.example.json to provide a template for CI secrets configuration.
- Introduced test-ci-local.sh script to facilitate local testing of the package-and-publish workflow using act.
- Updated .gitignore to exclude the actual ci-secrets.json file containing sensitive tokens.

* chore: enhance local testing and environment loading scripts

- Added scripts to load environment variables from .env and JSON files, improving local development setup.
- Introduced ci-event.json to simulate GitHub event payloads for local CI testing.
- Updated test-ci-local.sh to utilize the new event JSON for better integration with local testing workflows.
- Modified .gitignore to include ci-secrets.local.json for local secret management.

* chore: enhance environment loading and improve V8 memory management

- Updated load-env.sh to conditionally load ci-secrets.local.json and set APPLE_PASSWORD for notarization.
- Introduced a delay in auto-starting skills to prevent memory spikes during initialization.
- Adjusted V8 runtime memory settings to minimize initial heap allocation, reducing the risk of OOM errors.

* chore: update version bump workflow to modify tauri.conf.json

- Changed the version update process to reflect changes in tauri.conf.json instead of Cargo.toml.
- Adjusted the commit message to indicate the inclusion of tauri.conf.json in the version bump process.

* chore: migrate from V8 to QuickJS runtime and update related configurations

- Replaced V8 runtime references with QuickJS throughout the codebase, including updates to initialization and error handling.
- Modified package.json to change the build command for macOS to source environment variables correctly.
- Updated Cargo.toml to remove deno_core dependency and include rquickjs with appropriate features.
- Cleaned up unused V8-related code and comments in the runtime modules.
- Adjusted skill manifest checks to support QuickJS compatibility.

* refactor: implement QuickJS runtime and remove V8 references

- Replaced V8 engine with QuickJS in the runtime module, updating related imports and initialization logic.
- Introduced new `qjs_engine.rs` and `qjs_skill_instance.rs` files to handle QuickJS-specific functionality.
- Removed the deprecated `v8_skill_instance.rs` and associated V8-related code.
- Updated JavaScript bootstrap code to align with QuickJS operations and APIs.
- Adjusted documentation and comments to reflect the transition to QuickJS.

* refactor: update IdbStorage to use parking_lot::Mutex for improved concurrency

- Changed the connection management in IdbStorage from RwLock to parking_lot::Mutex for better performance.
- Updated related methods to reflect the new locking mechanism, enhancing the efficiency of database operations.
- Adjusted the IdbOpenResult struct to include serde::Serialize for potential serialization needs.

* refactor: update QuickJS skill instance and timer management

- Modified memory limit and stack size settings in QjsSkillInstance to be asynchronous, improving performance.
- Cleaned up imports in qjs_ops.rs by removing unused dependencies and enhancing function definitions for clarity.
- Refactored timer management functions for better readability and efficiency, including renaming and restructuring comments.

* chore: update package.json scripts and clean up build.rs

- Added a new script for running the Tauri app with environment variable loading.
- Simplified the macOS development command to use a dedicated build script.
- Removed unnecessary environment variable logging from build.rs to streamline the build process.
- Cleaned up commented-out sections in the GitHub Actions workflow for Android packaging.
This commit is contained in:
Steven Enamakel
2026-02-05 19:29:21 +05:30
committed by GitHub
parent 29d62544d6
commit ceb03fb2bc
32 changed files with 2010 additions and 2985 deletions
+16
View File
@@ -0,0 +1,16 @@
{
"ref": "refs/heads/develop",
"before": "0000000000000000000000000000000000000000",
"after": "19281e16457e7c8ff8e6bda6ceda77f0880d10d2",
"repository": {
"full_name": "vezuresdotxyz/alphahuman-frontend-runner",
"default_branch": "main",
"name": "alphahuman-frontend-runner",
"owner": { "login": "vezuresdotxyz" }
},
"head_commit": {
"id": "19281e16457e7c8ff8e6bda6ceda77f0880d10d2",
"message": "local test build"
},
"sender": { "login": "local-dev" }
}
+28
View File
@@ -0,0 +1,28 @@
{
"secrets": {
"XGH_TOKEN": "",
"GITHUB_TOKEN": "",
"UPDATER_GIST_URL": "",
"UPDATER_GIST_ID": "",
"UPDATER_PUBLIC_KEY": "",
"UPDATER_PRIVATE_KEY": "",
"UPDATER_PRIVATE_KEY_PASSWORD": "",
"APPLE_CERTIFICATE_BASE64": "",
"APPLE_CERTIFICATE_PASSWORD": "",
"APPLE_SIGNING_IDENTITY": "",
"APPLE_ID": "",
"APPLE_APP_SPECIFIC_PASSWORD": "",
"APPLE_TEAM_ID": "",
"VITE_TELEGRAM_BOT_USERNAME": "",
"VITE_TELEGRAM_BOT_ID": "",
"VITE_TELEGRAM_API_ID": "",
"VITE_TELEGRAM_API_HASH": "",
"VITE_SENTRY_DSN": ""
},
"vars": {
"BASE_URL": "https://localhost",
"VITE_BACKEND_URL": "https://localhost:5005",
"VITE_SKILLS_GITHUB_REPO": "",
"VITE_DEBUG": "true"
}
}
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Load .env file into environment variables.
# Usage:
# source scripts/load-dotenv.sh [path/to/.env]
# eval "$(scripts/load-dotenv.sh [path/to/.env])"
# Default path: .env (project root when run from repo root)
set -e
FILE="${1:-.env}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
RESOLVED="${1:+$1}"
RESOLVED="${RESOLVED:-$ROOT_DIR/.env}"
if [[ ! -f "$RESOLVED" ]]; then
echo "File not found: $RESOLVED" >&2
exit 1
fi
exports=()
while IFS= read -r line || [[ -n "$line" ]]; do
line="${line%%#*}"
line="${line#"${line%%[![:space:]]*}"}"
line="${line%"${line##*[![:space:]]}"}"
[[ -z "$line" ]] && continue
if [[ "$line" == export\ * ]]; then
line="${line#export }"
fi
if [[ "$line" == *"="* ]]; then
key="${line%%=*}"
key="${key%"${key##*[![:space:]]}"}"
value="${line#*=}"
value="${value#\"}"
value="${value%\"}"
value="${value#\'}"
value="${value%\'}"
[[ -n "$key" ]] && exports+=("$(printf 'export %s=%q' "$key" "$value")")
fi
done < "$RESOLVED"
joined=$(printf '%s\n' "${exports[@]}")
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "$joined"
else
eval "$joined"
fi
+29
View File
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
# Load key-value JSON into environment variables.
# Usage:
# source scripts/load-env-json.sh path/to/file.json
# eval "$(scripts/load-env-json.sh path/to/file.json)"
# Optional jq filter to select object (default: .):
# source scripts/load-env-json.sh ci-secrets.json '.secrets + .vars'
set -e
FILE="${1:?Usage: $0 <file.json> [jq-filter]}"
FILTER="${2:-.}"
if [[ ! -f "$FILE" ]]; then
echo "File not found: $FILE" >&2
exit 1
fi
if ! command -v jq &>/dev/null; then
echo "jq is required" >&2
exit 1
fi
exports=$(jq -r "${FILTER} | to_entries | .[] | \"export \(.key)=\(.value | @sh)\"" "$FILE")
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
echo "$exports"
else
eval "$exports"
fi
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Load .env file into environment variables and optional ci-secrets for signing/notarization.
# Usage:
# source scripts/load-env.sh
# eval "$(scripts/load-env.sh)"
set -e
source scripts/load-dotenv.sh
if [[ -f scripts/ci-secrets.local.json ]]; then
source scripts/load-env-json.sh scripts/ci-secrets.local.json
# Tauri notarization expects APPLE_PASSWORD; secrets file uses APPLE_APP_SPECIFIC_PASSWORD
if [[ -z "${APPLE_PASSWORD:-}" && -n "${APPLE_APP_SPECIFIC_PASSWORD:-}" ]]; then
export APPLE_PASSWORD="$APPLE_APP_SPECIFIC_PASSWORD"
fi
fi
+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env bash
# Test the package-and-publish workflow locally using `act`.
#
# Prerequisites:
# brew install act jq
#
# Setup:
# cp scripts/ci-secrets.example.json scripts/ci-secrets.json
# # Edit scripts/ci-secrets.json with your real values
#
# Usage:
# ./scripts/test-ci-local.sh # Run full workflow via act
# ./scripts/test-ci-local.sh --manual # Run build steps natively on macOS (recommended)
# ./scripts/test-ci-local.sh --list # List available jobs
# ./scripts/test-ci-local.sh --dryrun # Dry-run (show what would execute)
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
# ── Configuration ─────────────────────────────────────────────────────────────
WORKFLOW=".github/workflows/package-and-publish.yml"
SECRETS_JSON="scripts/ci-secrets.json"
EVENT_JSON="scripts/ci-event.json"
if [[ ! -f "$SECRETS_JSON" ]]; then
echo "ERROR: $SECRETS_JSON not found."
echo ""
echo "Create it from the example:"
echo " cp scripts/ci-secrets.example.json scripts/ci-secrets.json"
echo " # then fill in your values"
exit 1
fi
# ── Generate event payload with current HEAD ──────────────────────────────────
CURRENT_REF=$(git rev-parse HEAD)
cat > "$EVENT_JSON" <<EOF
{
"ref": "refs/heads/develop",
"before": "0000000000000000000000000000000000000000",
"after": "$CURRENT_REF",
"repository": {
"full_name": "vezuresdotxyz/alphahuman-frontend-runner",
"default_branch": "main",
"name": "alphahuman-frontend-runner",
"owner": { "login": "vezuresdotxyz" }
},
"head_commit": {
"id": "$CURRENT_REF",
"message": "local test build"
},
"sender": { "login": "local-dev" }
}
EOF
# ── Convert JSON to act-compatible KEY=VALUE files ────────────────────────────
SECRETS_FILE=$(mktemp)
VARS_FILE=$(mktemp)
trap 'rm -f "$SECRETS_FILE" "$VARS_FILE"' EXIT
# Extract "secrets" object → KEY=VALUE
jq -r '.secrets // {} | to_entries[] | "\(.key)=\(.value)"' "$SECRETS_JSON" > "$SECRETS_FILE"
# Extract "vars" object → KEY=VALUE
jq -r '.vars // {} | to_entries[] | "\(.key)=\(.value)"' "$SECRETS_JSON" > "$VARS_FILE"
echo "Loaded $(wc -l < "$SECRETS_FILE" | tr -d ' ') secrets and $(wc -l < "$VARS_FILE" | tr -d ' ') vars from $SECRETS_JSON"
# ── Common act arguments ──────────────────────────────────────────────────────
ACT_ARGS=(
-W "$WORKFLOW"
--secret-file "$SECRETS_FILE"
--var-file "$VARS_FILE"
--eventpath "$EVENT_JSON"
-P ubuntu-latest=catthehacker/ubuntu:act-latest
-P macos-latest=-self-hosted
)
# ── Handle CLI flags ──────────────────────────────────────────────────────────
if [[ "${1:-}" == "--list" ]]; then
echo "Available jobs in $WORKFLOW:"
act -W "$WORKFLOW" --list
exit 0
fi
if [[ "${1:-}" == "--dryrun" ]]; then
echo "Dry-run of workflow:"
act push "${ACT_ARGS[@]}" -n
exit 0
fi
# ── Manual macOS-native build (recommended) ───────────────────────────────────
if [[ "${1:-}" == "--manual" ]]; then
echo "=== Running build steps manually on macOS host ==="
echo ""
# Export VITE_* vars from the JSON so the frontend build picks them up
eval "$(jq -r '
(.secrets // {}) + (.vars // {})
| to_entries[]
| select(.key | startswith("VITE_"))
| "export \(.key)=\(.value | @sh)"
' "$SECRETS_JSON")"
# Step 1: Ensure OpenSSL is installed
echo ">>> Step 1: Ensure OpenSSL is installed"
brew install openssl@3 2>/dev/null || true
# Step 2: Install Node dependencies
echo ">>> Step 2: Install Node dependencies"
yarn install --frozen-lockfile
# Step 3: Install skills dependencies and build
echo ">>> Step 3: Build skills"
(cd skills && yarn install --frozen-lockfile && yarn build)
# Step 4: Build frontend
echo ">>> Step 4: Build frontend"
NODE_ENV=production yarn build
# Step 5: Build Tauri (aarch64)
echo ">>> Step 5: Build Tauri app (aarch64-apple-darwin)"
yarn tauri build --target aarch64-apple-darwin
echo ""
echo "=== Build complete ==="
echo "Check src-tauri/target/aarch64-apple-darwin/release/bundle/ for output"
exit 0
fi
# ── Default: run full workflow with act ────────────────────────────────────────
#
# We run the full workflow (not -j single-job) so act executes the dependency
# chain: get-version → check-version → create-release (skipped) → package-tauri.
# Using -j package-tauri alone fails because act can't resolve outputs from
# skipped `needs` jobs.
echo "=== Testing package-and-publish workflow locally ==="
echo ""
echo "Workflow: $WORKFLOW"
echo "Event: push to develop (from $EVENT_JSON)"
echo ""
echo "NOTE: act uses Docker containers — macOS-specific steps won't work."
echo "For a native macOS build, use: $0 --manual"
echo ""
act push "${ACT_ARGS[@]}" --verbose