Skip to content

Commit e939fe9

Browse files
feat: build for release
1 parent 6c72342 commit e939fe9

File tree

21 files changed

+248
-223
lines changed

21 files changed

+248
-223
lines changed

build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"owner":"technote-space","repo":"release-github-actions","sha":"8cb3e8db48ca27970ebb06f8fb5e81b9e9595e80","ref":"refs/tags/test/v7.0.7.1161048463","tagName":"test/v7.0.7.1161048463","branch":"gh-actions","tags":["test/v7.0.7.1161048463","test/v7.0.7","test/v7.0","test/v7"],"updated_at":"2021-08-24T03:03:06.063Z"}
1+
{"owner":"technote-space","repo":"release-github-actions","sha":"b5cd4543f7d4155a18e3d6816c338f7914c7b1b2","ref":"refs/tags/test/v7.0.7.1176305931","tagName":"test/v7.0.7.1176305931","branch":"gh-actions","tags":["test/v7.0.7.1176305931","test/v7.0.7","test/v7.0","test/v7"],"updated_at":"2021-08-28T03:03:21.511Z"}

lib/constant.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const misc_1 = require("./utils/misc");
55
exports.DEFAULT_FETCH_DEPTH = 3;
66
exports.TARGET_EVENTS = {
77
'create': [
8-
(context) => misc_1.isValidContext(context),
8+
(context) => (0, misc_1.isValidContext)(context),
99
],
1010
'release': [
1111
[
1212
'published',
13-
(context) => misc_1.isValidContext(context),
13+
(context) => (0, misc_1.isValidContext)(context),
1414
],
1515
],
1616
'push': [
17-
(context) => misc_1.isValidContext(context),
17+
(context) => (0, misc_1.isValidContext)(context),
1818
],
1919
};

