Skip to content

Commit 613d222

Browse files
committed
chore: build: sign addon
1 parent 23d8804 commit 613d222

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

build/addon.mjs

+29-10
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ const UPDATE_URL = 'https://raw.githubusercontent.com/mbnuqw/sidebery/v5/updates
77

88
async function main() {
99
// Parse arguments
10-
const versionRE = /\d\d?\.\d\d?\.\d\d?\.?\d?\d?/
10+
const versionRE = /^\d\d?\.\d\d?\.\d\d?\.?\d?\d?\d?$/
1111
const version = process.argv[process.argv.length - 1]
1212
const is4Digit = version.split('.').length === 4
1313
const preserveVersion = process.argv.some(arg => arg === '--preserve')
14+
const sign = process.argv.some(arg => arg === '--sign')
1415
if (!versionRE.test(version)) {
1516
console.log('\nWrong target version (the last argument)')
1617
return
@@ -64,14 +65,7 @@ async function main() {
6465

6566
// Build ('build')
6667
console.log('Preparing code...')
67-
await execSync('node ./build/all.js', { encoding: 'utf-8', stdio: 'inherit' })
68-
69-
// Create './dist/sidebery-X.zip' ('build.ext')
70-
console.log('Creating addon...')
71-
await execSync('npx web-ext build --source-dir ./addon -a ./dist/ -i __tests__', {
72-
encoding: 'utf-8',
73-
stdio: 'inherit',
74-
})
68+
execSync('node ./build/all.js', { encoding: 'utf-8', stdio: 'inherit' })
7569

7670
// Revert version in package.json, package-lock.json and manifest.json
7771
const revertVersion = !preserveVersion && prevVersion && version !== prevVersion
@@ -114,6 +108,31 @@ async function main() {
114108
return
115109
}
116110
}
111+
112+
// Create './dist/sidebery-X.zip' ('build.ext')
113+
console.log('Creating addon archive...')
114+
execSync('npx web-ext build --source-dir ./addon -a ./dist/ -i __tests__', {
115+
encoding: 'utf-8',
116+
stdio: 'inherit',
117+
})
118+
119+
// Sign
120+
if (is4Digit && sign) {
121+
console.log('Signing addon...')
122+
123+
if (!process.env.WEB_EXT_API_KEY || !process.env.WEB_EXT_API_SECRET) {
124+
console.log('\nNo API key or secret')
125+
return
126+
}
127+
128+
execSync(
129+
'npx web-ext sign --use-submission-api --channel unlisted --source-dir ./addon -a ./dist/ -i __tests__',
130+
{
131+
encoding: 'utf-8',
132+
stdio: 'inherit',
133+
}
134+
)
135+
}
117136
}
118137

119-
main()
138+
await main()

0 commit comments

Comments
 (0)