|
6 | 6 | pull_request:
|
7 | 7 |
|
8 | 8 | jobs:
|
| 9 | + manifest: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + outputs: |
| 12 | + version: ${{ steps.extract.outputs.version }} |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + - id: extract |
| 17 | + working-directory: ./workspace/extension/static |
| 18 | + run: echo "version=$(jq -r '.version' manifest.json)" >> $GITHUB_OUTPUT |
| 19 | + |
9 | 20 | bundle:
|
10 | 21 | runs-on: ubuntu-latest
|
| 22 | + needs: manifest |
11 | 23 |
|
12 | 24 | steps:
|
13 |
| - - uses: actions/checkout@v3 |
14 |
| - - uses: pnpm/action-setup@v2 |
15 |
| - - uses: actions/setup-node@v3 |
| 25 | + - uses: actions/checkout@v4 |
| 26 | + - uses: pnpm/action-setup@v4 |
| 27 | + - uses: actions/setup-node@v4 |
16 | 28 | with:
|
17 |
| - node-version: 18 |
| 29 | + node-version: 20 |
18 | 30 | cache: pnpm
|
19 | 31 |
|
20 | 32 | - run: pnpm install
|
21 |
| - - run: cd workspace/extension && pnpm build |
22 |
| - - run: cd workspace/extension/build && zip -r svelte-devtools * |
| 33 | + - working-directory: ./workspace/extension |
| 34 | + run: pnpm build && cd build && zip -r svelte-devtools * |
23 | 35 |
|
24 |
| - - uses: actions/upload-artifact@v3 |
| 36 | + - uses: actions/upload-artifact@v4 |
25 | 37 | with:
|
26 | 38 | name: extension-${{ github.sha }}
|
27 | 39 | path: workspace/extension/build/svelte-devtools.zip
|
28 | 40 |
|
29 |
| - # publish: |
30 |
| - # runs-on: ubuntu-latest |
31 |
| - # needs: bundle |
| 41 | + - if: github.event_name == 'pull_request' |
| 42 | + env: |
| 43 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + PR_NUMBER: ${{ github.event.number }} |
| 45 | + WORKFLOW: ${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts |
| 46 | + run: | |
| 47 | + url=https://github.com/$WORKFLOW/$(gh api repos/$WORKFLOW --jq '.artifacts[0].id') |
| 48 | + commented=$(gh pr view $PR_NUMBER --json comments --jq '.comments[].author.login | select(. | contains("github-actions"))') |
| 49 | + body="Try the changes in this PR by [side-loading the built extension]($url). :rocket:" |
| 50 | +
|
| 51 | + if [ -z "$commented" ]; then |
| 52 | + gh pr comment $PR_NUMBER --body "$body" |
| 53 | + else |
| 54 | + gh pr comment $PR_NUMBER --edit-last --body "$body" |
| 55 | + fi |
| 56 | +
|
| 57 | + publish: |
| 58 | + runs-on: ubuntu-latest |
| 59 | + needs: [manifest, bundle] |
| 60 | + |
| 61 | + if: | |
| 62 | + github.repository == 'sveltejs/svelte-devtools' && |
| 63 | + github.event_name == 'push' && github.ref == 'refs/heads/master' && |
| 64 | + startsWith(github.event.head_commit.message, format('~ v{0}', needs.manifest.outputs.version)) |
| 65 | +
|
| 66 | + steps: |
| 67 | + - uses: actions/checkout@v4 |
| 68 | + - uses: pnpm/action-setup@v4 |
| 69 | + - uses: actions/download-artifact@v4 |
| 70 | + |
| 71 | + - working-directory: extension-${{ github.sha }} |
| 72 | + run: | |
| 73 | + pnpm dlx web-ext sign --channel unlisted \ |
| 74 | + --api-key ${{ secrets.WEB_EXT_API_KEY }} \ |
| 75 | + --api-secret ${{ secrets.WEB_EXT_API_SECRET }} |
| 76 | +
|
| 77 | + - working-directory: extension-${{ github.sha }} |
| 78 | + env: |
| 79 | + GH_TOKEN: ${{ github.token }} |
| 80 | + run: | # https://cli.github.com/manual/gh_release_create |
| 81 | + gh release create v${{ needs.manifest.outputs.version }} \ |
| 82 | + svelte-devtools.zip web-ext-artifacts/*.xpi#svelte-devtools.xpi \ |
| 83 | + --title ${{ needs.manifest.outputs.version }} \ |
| 84 | + --draft --generate-notes --notes ' |
| 85 | + Built from ${{ github.event.head_commit.id }} at https://github.com/sveltejs/svelte-devtools/actions/runs/${{ github.run_id }} |
| 86 | + - Chrome Web Store: https://chrome.google.com/webstore/detail/svelte-devtools/kfidecgcdjjfpeckbblhmfkhmlgecoff |
| 87 | + - Firefox Signed Add-on: https://github.com/sveltejs/svelte-devtools/releases/download/v${{ needs.manifest.outputs.version }}/svelte-devtools.xpi |
| 88 | + ---' |
32 | 89 |
|
33 |
| - # steps: |
34 |
| - # - uses: actions/download-artifact@v3 |
35 |
| - # with: |
36 |
| - # name: extension-${{ github.sha }} |
| 90 | + # TODO: publish to Chrome Web Store |
0 commit comments