|
1 | | -name: Build & Lint Extension |
| 1 | +name: Build & Release Extension |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
9 | 9 | jobs: |
10 | 10 | build: |
11 | 11 | runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + contents: write # needed to create releases and upload assets |
12 | 14 |
|
13 | 15 | steps: |
14 | | - - uses: actions/checkout@v4 |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
15 | 18 |
|
16 | | - - name: Use Node.js 20 |
17 | | - uses: actions/setup-node@v4 |
18 | | - with: |
19 | | - node-version: 20 |
20 | | - cache: 'npm' |
| 19 | + - name: Set up Node.js 20 |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: 20 |
| 23 | + cache: 'npm' |
21 | 24 |
|
22 | | - - name: Install dependencies |
23 | | - run: npm ci |
| 25 | + - name: Install dependencies |
| 26 | + run: npm ci |
24 | 27 |
|
25 | | - - name: Type Check |
26 | | - run: npm run type-check |
| 28 | + - name: Type check |
| 29 | + run: npm run type-check |
27 | 30 |
|
28 | | - - name: Build Extension |
29 | | - run: npm run build |
| 31 | + - name: Build extension |
| 32 | + run: npm run build |
30 | 33 |
|
31 | | - - name: Upload Build Artifact |
32 | | - uses: actions/upload-artifact@v4 |
33 | | - with: |
34 | | - name: testpilot-extension |
35 | | - path: dist/ |
36 | | - retention-days: 5 |
| 34 | + # ── Build info ────────────────────────────────────────────────────────── |
| 35 | + - name: Generate build info |
| 36 | + id: build_info |
| 37 | + run: | |
| 38 | + SHA_SHORT=$(git rev-parse --short HEAD) |
| 39 | + DATE=$(date -u +"%Y-%m-%d") |
| 40 | + echo "sha_short=$SHA_SHORT" >> $GITHUB_OUTPUT |
| 41 | + echo "date=$DATE" >> $GITHUB_OUTPUT |
| 42 | + echo "zip_name=testpilot-${SHA_SHORT}.zip" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + # ── Zip the dist folder ───────────────────────────────────────────────── |
| 45 | + - name: Zip dist folder |
| 46 | + run: | |
| 47 | + cd dist |
| 48 | + zip -r "../${{ steps.build_info.outputs.zip_name }}" . |
| 49 | + cd .. |
| 50 | + echo "Created ${{ steps.build_info.outputs.zip_name }}" |
| 51 | + ls -lh "${{ steps.build_info.outputs.zip_name }}" |
| 52 | +
|
| 53 | + # ── Upload zip as a workflow artifact (available on every PR + push) ──── |
| 54 | + - name: Upload extension zip (artifact) |
| 55 | + uses: actions/upload-artifact@v4 |
| 56 | + with: |
| 57 | + name: testpilot-${{ steps.build_info.outputs.sha_short }} |
| 58 | + path: ${{ steps.build_info.outputs.zip_name }} |
| 59 | + retention-days: 14 |
| 60 | + |
| 61 | + # ── On main: create/update a "latest" GitHub Release with the zip ─────── |
| 62 | + - name: Create or update latest Release |
| 63 | + if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
| 64 | + uses: softprops/action-gh-release@v2 |
| 65 | + with: |
| 66 | + tag_name: latest |
| 67 | + name: "TestPilot – Latest Build (${{ steps.build_info.outputs.date }})" |
| 68 | + body: | |
| 69 | + ## ⬇️ Install TestPilot |
| 70 | +
|
| 71 | + 1. Download `testpilot-${{ steps.build_info.outputs.sha_short }}.zip` below |
| 72 | + 2. Unzip it anywhere on your machine |
| 73 | + 3. Open `chrome://extensions` in Chrome |
| 74 | + 4. Enable **Developer mode** (top-right toggle) |
| 75 | + 5. Click **Load unpacked** and select the unzipped folder |
| 76 | +
|
| 77 | + --- |
| 78 | + **Commit:** `${{ steps.build_info.outputs.sha_short }}` |
| 79 | + **Built:** ${{ steps.build_info.outputs.date }} |
| 80 | + files: ${{ steps.build_info.outputs.zip_name }} |
| 81 | + prerelease: false |
| 82 | + make_latest: true |
0 commit comments