Skip to content

Commit 89dc0f7

Browse files
committed
vx: create git tags from changes
1 parent 85b6ded commit 89dc0f7

File tree

3 files changed

+42
-12
lines changed

3 files changed

+42
-12
lines changed

vx/commands/release.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const pushToLatestBranch = require('../scripts/release/steps/pushToLatestBranch');
1+
const commitChangesToGit = require('../scripts/release/steps/commitChangesToGit');
22

33
const build = require('vx/commands/build');
44
const logger = require('vx/logger');
@@ -49,5 +49,5 @@ async function releaseAll() {
4949
return;
5050
}
5151

52-
pushToLatestBranch();
52+
commitChangesToGit();
5353
}

vx/scripts/release/steps/pushToLatestBranch.js renamed to vx/scripts/release/steps/commitChangesToGit.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,44 @@ const logger = require('vx/logger');
1111
const packageNames = require('vx/packageNames');
1212
const vxPath = require('vx/vxPath');
1313

14-
const SCRIPT_PATH = path.resolve(
14+
const RELEASE_SCRIPTS = path.resolve(
1515
vxPath.VX_SCRIPTS_PATH,
1616
'release',
17-
'steps',
17+
'steps'
18+
);
19+
20+
const PUSH_TO_LATEST_BRANCH = path.resolve(
21+
RELEASE_SCRIPTS,
1822
'push_to_latest_branch.sh'
1923
);
2024

25+
const CREATE_GIT_TAG = path.resolve(RELEASE_SCRIPTS, 'create_git_tag.sh');
26+
2127
const EMOJIS = ['🚀', '🦺', '🤘', '✨', '🌈', '✅'];
2228

23-
function pushToLatestBranch() {
29+
function commitChangesToGit() {
2430
logger.info('🌎 Pushing latest branch.');
2531

2632
const allChanges = listAllChangesSinceStableBranch();
2733
const changedPackages = filterChangedPackages(allChanges);
34+
35+
pushToLatestBranch(allChanges, changedPackages);
36+
createTags(changedPackages);
37+
}
38+
39+
module.exports = commitChangesToGit;
40+
41+
function pushToLatestBranch(allChanges, changedPackages) {
2842
const messages = allChanges.map(({ title }) => title);
29-
const command = [
43+
44+
exec([
3045
'sh',
31-
SCRIPT_PATH,
46+
PUSH_TO_LATEST_BRANCH,
3247
`"${createCommitMessage(changedPackages)}"`,
3348
`"${messages.join('\n')}"`,
34-
].join(' ');
35-
36-
exec(command);
49+
]);
3750
}
3851

39-
module.exports = pushToLatestBranch;
40-
4152
function filterChangedPackages(commits) {
4253
return packageNames.list.filter(packageName => {
4354
return commits.some(({ title, files }) => {
@@ -60,3 +71,12 @@ function createCommitMessage(changedPackages) {
6071

6172
return `${sample(EMOJIS)} Updating: ${msg}`;
6273
}
74+
75+
function createTags(changedPackages) {
76+
return changedPackages.forEach(packageName => {
77+
const version = packageJson(packageName).version;
78+
const tag = `${packageName}@${version}`;
79+
80+
exec(['sh', CREATE_GIT_TAG, tag]);
81+
});
82+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
git config --global user.email $EMAIL_ADDRESS --replace-all
4+
git config --global user.name $GIT_NAME
5+
6+
echo "Creating Git Tag: $1"
7+
git tag -a "$1" -m "$1"
8+
9+
echo "Pushing Git Tag: $1"
10+
git push origin $1

0 commit comments

Comments
 (0)