Skip to content

Commit 2d9e07d

Browse files
committed
ci: fix deploying extension to webstores
1 parent 92fee96 commit 2d9e07d

File tree

7 files changed

+62
-23
lines changed

7 files changed

+62
-23
lines changed

.github/workflows/build.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build extension
2+
3+
on: [workflow_dispatch, workflow_call]
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
install-packages:
10+
runs-on: ubuntu-22.04
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: npm
18+
cache-dependency-path: "./package-lock.json"
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Build all
24+
run: npm run build:all-ci -w syncwatch-extension
25+
26+
- uses: actions/upload-artifact@v4
27+
with:
28+
name: build-ci
29+
path: ./packages/syncwatch-extension/build-ci

.github/workflows/main.yaml

+25-20
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
name: CI
1+
name: Deploy extension to stores
22

3-
on:
4-
release:
5-
types: [published]
3+
on: workflow_dispatch
64

75
jobs:
8-
Firefox:
9-
runs-on: ubuntu-latest
6+
build-all:
7+
uses: ./.github/workflows/build.yml
8+
9+
firefox:
10+
needs: build-all
11+
runs-on: ubuntu-22.04
1012

1113
steps:
12-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1315

14-
- name: Find and Replace
15-
uses: jacobtomlinson/gha-find-replace@v1
16+
- uses: actions/download-artifact@v4
1617
with:
17-
find: '"incognito": "split",'
18-
replace: ""
19-
include: "packages/syncwatch-extension/dist/manifest.json"
18+
name: build-ci
19+
path: ./build-ci
2020

2121
- name: Build Extension for Firefox
2222
id: web-ext-build
2323
uses: kewisch/action-web-ext@v1
2424
with:
2525
cmd: build
26-
source: ./packages/syncwatch-extension/dist
26+
source: ./build-ci/firefox-mv2
2727

2828
- name: "Sign & publish"
2929
id: web-ext-sign
@@ -36,22 +36,27 @@ jobs:
3636
apiSecret: ${{ secrets.FIREFOX_CLIENT_SECRET }}
3737

3838
- name: Drop artifacts
39-
uses: actions/upload-artifact@v2
39+
uses: actions/upload-artifact@v4
4040
with:
4141
name: "Firefox Artefacts"
4242
path: ${{ steps.web-ext-build.outputs.target }}
4343

44-
Chrome:
45-
runs-on: ubuntu-latest
46-
44+
chrome:
45+
needs: build-all
46+
runs-on: ubuntu-22.04
4747
steps:
48-
- uses: actions/checkout@v2
48+
- uses: actions/checkout@v4
49+
50+
- uses: actions/download-artifact@v4
51+
with:
52+
name: build-ci
53+
path: ./build-ci
4954

5055
- name: Pack extension
5156
uses: TheDoctor0/[email protected]
5257
with:
5358
filename: ./SyncWatchExtension.zip
54-
path: ./packages/syncwatch-extension/dist
59+
path: ./build-ci/chrome-mv3
5560

5661
- name: Publish to Chrome Webstore
5762
uses: trmcnvn/chrome-addon@v2
@@ -72,7 +77,7 @@ jobs:
7277
draft: false
7378

7479
- name: Drop artifacts
75-
uses: actions/upload-artifact@v2
80+
uses: actions/upload-artifact@v4
7681
with:
7782
name: "Chrome Artifacts"
7883
path: ./SyncWatchExtension.zip

.github/workflows/yandex-cloud.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Image CI
1+
name: Deploy server
22

33
on:
44
push:

packages/syncwatch-extension/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Build
22
dist
3+
build-ci
34

45
# Logs
56
logs

packages/syncwatch-extension/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
"scripts": {
2424
"dev": "vite",
2525
"build": "vite build",
26+
"build:chrome-ci": "npx cross-env TARGET=chrome BUILD_DIR=build-ci/chrome-mv3 vite build",
27+
"build:firefox-ci": "npx cross-env TARGET=firefox BUILD_DIR=build-ci/firefox-mv2 vite build",
28+
"build:all-ci": "npm run build:chrome-ci && npm run build:firefox-ci",
2629
"serve:test-page": "npx serve tests/test-page/",
2730
"postinstall": "npx -y playwright install",
2831
"test:e2e": "npx playwright test",

packages/syncwatch-extension/src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"{{chrome}}.manifest_version": 3,
44
"name": "__MSG_appName__",
55
"description": "__MSG_appDesc__",
6-
"version": "0.423",
6+
"version": "0.500",
77
"default_locale": "en",
88
"options_ui": {
99
"page": "options.html",

packages/syncwatch-extension/vite.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function root(...paths: string[]): string {
77
}
88

99
const target = process.env.TARGET || 'chrome';
10+
const outDir = process.env.BUILD_DIR || 'dist';
1011

1112
function generateManifest() {
1213
const manifest = readJsonFile('src/manifest.json');
@@ -22,7 +23,7 @@ function generateManifest() {
2223
export default defineConfig({
2324
root: 'src',
2425
build: {
25-
outDir: root('dist'),
26+
outDir: root(outDir),
2627
emptyOutDir: true,
2728
sourcemap: process.env.SOURCEMAP?.trim() === 'true',
2829
},

0 commit comments

Comments
 (0)