-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5dec24f
commit c2e5bec
Showing
9 changed files
with
126 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Create Cli Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'cli-v*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# Setup .npmrc file to publish to npm | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm install | ||
- run: npm run build-cli | ||
- run: cd md-cli && npm ci && npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
name: Create Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
|
||
name: Create Release | ||
|
||
jobs: | ||
build: | ||
name: Create Release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
(async function () { | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
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 { | ||
console.log(`start: ${c}...`) | ||
console.log(child_process.execSync(c).toString('utf8')) | ||
} catch (error) { | ||
console.log('\x1B[31m%s\x1B[0m', error.stdout.toString()) | ||
process.exit(1) | ||
} | ||
}) | ||
const getNewVersion = (oldVersion, version = 'patch') => { | ||
// [<newversion> | major | minor | patch] | ||
if (/^([0-9]+\.*)+$/.test(version)) return version | ||
const types = ['major', 'minor', 'patch'] | ||
const index = types.indexOf(version) | ||
if (index >= 0) { | ||
const versionArr = oldVersion.split('.') | ||
versionArr[index] = Number(versionArr[index]) + 1 | ||
return versionArr.map((e, i) => i > index ? 0 : e).join('.') | ||
} | ||
return getNewVersion(oldVersion) | ||
} | ||
const newVersionObj = { | ||
version: getNewVersion(packageJson.version, process.argv[2]), | ||
}; | ||
fs.writeFileSync( | ||
path.resolve(__dirname, '../md-cli/package.json'), | ||
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) + | ||
'\n' | ||
); | ||
console.log(newVersionObj); | ||
execCommand([ | ||
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`, | ||
`git tag cli-v${newVersionObj.version}`, | ||
'git push && git push --tags', | ||
]) | ||
console.log('\x1B[32m%s\x1B[0m', '发布完成,请关注github CI构建') | ||
}()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.tgz | ||
httpData/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters