|
1 | 1 | name: Build Extension Packages |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: [main] |
6 | | - paths-ignore: |
7 | | - - "README.md" |
8 | | - - "LICENSE" |
9 | | - pull_request: |
10 | | - branches: [main] |
11 | | - paths-ignore: |
12 | | - - "README.md" |
13 | | - - "LICENSE" |
14 | | - workflow_dispatch: # Allows manual re-run from GitHub UI |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths-ignore: |
| 7 | + - "README.md" |
| 8 | + - "LICENSE" |
| 9 | + pull_request: |
| 10 | + branches: [main] |
| 11 | + paths-ignore: |
| 12 | + - "README.md" |
| 13 | + - "LICENSE" |
| 14 | + workflow_dispatch: # Allows manual re-run from GitHub UI |
15 | 15 |
|
16 | 16 | jobs: |
17 | | - build: |
18 | | - runs-on: ubuntu-latest |
19 | | - # Continue on error to ensure we always get some output |
20 | | - continue-on-error: false |
21 | | - |
22 | | - steps: |
23 | | - - name: Checkout code |
24 | | - uses: actions/checkout@v4 |
25 | | - |
26 | | - - name: Setup Node.js |
27 | | - uses: actions/setup-node@v4 |
28 | | - with: |
29 | | - node-version: "18" |
30 | | - cache: "npm" |
31 | | - |
32 | | - - name: Install dependencies |
33 | | - run: npm ci |
34 | | - |
35 | | - - name: Build extension packages |
36 | | - run: npm run build |
37 | | - |
38 | | - - name: Validate Firefox modifications |
39 | | - 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')" |
40 | | - |
41 | | - - name: Upload Chrome extension artifact |
42 | | - uses: actions/upload-artifact@v4 |
43 | | - with: |
44 | | - name: carbon-visualizer-chrome |
45 | | - path: build/carbon-visualizer-chrome.zip |
46 | | - retention-days: 30 |
47 | | - |
48 | | - - name: Upload Firefox extension artifact |
49 | | - uses: actions/upload-artifact@v4 |
50 | | - with: |
51 | | - name: carbon-visualizer-firefox |
52 | | - path: build/carbon-visualizer-firefox.zip |
53 | | - retention-days: 30 |
54 | | - |
55 | | - - name: Upload build directory artifact |
56 | | - uses: actions/upload-artifact@v4 |
57 | | - with: |
58 | | - name: build-directory |
59 | | - path: build/ |
60 | | - retention-days: 30 |
61 | | - |
62 | | - - name: Notify on failure |
63 | | - if: failure() |
64 | | - run: | |
65 | | - echo "❌ Build failed! Check the logs above for details." |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + # Continue on error to ensure we always get some output |
| 20 | + continue-on-error: false |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Setup Node.js |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: "18" |
| 30 | + cache: "npm" |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: npm ci |
| 34 | + |
| 35 | + - name: Build extension packages |
| 36 | + run: npm run build |
| 37 | + |
| 38 | + - name: Validate Firefox modifications |
| 39 | + 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')" |
| 40 | + |
| 41 | + - name: Upload Chrome extension artifact |
| 42 | + uses: actions/upload-artifact@v4 |
| 43 | + with: |
| 44 | + name: carbon-visualizer-chrome |
| 45 | + path: build/carbon-visualizer-chrome.zip |
| 46 | + retention-days: 30 |
| 47 | + |
| 48 | + - name: Upload Firefox extension artifact |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: carbon-visualizer-firefox |
| 52 | + path: build/carbon-visualizer-firefox.zip |
| 53 | + retention-days: 30 |
| 54 | + |
| 55 | + - name: Upload build directory artifact |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: build-directory |
| 59 | + path: build/ |
| 60 | + retention-days: 30 |
| 61 | + |
| 62 | + - name: Comment PR with artifact links |
| 63 | + if: github.event_name == 'pull_request' |
| 64 | + uses: actions/github-script@v7 |
| 65 | + with: |
| 66 | + script: | |
| 67 | + const { data: comments } = await github.rest.issues.listComments({ |
| 68 | + owner: context.repo.owner, |
| 69 | + repo: context.repo.repo, |
| 70 | + issue_number: context.issue.number, |
| 71 | + }); |
| 72 | +
|
| 73 | + const botComment = comments.find(comment => |
| 74 | + comment.user.type === 'Bot' && |
| 75 | + comment.body.includes('📦 Extension packages built successfully!') |
| 76 | + ); |
| 77 | +
|
| 78 | + const commentBody = `📦 Extension packages built successfully! |
| 79 | +
|
| 80 | + **[Download your Chrome and Firefox extension packages](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})**`; |
| 81 | +
|
| 82 | + if (botComment) { |
| 83 | + await github.rest.issues.updateComment({ |
| 84 | + owner: context.repo.owner, |
| 85 | + repo: context.repo.repo, |
| 86 | + comment_id: botComment.id, |
| 87 | + body: commentBody |
| 88 | + }); |
| 89 | + } else { |
| 90 | + await github.rest.issues.createComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + issue_number: context.issue.number, |
| 94 | + body: commentBody |
| 95 | + }); |
| 96 | + } |
| 97 | +
|
| 98 | + - name: Notify on failure |
| 99 | + if: failure() |
| 100 | + run: | |
| 101 | + echo "❌ Build failed! Check the logs above for details." |
0 commit comments