Skip to content

Commit 6c39a24

Browse files
committed
ci: add publish pipeline (#428)
1 parent 348e071 commit 6c39a24

File tree

6 files changed

+105
-3
lines changed

6 files changed

+105
-3
lines changed

.commitlintrc.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import {
2+
RuleConfigCondition,
3+
RuleConfigSeverity,
4+
TargetCaseType
5+
} from "@commitlint/types"
6+
7+
export default {
8+
rules: {
9+
"body-leading-blank": [RuleConfigSeverity.Error, "always"] as const,
10+
"body-max-line-length": [RuleConfigSeverity.Error, "always", 100] as const,
11+
"footer-leading-blank": [RuleConfigSeverity.Warning, "never"] as const,
12+
"footer-max-line-length": [
13+
RuleConfigSeverity.Error,
14+
"always",
15+
100,
16+
] as const,
17+
"header-max-length": [RuleConfigSeverity.Error, "always", 100] as const,
18+
"header-trim": [RuleConfigSeverity.Error, "always"] as const,
19+
"subject-case": [
20+
RuleConfigSeverity.Error,
21+
"never",
22+
["sentence-case", "start-case", "pascal-case", "upper-case"],
23+
] as [RuleConfigSeverity, RuleConfigCondition, TargetCaseType[]],
24+
"subject-empty": [RuleConfigSeverity.Error, "never"] as const,
25+
"subject-full-stop": [RuleConfigSeverity.Error, "never", "."] as const,
26+
"type-case": [RuleConfigSeverity.Error, "always", "lower-case"] as const,
27+
"type-empty": [RuleConfigSeverity.Error, "never"] as const,
28+
"type-enum": [
29+
RuleConfigSeverity.Error,
30+
"always",
31+
[
32+
"build",
33+
"chore",
34+
"ci",
35+
"docs",
36+
"feat",
37+
"fix",
38+
"perf",
39+
"refactor",
40+
"revert",
41+
"style",
42+
"test",
43+
],
44+
] satisfies [RuleConfigSeverity, RuleConfigCondition, string[]],
45+
},
46+
prompt: {},
47+
}

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish to extension/addon store
2+
on:
3+
push:
4+
branches:
5+
- "release"
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Install dependencies
12+
uses: actions/setup-node@v1
13+
with:
14+
node-version: "v20.11.0"
15+
- run: npm install
16+
- name: Build for MV3
17+
run: npm run build
18+
- name: Build for Firefox
19+
run: npm run build:firefox
20+
- name: Upload to chrome webstore
21+
uses: mnao305/chrome-extension-upload@v5.0.0
22+
with:
23+
file-path: market_packages/target.zip
24+
extension-id: dkdhhcbjijekmneelocdllcldcpmekmm
25+
client-id: ${{ secrets.CHROME_CLIENT_ID }}
26+
client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
27+
refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
28+
# publish: false # Not to publish
29+
- name: Upload to Edge addon store
30+
uses: wdzeng/edge-addon@v2
31+
with:
32+
zip-path: market_packages/target.zip
33+
product-id: 2a99ae83-5ec8-4ad2-aa63-9a276fc708ce
34+
client-id: ${{ secrets.EDGE_CLIENT_ID }}
35+
api-key: ${{ secrets.EDGE_API_KEY}}
36+
upload-only: true # Not to publish
37+
- name: Upload to Firefox addon store
38+
uses: cardinalby/webext-buildtools-firefox-addons-action@v1
39+
with:
40+
extensionId: '{7b312f5e-9680-436b-acc1-9b09f60e8aaa}'
41+
zipFilePath: market_packages/target.firefox.zip
42+
jwtIssuer: ${{ secrets.FIREFOX_API_KEY }}
43+
jwtSecret: ${{ secrets.FIREFOX_API_SECRET }}

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx --no -- commitlint --edit $1

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timer",
3-
"version": "3.3.3",
3+
"version": "3.3.4",
44
"description": "Time tracker",
55
"homepage": "https://www.wfhg.cc",
66
"scripts": {
@@ -15,7 +15,8 @@
1515
"analyze": "webpack --config=webpack/webpack.analyze.ts",
1616
"test": "jest --env=jsdom test/",
1717
"test-c": "jest --coverage --reporters=jest-junit --env=jsdom test/",
18-
"test-e2e": "jest test-e2e/ --runInBand"
18+
"test-e2e": "jest test-e2e/ --runInBand",
19+
"prepare": "husky"
1920
},
2021
"author": {
2122
"name": "zhy",
@@ -43,13 +44,15 @@
4344
"@types/webpack": "^5.28.5",
4445
"@vue/babel-plugin-jsx": "^1.4.0",
4546
"babel-loader": "^10.0.0",
47+
"commitlint": "^19.8.0",
4648
"copy-webpack-plugin": "^13.0.0",
4749
"css-loader": "^7.1.2",
4850
"decompress": "^4.2.1",
4951
"eslint": "^9.22.0",
5052
"filemanager-webpack-plugin": "^8.0.0",
5153
"generate-json-webpack-plugin": "^2.0.0",
5254
"html-webpack-plugin": "^5.6.3",
55+
"husky": "^9.1.7",
5356
"jest": "^29.7.0",
5457
"jest-environment-jsdom": "^29.7.0",
5558
"jest-junit": "^16.0.0",
@@ -85,4 +88,4 @@
8588
"engines": {
8689
"node": ">=20"
8790
}
88-
}
91+
}

webpack/webpack.prod.firefox.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const outputPath = path.resolve(__dirname, '..', 'dist_prod_firefox')
1010
const marketPkgPath = path.resolve(__dirname, '..', 'market_packages')
1111

1212
const normalZipFilePath = path.resolve(marketPkgPath, `${name}-${version}.firefox.zip`)
13+
const targetZipFilePath = path.resolve(marketPkgPath, 'target.firefox.zip')
1314
const sourceCodePath = path.resolve(__dirname, '..', 'market_packages', `${name}-${version}-src.zip`)
1415
const readmeForFirefox = path.join(__dirname, '..', 'doc', 'for-fire-fox.md')
1516
// Temporary directory for source code to archive on Firefox
@@ -28,6 +29,9 @@ const filemanagerWebpackPlugin = new FileManagerWebpackPlugin({
2829
archive: [{
2930
source: outputPath,
3031
destination: normalZipFilePath,
32+
}, {
33+
source: outputPath,
34+
destination: targetZipFilePath,
3135
}]
3236
},
3337
// Archive source code for FireFox

webpack/webpack.prod.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const outputPath = path.resolve(__dirname, '..', 'dist_prod')
1010
const marketPkgPath = path.resolve(__dirname, '..', 'market_packages')
1111

1212
const normalZipFilePath = path.resolve(marketPkgPath, `${name}-${version}.mv3.zip`)
13+
const targetZipFilePath = path.resolve(marketPkgPath, `target.zip`)
1314

1415
const filemanagerWebpackPlugin = new FileManagerWebpackPlugin({
1516
events: {
@@ -22,6 +23,9 @@ const filemanagerWebpackPlugin = new FileManagerWebpackPlugin({
2223
archive: [{
2324
source: outputPath,
2425
destination: normalZipFilePath,
26+
}, {
27+
source: outputPath,
28+
destination: targetZipFilePath,
2529
}]
2630
},
2731
]

0 commit comments

Comments
 (0)