Skip to content

feat(BLDL23): automate browser extension packaging #2

feat(BLDL23): automate browser extension packaging

feat(BLDL23): automate browser extension packaging #2

Workflow file for this run

name: Build Extension Packages
on:
push:
branches: [main]
paths-ignore:
- "README.md"
- "LICENSE"
pull_request:
branches: [main]
paths-ignore:
- "README.md"
- "LICENSE"
workflow_dispatch: # Allows manual re-run from GitHub UI
jobs:
build:
runs-on: ubuntu-latest
# Continue on error to ensure we always get some output
continue-on-error: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build extension packages
run: npm run build
- name: Validate Firefox modifications
run: node -e "const m=JSON.parse(require('fs').readFileSync('build/firefox/manifest.json','utf8')); if(!m.background.scripts||!m.browser_specific_settings?.gecko||m.background.service_worker) {console.error('❌ Firefox manifest missing required modifications or still has service_worker'); process.exit(1);} console.log('✅ Firefox manifest properly modified')"
- name: Upload Chrome extension artifact
uses: actions/upload-artifact@v4
with:
name: carbon-visualizer-chrome
path: build/carbon-visualizer-chrome.zip
retention-days: 30
- name: Upload Firefox extension artifact
uses: actions/upload-artifact@v4
with:
name: carbon-visualizer-firefox
path: build/carbon-visualizer-firefox.zip
retention-days: 30
- name: Upload build directory artifact
uses: actions/upload-artifact@v4
with:
name: build-directory
path: build/
retention-days: 30
- name: Comment PR with artifact links
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('📦 Extension packages built successfully!')
);
const commentBody = `📦 Extension packages built successfully!
**Download your extension packages:**
- [Chrome Extension](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})
- [Firefox Extension](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})
- [Build Directory](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})
Go to the Actions tab → Run #${context.runId} → Artifacts section to download.`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
- name: Notify on failure
if: failure()
run: |
echo "❌ Build failed! Check the logs above for details."