mirror of
https://github.com/proffesor-for-testing/agentic-qe.git
synced 2026-09-19 08:45:47 +08:00
4cb914757b
Matches local dev environment (Node 24 / npm 11) to fix lockfile compatibility issues causing `npm ci` failures (jose@5.10.0 missing). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
153 lines
4.5 KiB
YAML
153 lines
4.5 KiB
YAML
name: Publish to npm
|
|
|
|
on:
|
|
release:
|
|
types: [published]
|
|
workflow_dispatch:
|
|
inputs:
|
|
dry_run:
|
|
description: 'Perform a dry run (no actual publish)'
|
|
required: false
|
|
default: 'false'
|
|
type: boolean
|
|
|
|
# Required for npm trusted publishers (OIDC)
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and Verify
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
cache: 'npm'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Run type check
|
|
run: npm run typecheck
|
|
|
|
- name: Build project
|
|
run: npm run build
|
|
|
|
- name: Verify build output
|
|
run: |
|
|
if [ ! -d "dist" ]; then
|
|
echo "Error: dist directory not found"
|
|
exit 1
|
|
fi
|
|
if [ ! -f "dist/cli/bundle.js" ]; then
|
|
echo "Error: CLI bundle not found"
|
|
exit 1
|
|
fi
|
|
if [ ! -f "dist/index.js" ]; then
|
|
echo "Error: Main entry point not found"
|
|
exit 1
|
|
fi
|
|
echo "Build verification passed"
|
|
|
|
- name: Run tests (excluding browser E2E - requires real browser)
|
|
run: |
|
|
npm run test:ci 2>&1 | tee /tmp/test-output.txt
|
|
TEST_EXIT=$?
|
|
# Tolerate Vitest worker fork crash if all test files actually passed
|
|
if [ $TEST_EXIT -ne 0 ]; then
|
|
if grep -q "Test Files.*passed" /tmp/test-output.txt && ! grep -q "failed" /tmp/test-output.txt; then
|
|
echo "::warning::Vitest worker crashed at exit but all tests passed — continuing"
|
|
else
|
|
exit $TEST_EXIT
|
|
fi
|
|
fi
|
|
env:
|
|
NODE_OPTIONS: '--max-old-space-size=2048'
|
|
CI: 'true'
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
retention-days: 1
|
|
|
|
publish:
|
|
name: Publish to npm
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 10
|
|
environment: npm-publish
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
cache: 'npm'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Download build artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: dist
|
|
path: dist/
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Verify package version matches tag
|
|
if: github.event_name == 'release'
|
|
run: |
|
|
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
TAG_VERSION="${{ github.ref_name }}"
|
|
# Remove 'v' prefix if present
|
|
TAG_VERSION="${TAG_VERSION#v}"
|
|
|
|
if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
|
|
echo "Error: Package version ($PACKAGE_VERSION) does not match tag version ($TAG_VERSION)"
|
|
exit 1
|
|
fi
|
|
echo "Version verification passed: $PACKAGE_VERSION"
|
|
|
|
- name: Publish to npm (dry run)
|
|
if: github.event.inputs.dry_run == 'true'
|
|
run: npm publish --access public --dry-run
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Publish to npm
|
|
if: github.event.inputs.dry_run != 'true'
|
|
run: npm publish --access public --provenance
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Create publish summary
|
|
run: |
|
|
PACKAGE_NAME=$(node -p "require('./package.json').name")
|
|
PACKAGE_VERSION=$(node -p "require('./package.json').version")
|
|
|
|
echo "## Published to npm" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Package**: $PACKAGE_NAME" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Version**: $PACKAGE_VERSION" >> $GITHUB_STEP_SUMMARY
|
|
echo "- **Registry**: https://www.npmjs.com/package/$PACKAGE_NAME" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
if [ "${{ github.event.inputs.dry_run }}" == "true" ]; then
|
|
echo "> **Note**: This was a dry run. No package was actually published." >> $GITHUB_STEP_SUMMARY
|
|
else
|
|
echo "Install with: \`npm install $PACKAGE_NAME@$PACKAGE_VERSION\`" >> $GITHUB_STEP_SUMMARY
|
|
fi
|