Skip to content

Commit

Permalink
add new build and verify workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Nov 6, 2024
1 parent 2721fc0 commit f5e4032
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 2 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- 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
93 changes: 93 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ yarn-error.log*
# Local Netlify folder
.netlify


# Gitleaks
gitleaks-baseline.json
.secrets
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gooey-chat",
"private": true,
"version": "2.1.0",
"version": "2.1.8",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down Expand Up @@ -38,4 +38,4 @@
"vite-plugin-dts": "^3.7.0",
"vite-plugin-require-transform": "^1.0.21"
}
}
}

0 comments on commit f5e4032

Please sign in to comment.