ci(workflow): 完成版本设置脚本的开发

This commit is contained in:
fuyuhao 2023-05-15 16:52:42 +08:00 committed by 付宇豪
parent 6300b29bb6
commit 1df9619d96
4 changed files with 24 additions and 21 deletions

View File

@ -5,7 +5,6 @@ name: Release Version
on:
push:
branches: [ "main" ]
tags: ["v*"]
jobs:
build:
@ -37,9 +36,9 @@ jobs:
- name: install repo dependencies
run: |
yarn install --registry="https://registry.yarnpkg.com"
# - name: build
# run: |
# yarn build:all
- name: build
run: |
yarn build:all
- name: upload build
uses: actions/upload-artifact@v3
with:
@ -123,7 +122,7 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
# - name: publish
# run: |
# npm publish
# yarn workspaces foreach npm publish
- name: push to release branch
uses: EndBug/add-and-commit@v9
with:

0
scripts/workflow/get-package-version.mjs Normal file → Executable file
View File

36
scripts/workflow/set-package-version.mjs Normal file → Executable file
View File

@ -3,7 +3,8 @@
import { getPackageVersion } from './get-package-version.mjs'
import path from 'path';
import versionHelper from './version-helper.mjs';
const pkgJson = await fs.readJson(path.resolve(__dirname, '../package.json'));
const pkgDirs = path.resolve(__dirname, '../../packages')
const pkgNames = fs.readdirSync(pkgDirs);
const version = getPackageVersion();
@ -12,21 +13,24 @@ if (!version) {
process.exit(1)
}
for (let name of pkgNames) {
const jsonFilePath = path.resolve(__dirname, '../../packages/' + name + '/package.json')
console.log('reading json path');
const pkgJson = await fs.readJson(jsonFilePath);
pkgJson.version = version;
const tag = versionHelper.getVersionTag(versionHelper.addVersionPrefix(version));
pkgJson.publishConfig = Object.assign(pkgJson.publishConfig, {
tag: tag
});
pkgJson.version = version;
await fs.outputJson(
jsonFilePath,
pkgJson,
{
spaces: 2
}
)
}
const tag = versionHelper.getVersionTag(versionHelper.addVersionPrefix(version));
pkgJson.publishConfig = {
tag: tag
};
const jsonPath = path.join(__dirname, '../package.json');
await fs.outputJson(
jsonPath,
pkgJson,
{
spaces: 2
}
)

0
scripts/workflow/version-helper.mjs Normal file → Executable file
View File