Skip to content

armgit / bla

Public Imported from GitHub
0

🛡️ BLA (Blind LLM Agents) — Adversarial defense shield that protects binaries, Electron apps, JS bundles, Python, and WebAssembly against AI reverse-engineering agents like REA. Poison -> Exhaust -> Hallucinate.

ci(release): bind qybaihe/bla to automated npm publishing and version sync

qybaihe986eedabf5d1
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 5cf2c28..0c89f18 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -2,33 +2,35 @@ name: Release bla-agents
on:
push:
+ branches:
+ - main
tags:
- "bla-agents-*"
- "v*"
workflow_dispatch:
inputs:
- version:
- description: "Release version (e.g. 1.1.0)"
- required: true
- default: "1.1.0"
- type: string
- publish_npm:
- description: "Publish bla-agents to npm (requires NPM_TOKEN secret)"
+ bump:
+ description: "Optional version bump before publishing (none | patch | minor | major)"
required: false
- default: true
- type: boolean
+ default: "none"
+ type: choice
+ options:
+ - none
+ - patch
+ - minor
+ - major
permissions:
contents: write
id-token: write
concurrency:
- group: release-${{ github.ref_name }}
+ group: release-bla-agents
cancel-in-progress: false
jobs:
release:
- name: Build, Verify & Publish Release (bla-agents)
+ name: Build, Verify & Auto-Publish bla-agents to npm
runs-on: ubuntu-latest
steps:
- name: Checkout repository
@@ -46,7 +48,34 @@ jobs:
- name: Install dependencies
run: npm ci
+ - name: Optional version bump (on workflow_dispatch)
+ if: ${{ github.event_name == 'workflow_dispatch' && inputs.bump != 'none' && inputs.bump != '' }}
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ npm version "${{ inputs.bump }}" --no-git-tag-version
+ node scripts/sync-version.mjs
+ VERSION=$(node -p "require('./package.json').version")
+ git add package.json package-lock.json src/identity.ts
+ git commit -m "chore(release): bump bla-agents to v${VERSION}"
+ git push origin HEAD:main
+
+ - name: Check if current package.json version is already on npm
+ id: check_npm
+ run: |
+ LOCAL_VERSION=$(node -p "require('./package.json').version")
+ NPM_VERSION=$(npm view bla-agents version 2>/dev/null || echo "none")
+ echo "local_version=$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
+ echo "npm_version=$NPM_VERSION" >> "$GITHUB_OUTPUT"
+ echo "tag=bla-agents-$LOCAL_VERSION" >> "$GITHUB_OUTPUT"
+ if [ "$LOCAL_VERSION" != "$NPM_VERSION" ] || [ "${{ github.event_name }}" = "workflow_dispatch" ] || [[ "${{ github.ref }}" == refs/tags/* ]]; then
+ echo "should_publish=true" >> "$GITHUB_OUTPUT"
+ else
+ echo "should_publish=false" >> "$GITHUB_OUTPUT"
+ fi
+
- name: Run full verification gates (typecheck, build, test, 8-target benchmark)
+ if: steps.check_npm.outputs.should_publish == 'true'
run: |
npm run typecheck
npm run build
@@ -54,24 +83,20 @@ jobs:
npm run benchmark
- name: Package bla-agents release artifact
- id: pack
+ if: steps.check_npm.outputs.should_publish == 'true'
run: |
- VERSION=$(node -p "require('./package.json').version")
- echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- echo "tag=bla-agents-$VERSION" >> "$GITHUB_OUTPUT"
mkdir -p release-assets
-
npm pack --pack-destination release-assets
-
cd release-assets
shasum -a 256 *.tgz > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Create or update GitHub Release
+ if: steps.check_npm.outputs.should_publish == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- TAG: ${{ steps.pack.outputs.tag }}
- VERSION: ${{ steps.pack.outputs.version }}
+ TAG: ${{ steps.check_npm.outputs.tag }}
+ VERSION: ${{ steps.check_npm.outputs.local_version }}
run: |
if ! git rev-parse "$TAG" >/dev/null 2>&1; then
git tag "$TAG"
@@ -85,9 +110,14 @@ jobs:
--generate-notes
fi
- - name: Publish bla-agents to npm (if NPM_TOKEN is configured)
- if: ${{ (inputs.publish_npm != false) && env.NODE_AUTH_TOKEN != '' }}
+ - name: Publish bla-agents to npm (Trusted Publishing OIDC or NPM_TOKEN)
+ if: steps.check_npm.outputs.should_publish == 'true'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
- npm publish --provenance --access public
+ LOCAL_VERSION="${{ steps.check_npm.outputs.local_version }}"
+ if npm view "bla-agents@${LOCAL_VERSION}" version >/dev/null 2>&1; then
+ echo "bla-agents@${LOCAL_VERSION} is already published on npm."
+ else
+ npm publish --provenance --access public || npm publish --access public
+ fi
diff --git a/package.json b/package.json
index d4555dc..f3b87f0 100644
--- a/package.json
+++ b/package.json
@@ -58,12 +58,15 @@
"node": "^22.13.0 || >=24.0.0"
},
"scripts": {
- "build": "tsc -p tsconfig.build.json && chmod +x dist/cli.js",
+ "build": "node scripts/sync-version.mjs && tsc -p tsconfig.build.json && chmod +x dist/cli.js",
"dev": "tsx src/cli.ts",
"test": "vitest run",
"test:watch": "vitest",
"typecheck": "tsc --noEmit",
"benchmark": "node dist/cli.js benchmark",
+ "version": "node scripts/sync-version.mjs && git add src/identity.ts",
+ "release:patch": "npm version patch -m 'chore(release): bla-agents v%s' && git push --follow-tags",
+ "release:minor": "npm version minor -m 'chore(release): bla-agents v%s' && git push --follow-tags",
"prepublishOnly": "npm run build && npm test"
},
"dependencies": {
diff --git a/scripts/sync-version.mjs b/scripts/sync-version.mjs
new file mode 100644
index 0000000..9fd6512
--- /dev/null
+++ b/scripts/sync-version.mjs
@@ -0,0 +1,23 @@
+#!/usr/bin/env node
+import { readFileSync, writeFileSync } from "node:fs";
+import { resolve } from "node:path";
+
+const root = resolve(import.meta.dirname, "..");
+const pkgPath = resolve(root, "package.json");
+const identityPath = resolve(root, "src/identity.ts");
+
+const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
+const version = String(pkg.version);
+
+const identityText = readFileSync(identityPath, "utf8");
+const updated = identityText.replace(
+ /version:\s*"[^"]+"/,
+ `version: "${version}"`,
+);
+
+if (updated !== identityText) {
+ writeFileSync(identityPath, updated, "utf8");
+ console.log(`Synced BLA_IDENTITY.version -> ${version}`);
+} else {
+ console.log(`BLA_IDENTITY.version already at ${version}`);
+}