Skip to content

Commit

Permalink
vx: create git tags from changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Apr 26, 2022
1 parent 85b6ded commit 89dc0f7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
4 changes: 2 additions & 2 deletions vx/commands/release.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const pushToLatestBranch = require('../scripts/release/steps/pushToLatestBranch');
const commitChangesToGit = require('../scripts/release/steps/commitChangesToGit');

const build = require('vx/commands/build');
const logger = require('vx/logger');
Expand Down Expand Up @@ -49,5 +49,5 @@ async function releaseAll() {
return;
}

pushToLatestBranch();
commitChangesToGit();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,44 @@ const logger = require('vx/logger');
const packageNames = require('vx/packageNames');
const vxPath = require('vx/vxPath');

const SCRIPT_PATH = path.resolve(
const RELEASE_SCRIPTS = path.resolve(
vxPath.VX_SCRIPTS_PATH,
'release',
'steps',
'steps'
);

const PUSH_TO_LATEST_BRANCH = path.resolve(
RELEASE_SCRIPTS,
'push_to_latest_branch.sh'
);

const CREATE_GIT_TAG = path.resolve(RELEASE_SCRIPTS, 'create_git_tag.sh');

const EMOJIS = ['🚀', '🦺', '🤘', '✨', '🌈', '✅'];

function pushToLatestBranch() {
function commitChangesToGit() {
logger.info('🌎 Pushing latest branch.');

const allChanges = listAllChangesSinceStableBranch();
const changedPackages = filterChangedPackages(allChanges);

pushToLatestBranch(allChanges, changedPackages);
createTags(changedPackages);
}

module.exports = commitChangesToGit;

function pushToLatestBranch(allChanges, changedPackages) {
const messages = allChanges.map(({ title }) => title);
const command = [

exec([
'sh',
SCRIPT_PATH,
PUSH_TO_LATEST_BRANCH,
`"${createCommitMessage(changedPackages)}"`,
`"${messages.join('\n')}"`,
].join(' ');

exec(command);
]);
}

module.exports = pushToLatestBranch;

function filterChangedPackages(commits) {
return packageNames.list.filter(packageName => {
return commits.some(({ title, files }) => {
Expand All @@ -60,3 +71,12 @@ function createCommitMessage(changedPackages) {

return `${sample(EMOJIS)} Updating: ${msg}`;
}

function createTags(changedPackages) {
return changedPackages.forEach(packageName => {
const version = packageJson(packageName).version;
const tag = `${packageName}@${version}`;

exec(['sh', CREATE_GIT_TAG, tag]);
});
}
10 changes: 10 additions & 0 deletions vx/scripts/release/steps/create_git_tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

git config --global user.email $EMAIL_ADDRESS --replace-all
git config --global user.name $GIT_NAME

echo "Creating Git Tag: $1"
git tag -a "$1" -m "$1"

echo "Pushing Git Tag: $1"
git push origin $1

2 comments on commit 89dc0f7

@vercel
Copy link

@vercel vercel bot commented on 89dc0f7 Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-next-ealush.vercel.app
vest-website.vercel.app
vest-next.vercel.app
vest-next-git-latest-ealush.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 89dc0f7 Apr 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest – ./website

vest-git-stable-ealush.vercel.app
www.vestjs.dev
vestjs.dev
vest.vercel.app
vest-ealush.vercel.app

Please sign in to comment.