Skip to content

Commit

Permalink
chore(BuildTool): publish with same distTag for next and next-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 committed Dec 29, 2023
1 parent c3a0f5f commit 92398c6
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions tools/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,7 @@ const pushPlatformDocs = {
},
};

async function publishNpm() {
const { version } = getVersion();
const versionTag = version.match(/[a-z]+/)?.[0];
const distTag: string =
ARGV.tag ||
versionTag ||
(
await inquirer.prompt({
name: 'tag',
type: 'list',
choices: ['latest', 'next', 'beta'],
default: 0,
message: 'publish dist-tags:',
})
).tag;
async function publishNpm(distTag = 'latest') {
execSync('npm', ['publish', '--tag', distTag]);
execSync('tnpm', ['sync', '@alifd/next']);
}
Expand Down Expand Up @@ -243,7 +229,7 @@ async function githubRelease() {
.then(() => {});
}

async function publishNpmForDocs() {
async function publishNpmForDocs(distTag = 'latest') {
const { version } = getVersion();
const docs = NEXT_DOCS_PATH;

Expand All @@ -268,7 +254,7 @@ async function publishNpmForDocs() {
});
fs.writeFileSync(pkgPath, pkgContent);
logger.log('Generate @alifd/next-docs successfully!');
execSync('npm', ['publish'], { cwd: docs });
execSync('npm', ['publish', '--tag', distTag], { cwd: docs });
execSync('tnpm', ['sync', NEXT_DOCS_NAME], { cwd: docs });
fs.removeSync(docs);
}
Expand Down Expand Up @@ -331,16 +317,35 @@ registryTask(__filename, 'release', async () => {

await registryCheck(__filename);


await registryTask(__filename, 'release check', async () => {
await registryCheckSass(__filename);
await registryTask(__filename, 'check git tag', checkTags);
await registryTask(__filename, 'check build outputs', checkFiles);
});

await registryTask(__filename, 'publish next to npm', publishNpm);
await registryTask(__filename, 'publish next-docs to npm', publishNpmForDocs, () => {
fs.removeSync(NEXT_DOCS_PATH);
await registryTask(__filename, 'publish to npm', async () => {
const { version } = getVersion();
const versionTag = version.match(/[a-z]+/)?.[0];
const distTag: string =
ARGV.tag ||
versionTag ||
(
await inquirer.prompt({
name: 'tag',
type: 'list',
choices: ['latest', 'next', 'beta'],
default: 0,
message: 'publish dist-tags:',
})
).tag;
await registryTask(__filename, 'publish next to npm', publishNpm.bind(undefined, distTag));
await registryTask(
__filename,
'publish next-docs to npm',
publishNpmForDocs.bind(undefined, distTag),
() => {
fs.removeSync(NEXT_DOCS_PATH);
}
);
});

const commitRollbackFns = new Set<() => unknown>();
Expand Down

0 comments on commit 92398c6

Please sign in to comment.