ci: automate publishing extension (#31)
* chore: package extension for store * fix: manifest is valid json * chore: add script to automate publishing to chrome store * ci: on release of devtools publish extension * refactor: ensure all build artefacts are in dist * Apply suggestions from code review Co-authored-by: Piotr Galar <piotr.galar@gmail.com> * chore: fix lint error * Revert "refactor: ensure all build artefacts are in dist" This reverts commit 026e0fca7a831519c7924987da15c127d1c7269e. * ci: reorder workflow config for readability --------- Co-authored-by: Daniel N <2color@users.noreply.github.com> Co-authored-by: Piotr Galar <piotr.galar@gmail.com>
Daniel Norman committed
Aug 18, 2025 at 17:20 UTC
17735514ab3d0ab2077ee4ca6c652f5ec614f28d
5 files changed
+45
-5
.github/workflows/js-test-and-release.yml
+36
@@ -26,3 +26,39 @@ jobs:
26
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
27
UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }}
28
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
29
+
30
+ ## Detect changs to the devtools package
31
+ changes:
32
+ runs-on: ubuntu-latest
33
+ outputs:
34
+ devtools-changed: ${{ steps.changes.outputs.devtools }}
35
+ steps:
36
+ - uses: actions/checkout@v5
37
+ - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
38
+ id: changes
39
+ with:
40
+ filters: |
41
+ devtools:
42
+ - 'packages/libp2p-devtools/**'
43
+
44
+ publish-extension:
45
+ runs-on: ubuntu-latest
46
+ needs: [js-test-and-release, changes]
47
+ if: needs.js-test-and-release.outputs.release == 'true' && needs.changes.outputs.devtools-changed == 'true'
48
+ steps:
49
+ - uses: actions/checkout@v5
50
+ with:
51
+ persist-credentials: false
52
+ - uses: actions/setup-node@v4
53
+ with:
54
+ node-version: lts/*
55
+ - uses: ipfs/aegir/actions/cache-node-modules@main
56
+ - run: npm run package
57
+ working-directory: 'packages/libp2p-devtools'
58
+ - run: npm run publish:chrome-store
59
+ working-directory: 'packages/libp2p-devtools'
60
+ env:
61
+ CHROME_CLIENT_ID: ${{ secrets.CHROME_CLIENT_ID }}
62
+ CHROME_CLIENT_SECRET: ${{ secrets.CHROME_CLIENT_SECRET }}
63
+ CHROME_REFRESH_TOKEN: ${{ secrets.CHROME_REFRESH_TOKEN }}
64
+ CHROME_EXTENSION_ID: ${{ vars.CHROME_EXTENSION_ID }}
\ No newline at end of file
package.json
+1
@@ -41,6 +41,7 @@
41
"devDependencies": {
42
"@welldone-software/why-did-you-render": "^10.0.1",
43
"aegir": "^47.0.12",
44
+ "cws-publish": "^2.1.1",
45
"npm-run-all": "^4.1.5"
46
},
47
"workspaces": [
packages/libp2p-devtools/.gitignore
+1
@@ -1,3 +1,4 @@
1
dist
2
node_modules
3
.vscode
4
+libp2p-devtools.zip
\ No newline at end of file
packages/libp2p-devtools/manifest.json
+4
-4
@@ -15,15 +15,15 @@
15
"scripting"
16
],
17
"devtools_page": "devtools.html",
18
- // https://stackoverflow.com/questions/75043889/manifest-v3-background-scripts-service-worker-on-firefox
18
"background": {
20
- // for chrome
19
"service_worker": "/dist/service-worker.js",
22
- // for firefox
20
"scripts": ["/dist/service-worker.js"]
21
},
22
"content_scripts": [{
26
- "matches": ["<all_urls>"],
23
+ "matches": [
24
+ "http://*/*",
25
+ "https://*/*"
26
+ ],
27
"js": ["/dist/content-script.js"]
28
}]
29
}
packages/libp2p-devtools/package.json
+3
-1
@@ -131,6 +131,8 @@
131
"clean": "aegir clean",
132
"lint": "aegir lint",
133
"build": "tsc && node esbuild.js",
134
+ "package": "web-ext build --source-dir=. --artifacts-dir=. --filename=libp2p-devtools.zip --overwrite-dest",
135
+ "publish:chrome-store": "npx cws-publish \"$CHROME_CLIENT_ID\" \"$CHROME_CLIENT_SECRET\" \"$CHROME_REFRESH_TOKEN\" libp2p-devtools.zip \"$CHROME_EXTENSION_ID\"",
136
"test": "echo \"Error: no test specified\" && exit 1",
137
"dep-check": "aegir dep-check",
138
"start:firefox": "web-ext run --source-dir . --verbose --devtools",
@@ -156,6 +158,6 @@
158
"@types/react-dom": "^19.1.5",
159
"@types/react-syntax-highlighter": "^15.5.13",
160
"aegir": "^47.0.13",
159
- "web-ext": "^8.7.0"
161
+ "web-ext": "^8.9.0"
162
}
163
}