-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-cli.cjs
129 lines (101 loc) · 3.69 KB
/
deploy-cli.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
const yargs = require('yargs');
const { execSync } = require('child_process');
yargs
.command(
"release",
"Create a new release",
(yargs) => {
return yargs
.option("semver", {
describe: "semantic version number",
type: "string",
demandOption: true,
})
.option("version_bump", {
describe: "minor, major",
type: "string",
demandOption: true,
});
},
(argv) => {
const version = argv.semver;
const versionBump = argv.version_bump;
console.log(version);
const releaseBranch = `release/v${version}`;
// Step 1: Make PR of your release branch into develop
// ... code for creating PR ...
// Step 2: Gain approval and merge your PR into develop
// ... code for merging PR ...
// Step 3: Checkout develop branch
execSync("git checkout develop");
// Step 4: Pull down any recent additions to develop branch
execSync("git pull");
// Step 5: Run QA on the develop branch deployment
// ... code for QA ...
// Step 6: Create a new release branch off develop
execSync(`git checkout -b ${releaseBranch}`);
// Step 7: Bump version of release accordingly in the package.json
execSync(`npm version ${versionBump} --no-git-tag-version`);
// Step 8: git add and commit the version bump
execSync("git add .");
execSync(`git commit -m "bump version v${version}"`);
// Step 9: Checkout the main branch
execSync("git checkout main");
// Step 10: Merge the release branch into the main branch
execSync(`git merge --no-ff ${releaseBranch}`);
// Step 11: Create a signed tag for the release
execSync(`git tag -s -a v${version} -m "Release v${version}"`);
// Step 12: Push the changes to GitHub
execSync("git push");
execSync("git push --tags");
// Step 13: Run QA on the main deployment
// ... code for QA ...
// Step 14: Merge the release branch back into develop
execSync("git checkout develop");
execSync(`git merge --no-ff ${releaseBranch}`);
execSync("git push");
// Step 15: In GitHub, create a release from the tag
// ... code for creating GitHub release ...
// Step 16: Mark your ticket done in Asana
// ... code for marking Asana ticket as done ...
}
)
.command(
"hotfix",
"Create a hotfix release",
(yargs) => {
return yargs
.option("semver", {
describe: "semantic version number",
type: "string",
demandOption: true,
})
},
(argv) => {
const version = argv.semver;
const hotfixBranch = `hotfix/v${version}`;
// Step 1: Create a new hotfix branch off main
execSync(`git checkout -b ${hotfixBranch}`);
// Step 2: Fix the issue
// Step 3: Bump version
execSync(`npm version patch --no-git-tag-version`);
// Step 4: git add and commit the version bump
execSync("git add .");
execSync(`git commit -m "bump version v${version}"`);
// Step 5: Create a PR
// Step 6: On approval, merge the hotfix branch into main
execSync("git checkout main");
execSync(`git merge --no-ff ${hotfixBranch}`);
// Step 7: Create a signed tag for the hotfix release
execSync(`git tag -s -a v${version} -m "Hotfix v${version}"`);
// Step 8: Push the changes to GitHub
execSync("git push");
execSync("git push --tags");
// Step 9: Merge the hotfix branch back into develop
execSync("git checkout develop");
execSync(`git merge --no-ff ${hotfixBranch}`);
execSync("git push");
}
)
.demandCommand()
.help().argv;