-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathci.js
47 lines (44 loc) · 1.21 KB
/
ci.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const path = require('path')
const ci = require('miniprogram-ci')
const fs = require('fs')
const packageJson = require('../package.json')
const privateKeyContent = process.env.WX_PRIVATE_KEY
if (!privateKeyContent) {
throw new Error('未找到私钥内容,请确保已正确配置 GitHub Secrets')
}
const privateKeyPath = path.resolve(__dirname, './private.key')
fs.writeFileSync(privateKeyPath, privateKeyContent)
const project = new ci.Project({
appid: 'wx622bee4f78fa4f5a',
type: 'miniProgram',
projectPath: path.resolve(__dirname, '../'),
privateKeyPath: path.resolve(__dirname, './key'),
ignores: [path.resolve(__dirname, '../miniprogram/node_modules/**/*')]
})
const robotNumber = 2
const params = {
onProgressUpdate: console.log,
robot: robotNumber,
version: packageJson.version,
desc: packageJson.bundleDescription,
setting: {
es7: true,
minifyJS: true,
minifyWXML: true,
minifyWXSS: true,
codeProtect: false,
autoPrefixWXSS: true
},
}
ci.upload({
project,
...params
}).then(res => {
console.debug('>>>>upload res', res)
}).catch(err => {
console.error('>>>>upload error', err)
throw err
}).finally(() => {
// 删除临时私钥文件
fs.unlinkSync(privateKeyPath)
})