mirror of
https://github.com/seepine/action-miniprogram-ci.git
synced 2025-04-09 15:40:15 +08:00
Compare commits
No commits in common. "main" and "v1.0.0" have entirely different histories.
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
// 保存时执行eslint
|
// 保存时执行eslint
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": "explicit"
|
"source.fixAll.eslint": true
|
||||||
},
|
},
|
||||||
// 从不展示扩展缩写
|
// 从不展示扩展缩写
|
||||||
"emmet.showExpandedAbbreviation": "never",
|
"emmet.showExpandedAbbreviation": "never",
|
||||||
|
16
README.md
16
README.md
@ -64,15 +64,13 @@ appid 和 setting 相关设置将会自动从 `project.config.json` 文件中读
|
|||||||
|
|
||||||
| Name | Description | Default |
|
| Name | Description | Default |
|
||||||
| ------------------ | ------------------------------------------------------------------------------------------------------------- | --------------------- |
|
| ------------------ | ------------------------------------------------------------------------------------------------------------- | --------------------- |
|
||||||
| platform | ci 平台,可选 wechat/douyin | wechat |
|
| mode | ci 模式,可选 upload/preview. | upload |
|
||||||
| ci-version | ci的版本,默认值 `miniprogram-ci@2.0.8`, `tt-ide-cli@0.1.27` | |
|
| type | 小程序类型,可选 miniProgram/miniProgramPlugin/miniGame/miniGamePlugin | miniProgram |
|
||||||
| mode | ci 模式,可选 upload/preview. | upload |
|
| project-path | 项目的路径,即 project.config.json 所在的目录,默认根路径,即./, 若 uniapp 项目,一般传入./dist/build/mp-weixin | ./ |
|
||||||
| type | 小程序类型,可选 miniProgram/miniProgramPlugin/miniGame/miniGamePlugin | miniProgram |
|
| private-key | 私钥,在获取项目属性和上传时用于鉴权使用,在微信公众平台上登录后下载, 建议通过 secrets 设置 | |
|
||||||
| project-path | 项目的路径,即 project.config.json 所在的目录,默认根路径,即./, 若 uniapp 项目,一般传入./dist/build/mp-weixin | ./ |
|
| private-key-path | 私钥完整路径,private-key 为空时使用路径值,例如./private.key | |
|
||||||
| private-key | 私钥,在获取项目属性和上传时用于鉴权使用,在微信公众平台上登录后下载, 建议通过 secrets 设置 | |
|
| ignores | 指定需要排除的规则,默认忽略 node_modules 路径 | node_modules/**/* |
|
||||||
| private-key-path | 私钥完整路径,private-key 为空时使用路径值,例如./private.key | |
|
| version | 自定义版本号,空则根据时间戳自动生成 YYYY.MMDD.HHmmss | YYYY.MMDD.HHmmss |
|
||||||
| ignores | 指定需要排除的规则,默认忽略 node_modules 路径 | node_modules/**/* |
|
|
||||||
| version | 自定义版本号,空则根据时间戳自动生成 YYYY.MMDD.HHmmss | YYYY.MMDD.HHmmss |
|
|
||||||
| desc | 自定义备注 | 'fix some bug.' |
|
| desc | 自定义备注 | 'fix some bug.' |
|
||||||
| robot | 指定使用哪一个 ci 机器人,可选值:1 ~ 30 | 1 |
|
| robot | 指定使用哪一个 ci 机器人,可选值:1 ~ 30 | 1 |
|
||||||
| threads | 指定本地编译过程中开启的线程数 | 默认获取 cpu 线程数 |
|
| threads | 指定本地编译过程中开启的线程数 | 默认获取 cpu 线程数 |
|
||||||
|
10
action.yml
10
action.yml
@ -1,18 +1,11 @@
|
|||||||
name: 'action-miniprogram-ci'
|
name: 'action-miniprogram-ci'
|
||||||
description: '将 miniprogram-ci 封装为 action,通过 Actions 实现小程序自动化上传/预览'
|
description: '将 miniprogram-ci 封装为 action,通过 Actions 实现小程序自动化上传/预览'
|
||||||
author: 'seepine'
|
author: 'seepine'
|
||||||
branding:
|
|
||||||
icon: package
|
|
||||||
color: orange
|
|
||||||
inputs:
|
inputs:
|
||||||
mode:
|
mode:
|
||||||
required: false
|
required: false
|
||||||
description: 'ci模式,默认upload,可选preview'
|
description: 'ci模式,默认upload,可选preview'
|
||||||
default: 'upload'
|
default: 'upload'
|
||||||
platform:
|
|
||||||
required: false
|
|
||||||
description: '平台,默认wechat,可选douyin'
|
|
||||||
default: 'wechat'
|
|
||||||
type:
|
type:
|
||||||
required: false
|
required: false
|
||||||
description: '小程序类型,默认miniProgram,可选miniProgram/miniProgramPlugin/miniGame/miniGamePlugin'
|
description: '小程序类型,默认miniProgram,可选miniProgram/miniProgramPlugin/miniGame/miniGamePlugin'
|
||||||
@ -71,9 +64,6 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
description: '设置输出文件路径,默认为./output.txt'
|
description: '设置输出文件路径,默认为./output.txt'
|
||||||
default: './output.txt'
|
default: './output.txt'
|
||||||
ci-version:
|
|
||||||
required: false
|
|
||||||
description: 'ci版本'
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
5605
dist/index.js
generated
vendored
5605
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
34
package.json
34
package.json
@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "action-miniprogram-ci",
|
"name": "action-miniprogram-ci",
|
||||||
"version": "1.2.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "将 miniprogram-ci 封装为 action, 通过 Actions 实现小程序自动化上传/预览",
|
"description": "将 miniprogram-ci 封装为 action, 通过 Actions 实现小程序自动化上传/预览",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"packageManager": "yarn@1.22.19",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"format": "prettier --write **/*.ts",
|
"format": "prettier --write **/*.ts",
|
||||||
@ -25,22 +24,23 @@
|
|||||||
"author": "seepine",
|
"author": "seepine",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.10.0",
|
"@actions/core": "~1.10.0",
|
||||||
"jimp": "0.22.10",
|
"jimp": "~0.22.10",
|
||||||
"jsqr": "1.4.0",
|
"jsqr": "~1.4.0",
|
||||||
"qrcode-terminal": "0.12.0"
|
"qrcode-terminal": "~0.12.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "18.16.3",
|
"@types/node": "~18.16.3",
|
||||||
"@typescript-eslint/parser": "5.59.2",
|
"@typescript-eslint/parser": "~5.59.2",
|
||||||
"@vercel/ncc": "0.36.1",
|
"@vercel/ncc": "~0.36.1",
|
||||||
"eslint": "8.39.0",
|
"eslint": "~8.39.0",
|
||||||
"eslint-plugin-github": "4.7.0",
|
"eslint-plugin-github": "~4.7.0",
|
||||||
"eslint-plugin-jest": "27.2.1",
|
"eslint-plugin-jest": "~27.2.1",
|
||||||
"jest": "29.5.0",
|
"jest": "~29.5.0",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "~4.1.0",
|
||||||
"prettier": "2.8.8",
|
"miniprogram-ci": "~1.9.8",
|
||||||
"ts-jest": "29.1.0",
|
"prettier": "~2.8.8",
|
||||||
"typescript": "5.0.4"
|
"ts-jest": "~29.1.0",
|
||||||
|
"typescript": "~5.0.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export const preview = async (option: Preview): Promise<string> => {
|
|||||||
}
|
}
|
||||||
const command = [
|
const command = [
|
||||||
'npx',
|
'npx',
|
||||||
`miniprogram-ci@${option.ciVersion || '2.0.8'}`,
|
'miniprogram-ci',
|
||||||
'preview',
|
'preview',
|
||||||
...getArgs(option),
|
...getArgs(option),
|
||||||
...previewArgs
|
...previewArgs
|
||||||
|
@ -4,12 +4,9 @@ import {getArgs} from './utils'
|
|||||||
import * as cp from 'child_process'
|
import * as cp from 'child_process'
|
||||||
|
|
||||||
export const upload = async (option: Upload): Promise<void> => {
|
export const upload = async (option: Upload): Promise<void> => {
|
||||||
const command = [
|
const command = ['npx', 'miniprogram-ci', 'upload', ...getArgs(option)].join(
|
||||||
'npx',
|
' '
|
||||||
`miniprogram-ci@${option.ciVersion || '2.0.8'}`,
|
)
|
||||||
'upload',
|
|
||||||
...getArgs(option)
|
|
||||||
].join(' ')
|
|
||||||
|
|
||||||
core.info('Command:')
|
core.info('Command:')
|
||||||
core.info(` ${command}`)
|
core.info(` ${command}`)
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
import {Preview} from '../type'
|
|
||||||
import * as core from '@actions/core'
|
|
||||||
import {generate, getQrCode} from '../utils/qrcode'
|
|
||||||
import fs from 'fs'
|
|
||||||
import {getArgs} from './utils'
|
|
||||||
import * as cp from 'child_process'
|
|
||||||
|
|
||||||
export const preview = async (option: Preview): Promise<string> => {
|
|
||||||
cp.execSync(
|
|
||||||
[
|
|
||||||
'npx',
|
|
||||||
`tt-ide-cli@${option.ciVersion || '0.1.27'}`,
|
|
||||||
'set-app-config',
|
|
||||||
option.appid,
|
|
||||||
'--token',
|
|
||||||
option.privateKey
|
|
||||||
].join(' ')
|
|
||||||
)
|
|
||||||
|
|
||||||
const command = [
|
|
||||||
'npx',
|
|
||||||
`tt-ide-cli@${option.ciVersion || '0.1.27'}`,
|
|
||||||
'preview',
|
|
||||||
...getArgs(option),
|
|
||||||
'--qrcode-output',
|
|
||||||
option.qrcodeOutputDest,
|
|
||||||
option.projectPath
|
|
||||||
].join(' ')
|
|
||||||
core.info('Command:')
|
|
||||||
core.info(` ${command}`)
|
|
||||||
cp.execSync(command)
|
|
||||||
cp.execSync(`npx ${`tt-ide-cli@${option.ciVersion || '0.1.27'}`} logout`)
|
|
||||||
if (option.qrcodeFormat === 'terminal') {
|
|
||||||
const qrcodeData = await getQrCode(option.qrcodeOutputDest)
|
|
||||||
const qrcode = await generate(qrcodeData)
|
|
||||||
core.info(`Generate terminal qrcode:\n${qrcode}`)
|
|
||||||
fs.promises.unlink(option.qrcodeOutputDest)
|
|
||||||
return qrcode
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
import {Upload} from '../type'
|
|
||||||
import * as core from '@actions/core'
|
|
||||||
import {getArgs} from './utils'
|
|
||||||
import * as cp from 'child_process'
|
|
||||||
|
|
||||||
export const upload = async (option: Upload): Promise<void> => {
|
|
||||||
cp.execSync(
|
|
||||||
[
|
|
||||||
'npx',
|
|
||||||
`tt-ide-cli@${option.ciVersion || '0.1.27'}`,
|
|
||||||
'set-app-config',
|
|
||||||
option.appid,
|
|
||||||
'--token',
|
|
||||||
option.privateKey
|
|
||||||
].join(' ')
|
|
||||||
)
|
|
||||||
const command = [
|
|
||||||
'npx',
|
|
||||||
`tt-ide-cli@${option.ciVersion || '0.1.27'}`,
|
|
||||||
'upload',
|
|
||||||
...getArgs(option),
|
|
||||||
option.projectPath
|
|
||||||
].join(' ')
|
|
||||||
core.info('Command:')
|
|
||||||
core.info(` ${command}`)
|
|
||||||
cp.execSync(command)
|
|
||||||
cp.execSync(`npx ${`tt-ide-cli@${option.ciVersion || '0.1.27'}`} logout`)
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
import {CiOption} from '../type'
|
|
||||||
import * as core from '@actions/core'
|
|
||||||
|
|
||||||
export const getArgs = (option: CiOption): string[] => {
|
|
||||||
const args = []
|
|
||||||
if (option.version) {
|
|
||||||
args.push(...[' --app-version', `'${option.version}'`])
|
|
||||||
}
|
|
||||||
if (option.desc) {
|
|
||||||
args.push(...['--app-changelog', `'${option.desc}'`])
|
|
||||||
}
|
|
||||||
core.debug(args.toString())
|
|
||||||
return args
|
|
||||||
}
|
|
20
src/main.ts
20
src/main.ts
@ -11,7 +11,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
CiOption,
|
CiOption,
|
||||||
filterMode,
|
filterMode,
|
||||||
filterPlatform,
|
|
||||||
filterQrcodeFormat,
|
filterQrcodeFormat,
|
||||||
filterType,
|
filterType,
|
||||||
Preview
|
Preview
|
||||||
@ -21,8 +20,6 @@ import * as fs from 'fs'
|
|||||||
import * as os from 'os'
|
import * as os from 'os'
|
||||||
import {upload} from './ci/upload'
|
import {upload} from './ci/upload'
|
||||||
import {preview} from './ci/preview'
|
import {preview} from './ci/preview'
|
||||||
import {upload as dyUpload} from './douyin/upload'
|
|
||||||
import {preview as dyPreview} from './douyin/preview'
|
|
||||||
|
|
||||||
const defaultPrivateKeyPath = '../private.key'
|
const defaultPrivateKeyPath = '../private.key'
|
||||||
|
|
||||||
@ -37,7 +34,6 @@ async function run(): Promise<void> {
|
|||||||
|
|
||||||
option = {
|
option = {
|
||||||
mode: filterMode(getInput(Inputs.mode)),
|
mode: filterMode(getInput(Inputs.mode)),
|
||||||
platform: filterPlatform(getInput(Inputs.platform)),
|
|
||||||
appid: '',
|
appid: '',
|
||||||
type: filterType(getInput(Inputs.type)),
|
type: filterType(getInput(Inputs.type)),
|
||||||
projectPath: getInput(Inputs.projectPath) || '',
|
projectPath: getInput(Inputs.projectPath) || '',
|
||||||
@ -48,9 +44,7 @@ async function run(): Promise<void> {
|
|||||||
version: getInput(Inputs.version) || '',
|
version: getInput(Inputs.version) || '',
|
||||||
desc: getInput(Inputs.desc),
|
desc: getInput(Inputs.desc),
|
||||||
robot: getInputAsInt(Inputs.robot),
|
robot: getInputAsInt(Inputs.robot),
|
||||||
threads: getInputAsInt(Inputs.threads),
|
threads: getInputAsInt(Inputs.threads)
|
||||||
|
|
||||||
ciVersion: getInput(Inputs.ciVersion)
|
|
||||||
}
|
}
|
||||||
if (getInput(Inputs.mode) === 'test') {
|
if (getInput(Inputs.mode) === 'test') {
|
||||||
isTest = true
|
isTest = true
|
||||||
@ -103,11 +97,7 @@ async function run(): Promise<void> {
|
|||||||
} else if (option.mode === 'upload') {
|
} else if (option.mode === 'upload') {
|
||||||
core.info('Options:')
|
core.info('Options:')
|
||||||
core.info(`${stringify(option)}`)
|
core.info(`${stringify(option)}`)
|
||||||
if (option.platform === 'wechat') {
|
upload(option)
|
||||||
await upload(option)
|
|
||||||
} else {
|
|
||||||
await dyUpload(option)
|
|
||||||
}
|
|
||||||
} else if (option.mode === 'preview') {
|
} else if (option.mode === 'preview') {
|
||||||
const previewOption: Preview = {
|
const previewOption: Preview = {
|
||||||
...option,
|
...option,
|
||||||
@ -125,11 +115,7 @@ async function run(): Promise<void> {
|
|||||||
)
|
)
|
||||||
core.info('Options:')
|
core.info('Options:')
|
||||||
core.info(`${stringify(previewOption)}`)
|
core.info(`${stringify(previewOption)}`)
|
||||||
if (option.platform === 'wechat') {
|
qrcode = await preview(previewOption)
|
||||||
qrcode = await preview(previewOption)
|
|
||||||
} else {
|
|
||||||
qrcode = await dyPreview(previewOption)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (autoPrivateKey) {
|
if (autoPrivateKey) {
|
||||||
fs.promises.unlink(option.privateKeyPath)
|
fs.promises.unlink(option.privateKeyPath)
|
||||||
|
@ -22,12 +22,8 @@ export const filterMode = (type?: string): Mode => {
|
|||||||
return 'upload'
|
return 'upload'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const filterPlatform = (val?: string): 'wechat' | 'douyin' => {
|
|
||||||
return val === 'douyin' ? 'douyin' : 'wechat'
|
|
||||||
}
|
|
||||||
export type CiOption = {
|
export type CiOption = {
|
||||||
mode: Mode
|
mode: Mode
|
||||||
platform: 'wechat' | 'douyin'
|
|
||||||
appid: string
|
appid: string
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
setting?: any
|
setting?: any
|
||||||
@ -40,8 +36,6 @@ export type CiOption = {
|
|||||||
desc?: string
|
desc?: string
|
||||||
robot?: number
|
robot?: number
|
||||||
threads?: number
|
threads?: number
|
||||||
|
|
||||||
ciVersion?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Upload = CiOption & {}
|
export type Upload = CiOption & {}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/* eslint-disable no-shadow */
|
/* eslint-disable no-shadow */
|
||||||
export enum Inputs {
|
export enum Inputs {
|
||||||
mode = 'mode',
|
mode = 'mode',
|
||||||
platform = 'platform',
|
|
||||||
type = 'type',
|
type = 'type',
|
||||||
projectPath = 'project-path',
|
projectPath = 'project-path',
|
||||||
privateKey = 'private-key',
|
privateKey = 'private-key',
|
||||||
@ -19,9 +18,7 @@ export enum Inputs {
|
|||||||
scene = 'scene',
|
scene = 'scene',
|
||||||
// output
|
// output
|
||||||
output = 'output',
|
output = 'output',
|
||||||
outputPath = 'output-path',
|
outputPath = 'output-path'
|
||||||
|
|
||||||
ciVersion = 'ci-version'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum Outputs {
|
export enum Outputs {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user