lib/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ const constant_1 = require("./constant");
2020
const run = () => __awaiter(void 0, void 0, void 0, function* () {
2121
const logger = new github_action_log_helper_1.Logger();
2222
const context = new context_1.Context();
23-
github_action_helper_1.ContextHelper.showActionInfo(path_1.resolve(__dirname, '..'), logger, context);
24-
if (!filter_github_action_1.isTargetEvent(constant_1.TARGET_EVENTS, context)) {
23+
github_action_helper_1.ContextHelper.showActionInfo((0, path_1.resolve)(__dirname, '..'), logger, context);
24+
if (!(0, filter_github_action_1.isTargetEvent)(constant_1.TARGET_EVENTS, context)) {
2525
logger.info('This is not target event.');
2626
return;
2727
}
28-
yield command_1.deploy(github_action_helper_1.Utils.getOctokit(), context);
28+
yield (0, command_1.deploy)(github_action_helper_1.Utils.getOctokit(), context);
2929
});
3030
run().catch(error => {
3131
console.log(error);
32-
core_1.setFailed(error.message);
32+
(0, core_1.setFailed)(error.message);
3333
});

lib/utils/command.js

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,53 +16,53 @@ const github_action_helper_1 = require("@technote-space/github-action-helper");
1616
const github_action_log_helper_1 = require("@technote-space/github-action-log-helper");
1717
const misc_1 = require("./misc");
1818
const replaceDirectory = (context) => (message) => {
19-
const directories = misc_1.getReplaceDirectory(context);
19+
const directories = (0, misc_1.getReplaceDirectory)(context);
2020
return Object.keys(directories).reduce((value, directory) => github_action_helper_1.Utils.replaceAll(github_action_helper_1.Utils.replaceAll(value, ` -C ${directory}`, ''), directory, directories[directory]), message);
2121
};
2222
exports.replaceDirectory = replaceDirectory;
2323
const prepareFiles = (logger, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
24-
const { buildDir, pushDir } = misc_1.getParams(context);
25-
fs_1.mkdirSync(buildDir, { recursive: true });
24+
const { buildDir, pushDir } = (0, misc_1.getParams)(context);
25+
(0, fs_1.mkdirSync)(buildDir, { recursive: true });
2626
logger.startProcess('Cloning the remote repo for build...');
2727
yield helper.checkout(buildDir, context);
2828
logger.startProcess('Running build for release...');
29-
yield helper.runCommand(buildDir, misc_1.getBuildCommands(buildDir, pushDir));
29+
yield helper.runCommand(buildDir, (0, misc_1.getBuildCommands)(buildDir, pushDir));
3030
});
3131
exports.prepareFiles = prepareFiles;
3232
const createBuildInfoFile = (logger, context) => __awaiter(void 0, void 0, void 0, function* () {
33-
const filename = misc_1.getOutputBuildInfoFilename();
33+
const filename = (0, misc_1.getOutputBuildInfoFilename)();
3434
if (!filename) {
3535
return;
3636
}
37-
const { buildDir, branchName, tagName } = misc_1.getParams(context);
37+
const { buildDir, branchName, tagName } = (0, misc_1.getParams)(context);
3838
logger.startProcess('Creating build info file...');
39-
const filepath = path_1.resolve(buildDir, filename);
40-
const dir = path_1.dirname(filepath);
41-
if (!fs_1.existsSync(dir)) {
42-
fs_1.mkdirSync(dir, { recursive: true });
39+
const filepath = (0, path_1.resolve)(buildDir, filename);
40+
const dir = (0, path_1.dirname)(filepath);
41+
if (!(0, fs_1.existsSync)(dir)) {
42+
(0, fs_1.mkdirSync)(dir, { recursive: true });
4343
}
44-
fs_1.writeFileSync(filepath, JSON.stringify({
44+
(0, fs_1.writeFileSync)(filepath, JSON.stringify({
4545
owner: context.repo.owner,
4646
repo: context.repo.repo,
4747
sha: context.sha,
4848
ref: context.ref,
4949
tagName: tagName,
5050
branch: branchName,
51-
tags: misc_1.getCreateTags(tagName),
51+
tags: (0, misc_1.getCreateTags)(tagName),
5252
'updated_at': (new Date).toISOString(),
5353
}));
5454
});
5555
exports.createBuildInfoFile = createBuildInfoFile;
5656
const clone = (logger, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
57-
const { pushDir, branchName } = misc_1.getParams(context);
57+
const { pushDir, branchName } = (0, misc_1.getParams)(context);
5858
logger.startProcess('Fetching...');
5959
yield helper.fetchOrigin(pushDir, context, ['--no-tags'], [github_action_helper_1.Utils.getRefspec(branchName)]);
6060
logger.startProcess('Switching branch to [%s]...', branchName);
6161
yield helper.switchBranch(pushDir, branchName);
6262
});
6363
exports.clone = clone;
6464
const checkBranch = (clonedBranch, logger, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
65-
const { pushDir, branchName } = misc_1.getParams(context);
65+
const { pushDir, branchName } = (0, misc_1.getParams)(context);
6666
if (branchName !== clonedBranch) {
6767
logger.info('remote branch %s not found.', branchName);
6868
logger.info('now branch: %s', clonedBranch);
@@ -72,49 +72,49 @@ const checkBranch = (clonedBranch, logger, helper, context) => __awaiter(void 0,
7272
});
7373
exports.checkBranch = checkBranch;
7474
const config = (logger, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
75-
const { pushDir } = misc_1.getParams(context);
76-
const name = misc_1.getCommitName();
77-
const email = misc_1.getCommitEmail();
75+
const { pushDir } = (0, misc_1.getParams)(context);
76+
const name = (0, misc_1.getCommitName)();
77+
const email = (0, misc_1.getCommitEmail)();
7878
logger.startProcess('Configuring git committer to be %s <%s>...', name, email);
7979
yield helper.config(pushDir, { name, email });
8080
});
8181
exports.config = config;
82-
const commit = (helper, context) => __awaiter(void 0, void 0, void 0, function* () { return helper.commit(misc_1.getParams(context).pushDir, misc_1.getCommitMessage(), { allowEmpty: true }); });
82+
const commit = (helper, context) => __awaiter(void 0, void 0, void 0, function* () { return helper.commit((0, misc_1.getParams)(context).pushDir, (0, misc_1.getCommitMessage)(), { allowEmpty: true }); });
8383
exports.commit = commit;
8484
const getDeleteTestTag = (tagName, prefix, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
85-
return (yield helper.getTags(misc_1.getParams(context).pushDir, { quiet: true }))
85+
return (yield helper.getTags((0, misc_1.getParams)(context).pushDir, { quiet: true }))
8686
.filter(tag => github_action_helper_1.Utils.getPrefixRegExp(prefix).test(tag))
8787
.map(tag => tag.replace(github_action_helper_1.Utils.getPrefixRegExp(prefix), ''))
8888
.filter(tag => github_action_helper_1.Utils.versionCompare(tag, tagName, false) < 0) // eslint-disable-line no-magic-numbers
8989
.map(tag => `${prefix}${tag}`);
9090
});
9191
exports.getDeleteTestTag = getDeleteTestTag;
9292
const deleteTestTags = (helper, context) => __awaiter(void 0, void 0, void 0, function* () {
93-
const { pushDir, tagName } = misc_1.getParams(context);
94-
if (!misc_1.isTestTag(tagName) && misc_1.isEnabledCleanTestTag()) {
95-
const prefixForTestTag = misc_1.getTestTagPrefix();
93+
const { pushDir, tagName } = (0, misc_1.getParams)(context);
94+
if (!(0, misc_1.isTestTag)(tagName) && (0, misc_1.isEnabledCleanTestTag)()) {
95+
const prefixForTestTag = (0, misc_1.getTestTagPrefix)();
9696
if (prefixForTestTag) {
97-
yield helper.deleteTag(pushDir, yield exports.getDeleteTestTag(tagName, prefixForTestTag, helper, context), context);
98-
const prefixForOriginalTag = misc_1.getOriginalTagPrefix();
97+
yield helper.deleteTag(pushDir, yield (0, exports.getDeleteTestTag)(tagName, prefixForTestTag, helper, context), context);
98+
const prefixForOriginalTag = (0, misc_1.getOriginalTagPrefix)();
9999
if (prefixForOriginalTag) {
100-
yield helper.deleteTag(pushDir, yield exports.getDeleteTestTag(tagName, prefixForOriginalTag + prefixForTestTag, helper, context), context);
100+
yield helper.deleteTag(pushDir, yield (0, exports.getDeleteTestTag)(tagName, prefixForOriginalTag + prefixForTestTag, helper, context), context);
101101
}
102102
}
103103
}
104104
});
105105
exports.deleteTestTags = deleteTestTags;
106106
const push = (logger, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
107-
const { pushDir, branchName, tagName, branchNames } = misc_1.getParams(context);
107+
const { pushDir, branchName, tagName, branchNames } = (0, misc_1.getParams)(context);
108108
logger.startProcess('Pushing to %s@%s (tag: %s)...', github_action_helper_1.ContextHelper.getRepository(context), branchName, tagName);
109-
const prefixForOriginalTag = misc_1.getOriginalTagPrefix();
109+
const prefixForOriginalTag = (0, misc_1.getOriginalTagPrefix)();
110110
if (prefixForOriginalTag) {
111111
const originalTag = prefixForOriginalTag + tagName;
112112
yield helper.fetchTags(pushDir, context);
113113
yield helper.copyTag(pushDir, originalTag, tagName, context);
114114
}
115-
const tagNames = misc_1.getCreateTags(tagName);
115+
const tagNames = (0, misc_1.getCreateTags)(tagName);
116116
yield helper.fetchTags(pushDir, context);
117-
yield exports.deleteTestTags(helper, context);
117+
yield (0, exports.deleteTestTags)(helper, context);
118118
yield helper.deleteLocalTag(pushDir, tagNames);
119119
yield helper.addLocalTag(pushDir, tagNames);
120120
yield helper.push(pushDir, branchName, context, { withTag: true, force: true });
@@ -126,7 +126,7 @@ const push = (logger, helper, context) => __awaiter(void 0, void 0, void 0, func
126126
});
127127
exports.push = push;
128128
const findRelease = (octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
129-
const { tagName } = misc_1.getParams(context);
129+
const { tagName } = (0, misc_1.getParams)(context);
130130
const releases = yield octokit.rest.repos.listReleases({
131131
owner: context.repo.owner,
132132
repo: context.repo.repo,
@@ -147,7 +147,7 @@ const updateRelease = (release, logger, octokit, context) => __awaiter(void 0, v
147147
});
148148
exports.updateRelease = updateRelease;
149149
const copyFiles = (logger, command, context) => __awaiter(void 0, void 0, void 0, function* () {
150-
const { buildDir, pushDir } = misc_1.getParams(context);
150+
const { buildDir, pushDir } = (0, misc_1.getParams)(context);
151151
logger.startProcess('Copying %s contents to %s...', buildDir, pushDir);
152152
yield command.execAsync({
153153
command: 'rsync',
@@ -156,28 +156,28 @@ const copyFiles = (logger, command, context) => __awaiter(void 0, void 0, void 0
156156
});
157157
exports.copyFiles = copyFiles;
158158
const prepareCommit = (logger, command, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
159-
yield exports.clone(logger, helper, context);
160-
yield exports.checkBranch(yield helper.getCurrentBranchName(misc_1.getParams(context).pushDir), logger, helper, context);
161-
yield exports.prepareFiles(logger, helper, context);
162-
yield exports.createBuildInfoFile(logger, context);
163-
yield exports.copyFiles(logger, command, context);
159+
yield (0, exports.clone)(logger, helper, context);
160+
yield (0, exports.checkBranch)(yield helper.getCurrentBranchName((0, misc_1.getParams)(context).pushDir), logger, helper, context);
161+
yield (0, exports.prepareFiles)(logger, helper, context);
162+
yield (0, exports.createBuildInfoFile)(logger, context);
163+
yield (0, exports.copyFiles)(logger, command, context);
164164
});
165165
exports.prepareCommit = prepareCommit;
166166
const executeCommit = (release, logger, helper, octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
167-
yield exports.config(logger, helper, context);
168-
yield exports.commit(helper, context);
169-
yield exports.push(logger, helper, context);
170-
yield exports.updateRelease(release, logger, octokit, context);
167+
yield (0, exports.config)(logger, helper, context);
168+
yield (0, exports.commit)(helper, context);
169+
yield (0, exports.push)(logger, helper, context);
170+
yield (0, exports.updateRelease)(release, logger, octokit, context);
171171
return true;
172172
});
173173
const deploy = (octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
174-
const logger = new github_action_log_helper_1.Logger(exports.replaceDirectory(context));
174+
const logger = new github_action_log_helper_1.Logger((0, exports.replaceDirectory)(context));
175175
const command = new github_action_helper_1.Command(logger);
176-
const { branchName } = misc_1.getParams(context);
176+
const { branchName } = (0, misc_1.getParams)(context);
177177
logger.startProcess('Deploying branch %s to %s...', branchName, github_action_helper_1.ContextHelper.getRepository(context));
178-
const helper = new github_action_helper_1.GitHelper(logger, { depth: misc_1.getFetchDepth() });
178+
const helper = new github_action_helper_1.GitHelper(logger, { depth: (0, misc_1.getFetchDepth)() });
179179
const release = yield findRelease(octokit, context);
180-
yield exports.prepareCommit(logger, command, helper, context);
180+
yield (0, exports.prepareCommit)(logger, command, helper, context);
181181
yield executeCommit(release, logger, helper, octokit, context);
182182
});
183183
exports.deploy = deploy;

0 commit comments

Comments
 (0)