name: Build & Package on: push: branches: - main workflow_dispatch: env: DOTNET_VERSION: '10.0.x' REGISTRY: ghcr.io jobs: build: runs-on: ubuntu-latest timeout-minutes: 20 permissions: contents: write packages: write outputs: build-tag: ${{ steps.metadata.outputs.tag }} commit-hash: ${{ steps.metadata.outputs.commit }} build-time: ${{ steps.metadata.outputs.build-time }} steps: - name: Checkout Code uses: actions/checkout@v3 with: fetch-depth: 0 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install Python Dependencies run: pip install pyyaml openpyxl requests - name: "[GATE] Run Critical Validations" run: | echo "🔐 Running critical CI validations..." python3 tools/validate_no_direct_api_trading_v1.py || exit 1 python3 tools/validate_specs.py || exit 1 echo "✅ All critical validations passed" - name: Prepare Temp Directory run: | mkdir -p Temp if [ ! -f Temp/final_decision_packet_active.json ]; then echo '{"active_decision": "PASS", "details": "CI dummy packet"}' > Temp/final_decision_packet_active.json fi - name: Restore .NET Dependencies run: dotnet restore src/dotnet/QuantEngine.Web/QuantEngine.Web.csproj - name: Build Release run: | dotnet build src/dotnet/QuantEngine.Web/QuantEngine.Web.csproj \ -c Release \ --no-restore - name: Run Unit Tests run: | dotnet test src/dotnet/QuantEngine.Core.Tests/QuantEngine.Core.Tests.csproj \ -c Release \ --no-build - name: Publish Release Package run: | dotnet publish src/dotnet/QuantEngine.Web/QuantEngine.Web.csproj \ -c Release \ --no-build \ -o ./publish - name: Generate Build Metadata id: metadata run: | COMMIT=$(git rev-parse --short HEAD) BUILD_TIME=$(date -u +'%Y-%m-%dT%H:%M:%SZ') BUILD_TAG="build-${COMMIT}" mkdir -p ./publish/wwwroot cat > ./publish/wwwroot/version.json <> $GITHUB_OUTPUT echo "commit=${COMMIT}" >> $GITHUB_OUTPUT echo "build-time=${BUILD_TIME}" >> $GITHUB_OUTPUT echo "✓ Build metadata: ${BUILD_TAG} @ ${BUILD_TIME}" - name: Create Deployment Package run: | echo "📦 Creating deployment package..." tar -czf quantengine-${{ steps.metadata.outputs.commit }}.tar.gz \ -C ./publish . PACKAGE_SIZE=$(du -sh quantengine-${{ steps.metadata.outputs.commit }}.tar.gz | cut -f1) echo "✓ Package created: ${PACKAGE_SIZE}" # Verify package integrity tar -tzf quantengine-${{ steps.metadata.outputs.commit }}.tar.gz > /dev/null || exit 1 echo "✓ Package integrity verified" - name: Create GitHub Release uses: ncipollo/release-action@v1 with: tag: ${{ steps.metadata.outputs.tag }} name: Build ${{ steps.metadata.outputs.tag }} body: | **Build Information** - **Commit**: `${{ steps.metadata.outputs.commit }}` - **Built At**: ${{ steps.metadata.outputs.build-time }} - **Build Number**: ${{ github.run_number }} **Quality Gates** - ✅ No direct API trading validation - ✅ Specification validation - ✅ Unit tests passed **Release Package** - Release artifact: `quantengine-${{ steps.metadata.outputs.commit }}.tar.gz` - Size: $(du -sh quantengine-${{ steps.metadata.outputs.commit }}.tar.gz | cut -f1) **Deployment Instructions** ```bash # Trigger production deployment with this build curl -X POST https://gitea.taxbaik.com/api/v1/repos/kjh2064/QuantEngineByItz/actions/workflows/deploy-prod.yml/dispatches \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ -d '{"ref":"main", "inputs":{"release_tag":"${{ steps.metadata.outputs.tag }}"}}' ``` draft: false prerelease: false artifacts: quantengine-${{ steps.metadata.outputs.commit }}.tar.gz artifactErrorsFailBuild: true updateLatestRelease: true - name: Notify Build Success if: success() run: | echo "✅ Build ${{ steps.metadata.outputs.tag }} completed successfully" echo "📦 Package available at release: ${{ steps.metadata.outputs.tag }}" - name: Notify Build Failure if: failure() run: | echo "❌ Build ${{ steps.metadata.outputs.tag }} failed" exit 1