Skip to content

Commit b780606

Browse files
committed
ci/publish
1 parent 01e9240 commit b780606

File tree

3 files changed

+49
-84
lines changed

3 files changed

+49
-84
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci
1+
name: ci/publish
22
on:
33
push:
44
paths:
@@ -11,47 +11,54 @@ on:
1111
pull_request:
1212
branches: [master]
1313

14+
workflow_dispatch:
15+
inputs:
16+
tag:
17+
description: Tag to publish e.g. v2.4.1 (beta), v2.5.0 (stable if ends with ".0")
18+
required: true
19+
type: string
20+
1421
jobs:
15-
test:
22+
build:
1623
runs-on: ubuntu-latest
17-
24+
strategy:
25+
matrix:
26+
build: [chrome-mv3, firefox, mv2]
1827
steps:
1928
- uses: actions/checkout@v6
29+
with:
30+
ref: ${{github.event.inputs.tag}}
2031
- uses: pnpm/action-setup@v4
2132
with:
2233
version: 10
2334
- uses: actions/setup-node@v6
2435
with:
2536
node-version-file: 'package.json'
37+
cache: 'pnpm'
2638

2739
- run: pnpm install --ignore-scripts # ignore postinstall hook
2840
- run: pnpm test
29-
41+
if: ${{matrix.build == 'chrome-mv3'}}
3042
- run: echo "_REV=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
3143

32-
# MV3 chrome
44+
- run: pnpm build-${{matrix.build}}
3345

34-
- run: rm -rf dist && pnpm build-chrome-mv3
35-
- uses: actions/upload-artifact@v4
46+
- name: upload "${{matrix.build}}" to github
47+
uses: actions/upload-artifact@v4
3648
with:
37-
name: 'stylus-chrome-mv3-${{ env._VER }}-${{ env._REV }}'
49+
name: 'stylus-${{matrix.build}}-${{env._VER}}-${{env._REV}}'
3850
path: 'dist/*'
3951
if-no-files-found: error
4052

41-
# MV2 firefox
42-
43-
- run: rm -rf dist && pnpm build-firefox
44-
- uses: actions/upload-artifact@v4
45-
with:
46-
name: 'stylus-firefox-mv2-${{ env._VER }}-${{ env._REV }}'
47-
path: 'dist/*'
48-
if-no-files-found: error
49-
50-
# MV2
51-
52-
- run: rm -rf dist && pnpm build-mv2
53-
- uses: actions/upload-artifact@v4
54-
with:
55-
name: 'stylus-mv2-${{ env._VER }}-${{ env._REV }}'
56-
path: 'dist/*'
57-
if-no-files-found: error
53+
- name: publish "chrome-mv3" to CWS
54+
if: ${{matrix.build == 'chrome-mv3' && github.event_name == 'workflow_dispatch'}}
55+
continue-on-error: true
56+
working-directory:
57+
dist
58+
env:
59+
CLIENT_ID: ${{secrets.CLIENT_ID}}
60+
CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
61+
REFRESH_TOKEN: ${{secrets.REFRESH_TOKEN}}
62+
run: |
63+
node ../tools/define-extension-id.js
64+
npx chrome-webstore-upload-cli@3

tools/build-zip.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

tools/define-extension-id.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
if (!process.env.CLIENT_ID)
4+
process.exit(1);
5+
6+
const fs = require('fs');
7+
const mj = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
8+
const isStable = mj.version.endsWith('.0');
9+
const id = isStable
10+
? 'clngdbkpkpeebahjckkjfobafhncgmne'
11+
: 'apmmpaebfobifelkijhaljbmpcgbjbdo';
12+
if (!isStable) {
13+
mj.version = mj.version.replace(/^2\./, '3.');
14+
mj.name += ' (beta)';
15+
fs.writeFileSync('manifest.json', JSON.stringify(mj, null, 2), 'utf8');
16+
}
17+
fs.appendFileSync(process.env.GITHUB_ENV, `EXTENSION_ID=${id}\n`);

0 commit comments

Comments
 (0)