79 lines
2.8 KiB
YAML
79 lines
2.8 KiB
YAML
name: CI — Test & Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
test-and-build:
|
|
name: Test & Build
|
|
runs-on: ubuntu-latest
|
|
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
|
|
run: |
|
|
git config --global http.sslVerify false
|
|
git clone --depth 1 --branch main ${{ gitea.server_url }}/${{ gitea.repository }}.git /tmp/lexai
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
working-directory: /tmp/lexai
|
|
|
|
- name: Type check
|
|
run: npm run typecheck
|
|
working-directory: /tmp/lexai
|
|
|
|
- name: Run unit tests
|
|
run: npm test -- --run
|
|
working-directory: /tmp/lexai
|
|
|
|
- name: Build extension
|
|
run: npm run build
|
|
working-directory: /tmp/lexai
|
|
|
|
- name: Verify build output
|
|
run: ls -la .output/chrome-mv3/
|
|
working-directory: /tmp/lexai
|
|
|
|
- name: Package as ZIP
|
|
run: |
|
|
SHA=$(echo "${{ gitea.sha }}" | cut -c1-7)
|
|
VERSION=$(node -p "require('./package.json').version")-${SHA}
|
|
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
|
|
|
|
- name: Publish to Gitea Package Registry
|
|
run: |
|
|
curl -f -s -X PUT \
|
|
"${{ gitea.server_url }}/api/packages/kibin/generic/lexai-extension/${PACKAGE_VERSION}/lexai-chrome-mv3-${PACKAGE_VERSION}.zip" \
|
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
|
-T "/tmp/lexai-chrome-mv3-${PACKAGE_VERSION}.zip"
|
|
echo "✅ Published: https://git.juankibin.space/kibin/-/packages"
|
|
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"
|