mirror of
https://github.com/doocs/md.git
synced 2025-02-02 11:17:49 +08:00
chore: update cli (#460)
This commit is contained in:
parent
ec7a46f4da
commit
dbb1af10a8
4
.github/workflows/preview-build.yml
vendored
4
.github/workflows/preview-build.yml
vendored
@ -25,7 +25,7 @@ jobs:
|
|||||||
npm run build:h5-netlify
|
npm run build:h5-netlify
|
||||||
|
|
||||||
- name: Upload dist artifact
|
- name: Upload dist artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
@ -37,7 +37,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload PR number
|
- name: Upload PR number
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: pr
|
name: pr
|
||||||
path: ./pr-id.txt
|
path: ./pr-id.txt
|
||||||
|
12
.github/workflows/preview-deploy.yml
vendored
12
.github/workflows/preview-deploy.yml
vendored
@ -12,7 +12,7 @@ jobs:
|
|||||||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.repository == 'doocs/md'
|
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.repository == 'doocs/md'
|
||||||
steps:
|
steps:
|
||||||
- name: Download PR artifact
|
- name: Download PR artifact
|
||||||
uses: dawidd6/action-download-artifact@v6
|
uses: dawidd6/action-download-artifact@v2
|
||||||
with:
|
with:
|
||||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||||
name: pr
|
name: pr
|
||||||
@ -22,7 +22,7 @@ jobs:
|
|||||||
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"
|
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Download dist artifact
|
- name: Download dist artifact
|
||||||
uses: dawidd6/action-download-artifact@v6
|
uses: dawidd6/action-download-artifact@v2
|
||||||
with:
|
with:
|
||||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||||
workflow_conclusion: success
|
workflow_conclusion: success
|
||||||
@ -35,7 +35,7 @@ jobs:
|
|||||||
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
|
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
|
||||||
|
|
||||||
- name: Upload status comment
|
- name: Upload status comment
|
||||||
uses: actions-cool/maintain-one-comment@v3
|
uses: actions-cool/maintain-one-comment@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
body: |
|
body: |
|
||||||
@ -49,7 +49,7 @@ jobs:
|
|||||||
|
|
||||||
- name: The job failed
|
- name: The job failed
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: actions-cool/maintain-one-comment@v3
|
uses: actions-cool/maintain-one-comment@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
body: |
|
body: |
|
||||||
@ -66,7 +66,7 @@ jobs:
|
|||||||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && github.repository == 'doocs/md'
|
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && github.repository == 'doocs/md'
|
||||||
steps:
|
steps:
|
||||||
- name: Download PR artifact
|
- name: Download PR artifact
|
||||||
uses: dawidd6/action-download-artifact@v6
|
uses: dawidd6/action-download-artifact@v2
|
||||||
with:
|
with:
|
||||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||||
name: pr
|
name: pr
|
||||||
@ -76,7 +76,7 @@ jobs:
|
|||||||
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"
|
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: The job failed
|
- name: The job failed
|
||||||
uses: actions-cool/maintain-one-comment@v3
|
uses: actions-cool/maintain-one-comment@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
body: |
|
body: |
|
||||||
|
@ -1,44 +1,48 @@
|
|||||||
|
import fs from 'fs/promises';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
import packageJson from '../md-cli/package.json' assert { type: 'json' };
|
||||||
|
import child_process from 'child_process';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
(async function () {
|
(async function () {
|
||||||
const fs = require('fs');
|
const execCommand = (arr) =>
|
||||||
const path = require('path');
|
(Array.isArray(arr) ? arr : [arr]).forEach((c) => {
|
||||||
const packageJson = require('../md-cli/package.json');
|
|
||||||
const child_process = require('child_process');
|
|
||||||
// 自动更新版本
|
|
||||||
// version可以传递如 6.1.1 | patch | minor | major
|
|
||||||
const execCommand = arr => (Array.isArray(arr) ? arr : [arr]).forEach(c => {
|
|
||||||
try {
|
try {
|
||||||
console.log(`start: ${c}...`)
|
console.log(`start: ${c}...`);
|
||||||
console.log(child_process.execSync(c).toString('utf8'))
|
console.log(child_process.execSync(c).toString("utf8"));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('\x1B[31m%s\x1B[0m', error.stdout.toString())
|
console.log("\x1B[31m%s\x1B[0m", error.stdout.toString());
|
||||||
process.exit(1)
|
process.exit(1);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
const getNewVersion = (oldVersion, version = 'patch') => {
|
const getNewVersion = (oldVersion, version = "patch") => {
|
||||||
// [<newversion> | major | minor | patch]
|
// [<newversion> | major | minor | patch]
|
||||||
if (/^([0-9]+\.*)+$/.test(version)) return version
|
if (/^([0-9]+\.*)+$/.test(version)) return version;
|
||||||
const types = ['major', 'minor', 'patch']
|
const types = ["major", "minor", "patch"];
|
||||||
const index = types.indexOf(version)
|
const index = types.indexOf(version);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
const versionArr = oldVersion.split('.')
|
const versionArr = oldVersion.split(".");
|
||||||
versionArr[index] = Number(versionArr[index]) + 1
|
versionArr[index] = Number(versionArr[index]) + 1;
|
||||||
return versionArr.map((e, i) => i > index ? 0 : e).join('.')
|
return versionArr.map((e, i) => (i > index ? 0 : e)).join(".");
|
||||||
}
|
|
||||||
return getNewVersion(oldVersion)
|
|
||||||
}
|
}
|
||||||
|
return getNewVersion(oldVersion);
|
||||||
|
};
|
||||||
const newVersionObj = {
|
const newVersionObj = {
|
||||||
version: getNewVersion(packageJson.version, process.argv[2]),
|
version: getNewVersion(packageJson.version, process.argv[2]),
|
||||||
};
|
};
|
||||||
fs.writeFileSync(
|
await fs.writeFile(
|
||||||
path.resolve(__dirname, '../md-cli/package.json'),
|
path.resolve(__dirname, "../md-cli/package.json"),
|
||||||
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) +
|
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) +
|
||||||
'\n'
|
"\n"
|
||||||
);
|
);
|
||||||
console.log(newVersionObj);
|
console.log(newVersionObj);
|
||||||
execCommand([
|
execCommand([
|
||||||
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`,
|
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`,
|
||||||
`git tag cli-v${newVersionObj.version}`,
|
`git tag cli-v${newVersionObj.version}`,
|
||||||
'git push && git push --tags',
|
"git push && git push --tags",
|
||||||
])
|
]);
|
||||||
console.log('\x1B[32m%s\x1B[0m', '发布完成,请关注github CI构建')
|
console.log("\x1B[32m%s\x1B[0m", "发布完成,请关注 GitHub CI 构建");
|
||||||
}())
|
})();
|
||||||
|
@ -16,7 +16,7 @@ new Promise(async () => {
|
|||||||
;[port, testPort, replayPort] = await Promise.all([port, port+1, port+2].map(item => getPort({port: item}) )).catch(err => console.log(`err`, err))
|
;[port, testPort, replayPort] = await Promise.all([port, port+1, port+2].map(item => getPort({port: item}) )).catch(err => console.log(`err`, err))
|
||||||
const line = Object.entries({
|
const line = Object.entries({
|
||||||
...arg,
|
...arg,
|
||||||
proxy: `https://doocs.gitee.io/`,
|
proxy: `https://doocs-md.pages.dev`,
|
||||||
port,
|
port,
|
||||||
testPort,
|
testPort,
|
||||||
replayPort,
|
replayPort,
|
||||||
|
3748
md-cli/package-lock.json
generated
3748
md-cli/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@doocs/md-cli",
|
"name": "@doocs/md-cli",
|
||||||
"version": "0.0.7",
|
"version": "0.0.8",
|
||||||
"description": "✍ 一款高度简洁的微信 Markdown 编辑器:支持 Markdown 所有基础语法、色盘取色、一键复制并粘贴到公众号后台、多图上传、一键下载文档、自定义 CSS 样式、一键重置等特性",
|
"description": "✍ 一款高度简洁的微信 Markdown 编辑器:支持 Markdown 所有基础语法、色盘取色、一键复制并粘贴到公众号后台、多图上传、一键下载文档、自定义 CSS 样式、一键重置等特性",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
Reference in New Issue
Block a user