Skip to content
Snippets Groups Projects
Unverified Commit 80082e05 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

ci(release): fix version replace

parent d22c896a
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,7 @@ export async function bumpNextVersion({
const newBranch = `release-${finalVersion}`;
// update root package.json
core.info('bump main package.json version');
updateVersionPackageJson(cwd, newVersion);
// TODO check if branch exists
......@@ -63,6 +64,7 @@ export async function bumpNextVersion({
await exec('git', ['add', '.']);
await exec('git', ['commit', '-m', newVersion]);
core.info('fix dependencies in workspace packages');
await fixWorkspaceVersionsBeforePublish();
await exec('yarn', ['changeset', 'publish']);
......@@ -80,8 +82,11 @@ export async function bumpNextVersion({
body: prBody,
...github.context.repo,
});
} else {
core.info('no pull request created: release is not the first candidate');
}
core.info('create release');
await octokit.rest.repos.createRelease({
name: newVersion,
tag_name: newVersion,
......
......@@ -3,6 +3,7 @@ import path from 'path';
import { exec } from '@actions/exec';
import * as github from '@actions/github';
import * as core from '@actions/core';
import { createNpmFile } from './createNpmFile';
import { setupOctokit } from './setupOctokit';
......@@ -71,17 +72,20 @@ export async function publishRelease({
const releaseBody = changelogEntry.content;
// update root package.json
core.info('bump main package.json version');
updateVersionPackageJson(cwd, newVersion);
await exec('git', ['add', '.']);
await exec('git', ['commit', '-m', newVersion]);
core.info('fix dependencies in workspace packages');
await fixWorkspaceVersionsBeforePublish();
await exec('yarn', ['changeset', 'publish']);
await exec('git', ['push', '--follow-tags']);
core.info('create release');
await octokit.rest.repos.createRelease({
name: newVersion,
tag_name: newVersion,
......
......@@ -38,6 +38,7 @@ export async function startPatchRelease({
// TODO check if branch exists
await exec('git', ['checkout', '-b', newBranch]);
core.info('bump main package.json version');
updateVersionPackageJson(cwd, newVersion);
await exec('git', ['add', '.']);
......@@ -57,5 +58,7 @@ export async function startPatchRelease({
body: '',
...github.context.repo,
});
} else {
core.info('no pull request created: patch is not for current version');
}
}
......@@ -61,6 +61,6 @@ export function getChangelogEntry(changelog: string, version: string) {
export function updateVersionPackageJson(cwd = process.cwd(), newVersion: string) {
const rootPackageJsonPath = path.resolve(cwd, 'package.json');
const content = fs.readFileSync(rootPackageJsonPath, 'utf8');
const updatedContent = content.replace(/'version': '.*',$/m, `'version': '${newVersion}',`);
const updatedContent = content.replace(/"version": ".*",$/m, `"version": "${newVersion}",`);
fs.writeFileSync(rootPackageJsonPath, updatedContent);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment