diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..1c3f49d --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,169 @@ +name: El UI Release + +on: + push: + branches: + - main + repository_dispatch: + types: + - el-sdk-updated + +jobs: + build-and-release: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install build dependencies + run: | + apt-get update -qq + apt-get install -y gcc libcurl4-openssl-dev + + # Install El SDK — try GCP Artifact Registry prod first, fall back to Gitea release + - name: Install El SDK + env: + GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} + RELEASE_BASE: https://git.neuralplatform.ai/neuron-technologies/el/releases/download/latest + run: | + echo "${GCP_SA_KEY}" > /tmp/gcp-key.json + apt-get install -y -qq apt-transport-https ca-certificates gnupg curl + curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg + echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list + apt-get update -qq && apt-get install -y google-cloud-cli + gcloud auth activate-service-account --key-file=/tmp/gcp-key.json + gcloud config set project neuron-785695 + + mkdir -p /usr/local/bin /usr/local/lib/el + + LATEST_VERSION=$(gcloud artifacts versions list \ + --repository=foundation-prod \ + --location=us-central1 \ + --project=neuron-785695 \ + --package=el/elc \ + --format="value(name)" 2>/dev/null | sort | tail -1 | sed 's|.*/||' || true) + + if [ -n "${LATEST_VERSION}" ]; then + gcloud artifacts generic download \ + --repository=foundation-prod \ + --location=us-central1 \ + --project=neuron-785695 \ + --package=el/elc \ + --version="${LATEST_VERSION}" \ + --destination=/usr/local/bin/elc + chmod +x /usr/local/bin/elc + else + echo "Falling back to Gitea latest release..." + curl -fsSL "${RELEASE_BASE}/elc" -o /usr/local/bin/elc + chmod +x /usr/local/bin/elc + fi + + curl -fsSL "${RELEASE_BASE}/el_runtime.c" -o /usr/local/lib/el/el_runtime.c + curl -fsSL "${RELEASE_BASE}/el_runtime.h" -o /usr/local/lib/el/el_runtime.h + + echo "El SDK installed:"; elc --version || true + rm -f /tmp/gcp-key.json + + # Build el-platform vessel (foundation layer for all el-ui vessels) + - name: Build el-platform vessel + run: | + mkdir -p dist + elc vessels/el-platform/src/main.el > dist/el-platform.c + cc -std=c11 -O2 \ + -I /usr/local/lib/el \ + -o dist/el-platform \ + dist/el-platform.c \ + /usr/local/lib/el/el_runtime.c \ + -lcurl -lpthread + chmod +x dist/el-platform + echo "Built dist/el-platform" + ls -lh dist/el-platform + + - name: Run tests + run: | + if [ -f spec/run.sh ]; then + ELC=/usr/local/bin/elc bash spec/run.sh + elif [ -f tests/run.sh ]; then + ELC=/usr/local/bin/elc bash tests/run.sh + else + echo "No spec/run.sh or tests/run.sh — skipping" + fi + + # Publish / update the `latest` release + - name: Publish latest release + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_API: https://git.neuralplatform.ai/api/v1 + REPO: neuron-technologies/el-ui + run: | + EXISTING_ID=$(curl -sf \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/repos/${REPO}/releases/tags/latest" \ + | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['id'])" 2>/dev/null || true) + + if [ -n "${EXISTING_ID}" ]; then + echo "Deleting existing release id=${EXISTING_ID}" + curl -sf -X DELETE \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/repos/${REPO}/releases/${EXISTING_ID}" + fi + + curl -sf -X DELETE \ + -H "Authorization: token ${GITEA_TOKEN}" \ + "${GITEA_API}/repos/${REPO}/tags/latest" || true + + RELEASE_ID=$(curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_API}/repos/${REPO}/releases" \ + -d "{ + \"tag_name\": \"latest\", + \"name\": \"El UI (latest)\", + \"body\": \"Latest El UI build from commit ${GITHUB_SHA}.\nBuilt $(date -u +%Y-%m-%dT%H:%M:%SZ).\", + \"draft\": false, + \"prerelease\": false + }" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") + + echo "Created release id=${RELEASE_ID}" + + curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -F "attachment=@dist/el-platform;filename=el-platform" \ + "${GITEA_API}/repos/${REPO}/releases/${RELEASE_ID}/assets" + + echo "Release published successfully" + + # Publish artifact to GCP Artifact Registry (prod) + - name: Publish el-platform to Artifact Registry (prod) + env: + GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} + run: | + echo "${GCP_SA_KEY}" > /tmp/gcp-key.json + gcloud auth activate-service-account --key-file=/tmp/gcp-key.json + gcloud config set project neuron-785695 + + VERSION="${GITEA_SHA:0:8}" + gcloud artifacts generic upload \ + --repository=foundation-prod \ + --location=us-central1 \ + --project=neuron-785695 \ + --package=el-ui/el-platform \ + --version="${VERSION}" \ + --source=dist/el-platform + + echo "Published el-platform version=${VERSION} to foundation-prod/el-ui/el-platform" + rm -f /tmp/gcp-key.json + + # Dispatch ui-updated to downstream dependents + - name: Dispatch ui-updated to el-ide + env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + GITEA_API: https://git.neuralplatform.ai/api/v1 + run: | + curl -sf -X POST \ + -H "Authorization: token ${GITEA_TOKEN}" \ + -H "Content-Type: application/json" \ + "${GITEA_API}/repos/neuron-technologies/el-ide/dispatches" \ + -d "{\"type\":\"ui-updated\",\"inputs\":{\"ui_version\":\"latest\",\"commit\":\"${GITHUB_SHA}\"}}" + echo "Dispatched ui-updated to neuron-technologies/el-ide"