From f5e40325ea7a309357508b9175b0f51b1d1f695e Mon Sep 17 00:00:00 2001 From: anish-work Date: Wed, 6 Nov 2024 13:10:23 +0530 Subject: [PATCH] add new build and verify workflows --- .github/workflows/build.yml | 65 +++++++++++++++++++++++++ .github/workflows/verify.yml | 93 ++++++++++++++++++++++++++++++++++++ .gitignore | 2 + package.json | 4 +- 4 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/verify.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2f7be46 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,65 @@ +name: Build, Version Bump and Publish + +on: + push: + branches: + - master + pull_request: + types: [closed] + branches: + - master + +jobs: + build: + if: github.event.pull_request.merged == true || github.event_name == 'push' + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + + - name: Configure Git + run: | + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + + - name: Install dependencies + run: npm install + + - name: Get current version + id: version + run: | + CURRENT_VERSION=$(node -p "require('./package.json').version") + IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION" + BUILD_NUM=$((${VERSION_PARTS[2]} + 1)) + NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$BUILD_NUM" + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Update version in package.json + run: | + NEW_VERSION=${{ steps.version.outputs.new_version }} + npm version $NEW_VERSION --no-git-tag-version + + - name: Build project + run: npm run build + + - name: Commit changes + run: | + NEW_VERSION=${{ steps.version.outputs.new_version }} + git add package.json package-lock.json dist/ + git commit -m "build: $NEW_VERSION" + git push + + - name: Create and push tag + run: | + NEW_VERSION=${{ steps.version.outputs.new_version }} + git tag $NEW_VERSION + git push origin $NEW_VERSION \ No newline at end of file diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml new file mode 100644 index 0000000..767d119 --- /dev/null +++ b/.github/workflows/verify.yml @@ -0,0 +1,93 @@ +name: Build Verification + +on: + # Run on all PRs + pull_request: + branches: + - '*' + # Run on all pushes except master (since master has its own build workflow) + push: + branches: + - '*' + - '!master' + +jobs: + verify-build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm install + + - name: Lint + run: npm run lint + continue-on-error: true # Don't fail the build for lint errors + + - name: Type check + if: ${{ hashFiles('tsconfig.json') }} # Only run if TypeScript is used + run: npm run typecheck || npm run check:types || echo "No type checking script found" + continue-on-error: true + + - name: Run tests + run: npm test + continue-on-error: true # Don't fail if tests aren't set up + + - name: Verify build + run: | + npm run build + if [ $? -eq 0 ]; then + echo "✅ Build successful" + else + echo "❌ Build failed" + exit 1 + fi + + - name: Check bundle size + run: | + BUILD_DIR="dist" + if [ -d "$BUILD_DIR" ]; then + echo "Bundle sizes:" + du -h "$BUILD_DIR"/* + else + echo "Build directory not found" + exit 1 + fi + + - name: Check for common build issues + run: | + # Check if dist directory exists + if [ ! -d "dist" ]; then + echo "❌ dist directory is missing" + exit 1 + fi + + # Check if main bundle exists (adjust the pattern based on your build output) + if ! ls dist/*.js >/dev/null 2>&1; then + echo "❌ No JavaScript bundles found in dist/" + exit 1 + fi + + # Check if any source maps are generated (if expected) + if ! ls dist/*.map >/dev/null 2>&1; then + echo "⚠️ Warning: No source maps found" + fi + + echo "✅ All build artifacts verified" + + - name: Status Report + if: always() + run: | + echo "Build Verification Summary:" + echo "==========================" + echo "✓ Dependencies installed" + echo "✓ Build completed" + echo "✓ Bundle size checked" + echo "✓ Build artifacts verified" \ No newline at end of file diff --git a/.gitignore b/.gitignore index e7af657..60fdb97 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,7 @@ yarn-error.log* # Local Netlify folder .netlify + # Gitleaks gitleaks-baseline.json +.secrets diff --git a/package.json b/package.json index 699ede0..3692ba4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "gooey-chat", "private": true, - "version": "2.1.0", + "version": "2.1.8", "type": "module", "scripts": { "dev": "vite", @@ -38,4 +38,4 @@ "vite-plugin-dts": "^3.7.0", "vite-plugin-require-transform": "^1.0.21" } -} +} \ No newline at end of file