feat: remove obsolete CI workflows and update documentation for new CI structure
This commit is contained in:
80
.gitea/workflows/ci-chrome.yml
Normal file
80
.gitea/workflows/ci-chrome.yml
Normal file
@@ -0,0 +1,80 @@
|
||||
name: CI — Chrome
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
paths:
|
||||
- 'packages/chrome/**'
|
||||
- 'src/lib/**'
|
||||
- 'tests/**'
|
||||
- '.gitea/workflows/ci-chrome.yml'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'packages/chrome/**'
|
||||
- 'src/lib/**'
|
||||
- 'tests/**'
|
||||
- '.gitea/workflows/ci-chrome.yml'
|
||||
|
||||
jobs:
|
||||
chrome:
|
||||
name: Chrome — typecheck, test, build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install system deps
|
||||
run: apt-get update -qq && apt-get install -y git ca-certificates -qq
|
||||
|
||||
- name: Clone repository
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /tmp/lexai
|
||||
cd /tmp/lexai
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
|
||||
git checkout pr
|
||||
else
|
||||
git checkout ${{ gitea.sha }}
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefer-offline --no-audit --no-fund
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Prepare WXT types
|
||||
run: npx wxt prepare
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Typecheck
|
||||
run: npm run typecheck
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Unit tests
|
||||
run: npm test -- --run
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Verify output
|
||||
run: ls -la .output/chrome-mv3/
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Notify Success
|
||||
if: success()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=✅ LexAI CI Chrome Passed%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}"
|
||||
|
||||
- name: Notify Failure
|
||||
if: failure()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=❌ LexAI CI Chrome FAILED%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0Ahttps://git.juankibin.space/kibin/LexAI/actions"
|
||||
72
.gitea/workflows/ci-cli.yml
Normal file
72
.gitea/workflows/ci-cli.yml
Normal file
@@ -0,0 +1,72 @@
|
||||
name: CI — CLI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
paths:
|
||||
- 'packages/cli/**'
|
||||
- 'src/lib/**'
|
||||
- '.gitea/workflows/ci-cli.yml'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'packages/cli/**'
|
||||
- 'src/lib/**'
|
||||
- '.gitea/workflows/ci-cli.yml'
|
||||
|
||||
jobs:
|
||||
cli:
|
||||
name: CLI — typecheck, build, smoke
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install system deps
|
||||
run: apt-get update -qq && apt-get install -y git ca-certificates -qq
|
||||
|
||||
- name: Clone repository
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /tmp/lexai
|
||||
cd /tmp/lexai
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
|
||||
git checkout pr
|
||||
else
|
||||
git checkout ${{ gitea.sha }}
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefer-offline --no-audit --no-fund
|
||||
working-directory: /tmp/lexai/packages/cli
|
||||
|
||||
- name: Typecheck
|
||||
run: npm run typecheck
|
||||
working-directory: /tmp/lexai/packages/cli
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
working-directory: /tmp/lexai/packages/cli
|
||||
|
||||
- name: Smoke (help + list, no API key)
|
||||
run: |
|
||||
node out/cli.js --help
|
||||
node out/cli.js prompt --list
|
||||
working-directory: /tmp/lexai/packages/cli
|
||||
|
||||
- name: Notify Success
|
||||
if: success()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=✅ LexAI CI CLI Passed%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}"
|
||||
|
||||
- name: Notify Failure
|
||||
if: failure()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=❌ LexAI CI CLI FAILED%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0Ahttps://git.juankibin.space/kibin/LexAI/actions"
|
||||
70
.gitea/workflows/ci-vscode.yml
Normal file
70
.gitea/workflows/ci-vscode.yml
Normal file
@@ -0,0 +1,70 @@
|
||||
name: CI — VS Code
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
paths:
|
||||
- 'packages/vscode/**'
|
||||
- 'src/lib/**'
|
||||
- '.gitea/workflows/ci-vscode.yml'
|
||||
pull_request:
|
||||
branches: [main]
|
||||
paths:
|
||||
- 'packages/vscode/**'
|
||||
- 'src/lib/**'
|
||||
- '.gitea/workflows/ci-vscode.yml'
|
||||
|
||||
jobs:
|
||||
vscode:
|
||||
name: VS Code — typecheck, build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install system deps
|
||||
run: apt-get update -qq && apt-get install -y git ca-certificates -qq
|
||||
|
||||
- name: Clone repository
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /tmp/lexai
|
||||
cd /tmp/lexai
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
|
||||
git checkout pr
|
||||
else
|
||||
git checkout ${{ gitea.sha }}
|
||||
fi
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefer-offline --no-audit --no-fund
|
||||
working-directory: /tmp/lexai/packages/vscode
|
||||
|
||||
- name: Typecheck
|
||||
run: npm run typecheck
|
||||
working-directory: /tmp/lexai/packages/vscode
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
working-directory: /tmp/lexai/packages/vscode
|
||||
|
||||
- name: Verify output
|
||||
run: ls -la out/extension.js
|
||||
working-directory: /tmp/lexai/packages/vscode
|
||||
|
||||
- name: Notify Success
|
||||
if: success()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=✅ LexAI CI VS Code Passed%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}"
|
||||
|
||||
- name: Notify Failure
|
||||
if: failure()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=❌ LexAI CI VS Code FAILED%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0Ahttps://git.juankibin.space/kibin/LexAI/actions"
|
||||
@@ -1,100 +0,0 @@
|
||||
name: CI — Test & Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
test-and-build:
|
||||
name: Test & Build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 15
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install system deps
|
||||
run: apt-get update -qq && apt-get install -y zip curl git ca-certificates -qq
|
||||
|
||||
- name: Clone repository (triggering ref)
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git /tmp/lexai
|
||||
cd /tmp/lexai
|
||||
if [ "${{ gitea.event_name }}" = "pull_request" ]; then
|
||||
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
|
||||
git checkout pr
|
||||
else
|
||||
git checkout ${{ gitea.sha }}
|
||||
fi
|
||||
|
||||
- name: Install Chrome package dependencies
|
||||
run: npm ci --prefer-offline --no-audit --no-fund
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
# Generates .wxt/types (ImportMeta.env etc.) required by typecheck.
|
||||
- name: Prepare WXT types
|
||||
run: npx wxt prepare
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Type check
|
||||
run: npm run typecheck
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm test -- --run
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Build extension
|
||||
run: npm run build
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Verify build output
|
||||
run: ls -la .output/chrome-mv3/
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Package as ZIP
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
TS=$(date +%Y%m%d%H%M%S)
|
||||
VERSION=$(node -p "require('./package.json').version")-${SHA}-${TS}
|
||||
zip -r /tmp/lexai-chrome-mv3-${VERSION}.zip .output/chrome-mv3/
|
||||
echo "PACKAGE_VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
echo "✅ Packaged: lexai-chrome-mv3-${VERSION}.zip"
|
||||
working-directory: /tmp/lexai/packages/chrome
|
||||
|
||||
- name: Publish to Gitea Package Registry
|
||||
if: gitea.event_name == 'push'
|
||||
run: |
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X PUT \
|
||||
"${{ gitea.server_url }}/api/packages/kibin/generic/lexai-extension/${PACKAGE_VERSION}/lexai-chrome-mv3-${PACKAGE_VERSION}.zip" \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-T "/tmp/lexai-chrome-mv3-${PACKAGE_VERSION}.zip")
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -n 1)
|
||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||
echo "HTTP: $HTTP_CODE | Response: $BODY"
|
||||
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
|
||||
echo "✅ Published: https://git.juankibin.space/kibin/-/packages"
|
||||
else
|
||||
echo "⚠️ Package publish returned $HTTP_CODE: $BODY"
|
||||
exit 1
|
||||
fi
|
||||
env:
|
||||
PACKAGE_VERSION: ${{ env.PACKAGE_VERSION }}
|
||||
|
||||
- name: Notify Success
|
||||
if: success()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=✅ LexAI CI Passed%0A%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0A%0AAll steps green — new build published to packages."
|
||||
|
||||
- name: Notify Failure
|
||||
if: failure()
|
||||
run: |
|
||||
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=❌ LexAI CI FAILED%0A%0ABranch: ${{ gitea.ref_name }}%0ACommit: ${SHA}%0A%0ACheck: https://git.juankibin.space/kibin/LexAI/actions"
|
||||
@@ -1,132 +0,0 @@
|
||||
name: Deploy — Chrome Web Store
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
publish:
|
||||
description: 'Publish after upload? (yes/no)'
|
||||
required: false
|
||||
default: 'yes'
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Build & Deploy to Chrome Web Store
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install deps
|
||||
run: apt-get update -qq && apt-get install -y zip curl
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||
git checkout ${{ gitea.sha }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
working-directory: packages/chrome
|
||||
|
||||
# Same gates as CI — a release must never check less than a push.
|
||||
- name: Prepare WXT types
|
||||
run: npx wxt prepare
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Type check
|
||||
run: npm run typecheck
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Run tests
|
||||
run: npm test -- --run
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Build extension
|
||||
run: npm run build
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Package as ZIP
|
||||
run: |
|
||||
VERSION=${{ gitea.ref_name || 'manual' }}
|
||||
ZIPFILE="$(cd ../.. && pwd)/lexai-chrome-mv3-${VERSION}.zip"
|
||||
# Verify manifest exists and check version
|
||||
node -e "console.log('Manifest version:', require('./.output/chrome-mv3/manifest.json').version)"
|
||||
# Zip from inside the chrome-mv3 dir so manifest.json is at root
|
||||
cd .output/chrome-mv3 && zip -r "$ZIPFILE" . && cd -
|
||||
echo "ZIP_FILE=${ZIPFILE}" >> $GITHUB_ENV
|
||||
echo "VERSION=${VERSION}" >> $GITHUB_ENV
|
||||
echo "✅ Packaged: lexai-chrome-mv3-${VERSION}.zip"
|
||||
working-directory: packages/chrome
|
||||
|
||||
|
||||
- name: Get Chrome Web Store OAuth2 Token
|
||||
run: |
|
||||
TOKEN_RESPONSE=$(curl -s -X POST "https://oauth2.googleapis.com/token" \
|
||||
-d "client_id=${{ secrets.CWS_CLIENT_ID }}" \
|
||||
-d "client_secret=${{ secrets.CWS_CLIENT_SECRET }}" \
|
||||
-d "refresh_token=${{ secrets.CWS_REFRESH_TOKEN }}" \
|
||||
-d "grant_type=refresh_token")
|
||||
ACCESS_TOKEN=$(echo "$TOKEN_RESPONSE" | node -e "let s='';process.stdin.on('data',d=>s+=d);process.stdin.on('end',()=>{let d;try{d=JSON.parse(s)}catch(e){console.error('Invalid JSON token response:',s);process.exit(1)};if(!d.access_token){console.error('No access_token in response:',s);process.exit(1)};console.log(d.access_token)})")
|
||||
if [ -z "$ACCESS_TOKEN" ]; then
|
||||
echo "❌ Failed to get access token. Response: $TOKEN_RESPONSE"
|
||||
exit 1
|
||||
fi
|
||||
echo "CWS_ACCESS_TOKEN=${ACCESS_TOKEN}" >> $GITHUB_ENV
|
||||
echo "✅ OAuth2 token obtained"
|
||||
|
||||
- name: Upload to Chrome Web Store
|
||||
run: |
|
||||
UPLOAD_BODY=$(curl -s -X PUT \
|
||||
"https://www.googleapis.com/upload/chromewebstore/v1.1/items/${{ secrets.CWS_EXTENSION_ID }}" \
|
||||
-H "Authorization: Bearer ${{ env.CWS_ACCESS_TOKEN }}" \
|
||||
-H "x-goog-api-version: 2" \
|
||||
-T "${{ env.ZIP_FILE }}")
|
||||
echo "Upload Response: $UPLOAD_BODY"
|
||||
UPLOAD_STATE=$(echo "$UPLOAD_BODY" | node -e "let s='';process.stdin.on('data',d=>s+=d);process.stdin.on('end',()=>{let d;try{d=JSON.parse(s)}catch(e){console.error('Invalid JSON upload response:',s);process.exit(1)};console.log(d.uploadState||'')})")
|
||||
echo "Upload state: $UPLOAD_STATE"
|
||||
if [ "$UPLOAD_STATE" != "SUCCESS" ]; then
|
||||
echo "❌ Upload failed — state: $UPLOAD_STATE"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ Uploaded to Chrome Web Store"
|
||||
|
||||
- name: Publish to Chrome Web Store
|
||||
if: ${{ gitea.event_name == 'push' || github.event.inputs.publish == 'yes' }}
|
||||
run: |
|
||||
PUBLISH_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
"https://www.googleapis.com/chromewebstore/v1.1/items/${{ secrets.CWS_EXTENSION_ID }}/publish" \
|
||||
-H "Authorization: Bearer ${{ env.CWS_ACCESS_TOKEN }}" \
|
||||
-H "x-goog-api-version: 2" \
|
||||
-H "Content-Length: 0")
|
||||
HTTP_CODE=$(echo "$PUBLISH_RESPONSE" | tail -n 1)
|
||||
BODY=$(echo "$PUBLISH_RESPONSE" | sed '$d')
|
||||
echo "Publish HTTP: $HTTP_CODE"
|
||||
echo "Publish Response: $BODY"
|
||||
STATUS=$(echo "$BODY" | grep -o '"status":\["[^"]*"\]' | head -1)
|
||||
echo "Publish status: $STATUS"
|
||||
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
|
||||
echo "✅ Published to Chrome Web Store!"
|
||||
else
|
||||
echo "❌ Publish failed: HTTP $HTTP_CODE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Notify Success
|
||||
if: success()
|
||||
run: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=🚀 LexAI ${VERSION} deployed to Chrome Web Store!%0A%0A✅ Built%0A✅ Packaged%0A✅ Uploaded%0A✅ Published%0A%0Ahttps://chromewebstore.google.com/detail/${{ secrets.CWS_EXTENSION_ID }}"
|
||||
|
||||
- name: Notify Failure
|
||||
if: failure()
|
||||
run: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \
|
||||
-d "chat_id=${{ secrets.TELEGRAM_CHAT_ID }}" \
|
||||
-d "text=❌ LexAI CWS Deploy FAILED%0A%0AVersion: ${VERSION}%0A%0ACheck: https://git.juankibin.space/kibin/LexAI/actions"
|
||||
@@ -1,53 +0,0 @@
|
||||
name: Preview — PR Build Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
preview-build:
|
||||
name: PR Preview Build
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install zip curl
|
||||
run: apt-get update -qq && apt-get install -y zip curl
|
||||
|
||||
- name: Checkout PR
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
|
||||
git checkout pr
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Type check
|
||||
run: npm run typecheck
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm test -- --run
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Build extension
|
||||
run: npm run build
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Package preview ZIP
|
||||
run: |
|
||||
PR_NUM=${{ gitea.event.pull_request.number }}
|
||||
zip -r ../../lexai-pr-${PR_NUM}-preview.zip .output/chrome-mv3/
|
||||
echo "✅ PR #${PR_NUM} build successful"
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Comment on PR
|
||||
run: |
|
||||
PR_NUM=${{ gitea.event.pull_request.number }}
|
||||
curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/${PR_NUM}/comments" \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"body\": \"## ⚡ LexAI Preview Build Ready\n\n✅ Tests passed\n✅ Build successful\n✅ TypeScript clean\n\nCommit: \`${{ gitea.sha }}\`\"}"
|
||||
@@ -1,102 +0,0 @@
|
||||
name: Release — Package & Publish
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Build & Package Release
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
|
||||
steps:
|
||||
- name: Install zip
|
||||
run: apt-get update -qq && apt-get install -y zip curl
|
||||
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
|
||||
git checkout ${{ gitea.sha }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Run tests
|
||||
run: npm test -- --run
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Build extension
|
||||
run: npm run build
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Package as ZIP
|
||||
run: |
|
||||
VERSION=${{ gitea.ref_name }}
|
||||
ZIPFILE="$(cd ../.. && pwd)/lexai-chrome-mv3-${VERSION}.zip"
|
||||
# Zip from inside the chrome-mv3 dir so manifest.json is at root of the archive
|
||||
cd .output/chrome-mv3 && zip -r "$ZIPFILE" . && cd -
|
||||
echo "ZIP_FILE=${ZIPFILE}" >> $GITHUB_ENV
|
||||
working-directory: packages/chrome
|
||||
|
||||
- name: Create Release
|
||||
run: |
|
||||
VERSION=${{ gitea.ref_name }}
|
||||
cat > build-release-payload.js <<'EOF'
|
||||
const fs = require('fs');
|
||||
const tag = process.env.VERSION;
|
||||
const version = tag.replace(/^v/, '');
|
||||
const installSteps = '### Installation\n1. Download ZIP below\n2. Extract it\n3. Open Chrome → chrome://extensions\n4. Enable Developer Mode\n5. Click Load unpacked → select the extracted folder';
|
||||
let body = '## LexAI ' + tag + '\n\n' + installSteps;
|
||||
try {
|
||||
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
|
||||
const headingRe = new RegExp('^## \\[' + version.replace(/\./g, '\\.') + '\\].*$', 'm');
|
||||
const match = headingRe.exec(changelog);
|
||||
if (match) {
|
||||
const rest = changelog.slice(match.index + match[0].length);
|
||||
const nextStop = rest.search(/^(## \[|\[[^\]]+\]:\s)/m);
|
||||
const section = (nextStop === -1 ? rest : rest.slice(0, nextStop)).trim();
|
||||
body = match[0] + '\n\n' + section + '\n\n' + installSteps;
|
||||
} else {
|
||||
console.error('No CHANGELOG.md section found for ' + version + ', falling back to generic body');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Could not read CHANGELOG.md, falling back to generic body:', e.message);
|
||||
}
|
||||
const payload = {
|
||||
tag_name: tag,
|
||||
name: 'LexAI ' + tag,
|
||||
body,
|
||||
draft: false,
|
||||
prerelease: false,
|
||||
};
|
||||
fs.writeFileSync('payload.json', JSON.stringify(payload));
|
||||
EOF
|
||||
VERSION="$VERSION" node build-release-payload.js
|
||||
curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d @payload.json > release.json
|
||||
cat release.json
|
||||
RELEASE_ID=$(node -e "const r=require('./release.json'); if(!r.id) { console.error('No release id in response:', JSON.stringify(r)); process.exit(1); } console.log(r.id)")
|
||||
echo "RELEASE_ID=${RELEASE_ID}" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload ZIP to Release
|
||||
run: |
|
||||
RELEASE_ID=${{ env.RELEASE_ID }}
|
||||
curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-F "attachment=@${{ env.ZIP_FILE }}"
|
||||
echo "✅ Release ${{ gitea.ref_name }} published!"
|
||||
|
||||
- name: Publish to Gitea Package Registry
|
||||
run: |
|
||||
VERSION=${{ gitea.ref_name }}
|
||||
curl -s -X PUT "https://git.juankibin.space/api/packages/kibin/generic/lexai-extension/${VERSION}/lexai-chrome-mv3-${VERSION}.zip" \
|
||||
-H "Authorization: token ${{ secrets.GITEATOKEN }}" \
|
||||
-T "${{ env.ZIP_FILE }}"
|
||||
echo "✅ Published lexai-chrome-mv3-${VERSION}.zip to package registry"
|
||||
echo "📦 Download: https://git.juankibin.space/kibin/LexAI/packages"
|
||||
Reference in New Issue
Block a user