Skip to content

Commit

Permalink
chore: dev release workflow (QwikDev#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Jan 6, 2022
1 parent bd6ecdd commit ff632b1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ import { buildCli } from './cli';
* use TSC + Rollup + Terser for the core submodule.
*/
export async function build(config: BuildConfig) {
config.devRelease = config.devRelease || (!!config.release && config.setDistTag === 'dev');
try {
if (config.prepareRelease) {
// locally set the version for the upcoming release
await prepareReleaseVersion(config);
} else if (config.release && !config.dryRun) {
} else if (config.release && !config.dryRun && !config.devRelease) {
// ci release, npm publish
await setReleaseVersion(config);
} else {
Expand Down
20 changes: 13 additions & 7 deletions scripts/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export async function publish(config: BuildConfig) {

const distPkgDir = config.distPkgDir;
const distPkg = await readPackageJson(distPkgDir);
const version = distPkg.version;
const version = config.devRelease ? config.distVersion : distPkg.version;
const gitTag = `v${version}`;
const distTag = config.setDistTag || 'dev';

Expand Down Expand Up @@ -146,7 +146,9 @@ export async function publish(config: BuildConfig) {
// production release
// git push to the repo w/ --dry-run flag to make sure we're good before publishing
const gitPushArgs = ['push', '--follow-tags'];
await run('git', gitPushArgs, false, true);
if (!config.devRelease) {
await run('git', gitPushArgs, false, true);
}

// if we've made it this far then the npm publish dry-run passed
// and all of the git commands worked, time to publish!!
Expand All @@ -155,13 +157,17 @@ export async function publish(config: BuildConfig) {

console.log(` https://www.npmjs.com/package/${distPkg.name}`);

// git push to the production repo w/out the dry-run flag
// now that it's officially published to npm
await run('git', gitPushArgs, false, false);
if (!config.devRelease) {
// git push to the production repo w/out the dry-run flag
// now that it's officially published to npm
await run('git', gitPushArgs, false, false);
}
}

// create a github release using the git tag we just pushed
await createGithubRelease(version, gitTag, isDryRun);
if (!config.devRelease) {
// create a github release using the git tag we just pushed
await createGithubRelease(version, gitTag, isDryRun);
}

console.log(
`🐋 published version "${version}" of ${distPkg.name} with dist-tag "${distTag}" to npm`,
Expand Down
2 changes: 2 additions & 0 deletions scripts/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface BuildConfig {
platformBinding?: boolean;
prepareRelease?: boolean;
release?: boolean;
devRelease?: boolean;
setDistTag?: string;
tsc?: boolean;
validate?: boolean;
Expand Down Expand Up @@ -83,6 +84,7 @@ export function loadConfig(args: string[] = []) {
config.prepareRelease = (config as any)['prepare-release'];
config.platformTarget = (config as any)['platform-target'];
config.setDistTag = (config as any)['set-dist-tag'];
config.devRelease = !!(config as any)['dev-release'];
config.dryRun = (config as any)['dry-run'];

return config;
Expand Down

0 comments on commit ff632b1

Please sign in to comment.