Skip to content

Commit 5f7200a

Browse files
feat: Build for release
1 parent 1d391fd commit 5f7200a

File tree

122 files changed

+14691
-29909
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+14691
-29909
lines changed

README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ default: `''`
156156

157157
## Execute commands
158158
### ビルド
159-
- `build`、 `production` または `prod` が package.json の scripts に含まれる場合、ビルド用のコマンドとしてそれを使用します。([BUILD_COMMAND_TARGET](#build_command_target) で変更可能です)
159+
- `build`、 `production`、 `prod` または `package` が package.json の scripts に含まれる場合、ビルド用のコマンドとしてそれを使用します。([BUILD_COMMAND_TARGET](#build_command_target) で変更可能です)
160160
- `npm run install` や `yarn install` のようなインストール用コマンドが存在しない場合、インストール用コマンドが追加されます。
161161

162162
したがって、`BUILD_COMMAND` が設定されていない かつ package.json に `build` が存在する場合、以下のコマンドが実行されます。

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":"f81a92c716a5ad847f8c6dfa2182b8eccdc918f8","ref":"refs/tags/v2.0.6","tagName":"v2.0.6","branch":"gh-actions","tags":["v2","v2.0","v2.0.6"],"updated_at":"2020-01-16T16:34:46.757Z"}
1+
{"owner":"technote-space","repo":"release-github-actions","sha":"2d794cccdbe79e11dbc78649686007afcd2c85f3","ref":"refs/tags/test/v2.0.7","tagName":"test/v2.0.7","branch":"gh-actions","tags":["test/v2","test/v2.0","test/v2.0.7"],"updated_at":"2020-01-27T12:04:41.477Z"}

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function run() {
3030
logger.info('This is not target event.');
3131
return;
3232
}
33-
yield command_1.deploy(new github_1.GitHub(core_1.getInput('GITHUB_TOKEN', { required: true })), github_1.context);
33+
yield command_1.deploy(new github_1.GitHub(github_action_helper_1.Utils.getAccessToken(true)), github_1.context);
3434
});
3535
}
3636
run().catch(error => core_1.setFailed(error.message));

lib/utils/command.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ exports.replaceDirectory = (message) => {
2525
};
2626
const logger = new github_action_helper_1.Logger(exports.replaceDirectory);
2727
const command = new github_action_helper_1.Command(logger);
28-
const helper = new github_action_helper_1.GitHelper(logger, { depth: misc_1.getFetchDepth() });
2928
const { startProcess, info } = logger;
30-
exports.prepareFiles = (context) => __awaiter(void 0, void 0, void 0, function* () {
29+
exports.prepareFiles = (helper, context) => __awaiter(void 0, void 0, void 0, function* () {
3130
const { buildDir } = misc_1.getParams();
3231
fs_1.default.mkdirSync(buildDir, { recursive: true });
3332
startProcess('Cloning the remote repo for build...');
@@ -59,14 +58,14 @@ exports.createBuildInfoFile = (context) => __awaiter(void 0, void 0, void 0, fun
5958
'updated_at': moment_1.default().toISOString(),
6059
}));
6160
});
62-
exports.clone = (context) => __awaiter(void 0, void 0, void 0, function* () {
61+
exports.clone = (helper, context) => __awaiter(void 0, void 0, void 0, function* () {
6362
const { pushDir, branchName } = misc_1.getParams();
6463
startProcess('Fetching...');
6564
yield helper.fetchOrigin(pushDir, context, ['--no-tags'], [`+refs/heads/${branchName}:refs/remotes/origin/${branchName}`]);
6665
startProcess('Switching branch to [%s]...', branchName);
6766
yield helper.switchBranch(pushDir, branchName);
6867
});
69-
exports.checkBranch = (clonedBranch) => __awaiter(void 0, void 0, void 0, function* () {
68+
exports.checkBranch = (clonedBranch, helper) => __awaiter(void 0, void 0, void 0, function* () {
7069
const { pushDir, branchName } = misc_1.getParams();
7170
if (branchName !== clonedBranch) {
7271
info('remote branch %s not found.', branchName);
@@ -75,36 +74,36 @@ exports.checkBranch = (clonedBranch) => __awaiter(void 0, void 0, void 0, functi
7574
yield helper.gitInit(pushDir, branchName);
7675
}
7776
});
78-
exports.config = () => __awaiter(void 0, void 0, void 0, function* () {
77+
exports.config = (helper) => __awaiter(void 0, void 0, void 0, function* () {
7978
const { pushDir } = misc_1.getParams();
8079
const name = misc_1.getCommitName();
8180
const email = misc_1.getCommitEmail();
8281
startProcess('Configuring git committer to be %s <%s>...', name, email);
8382
yield helper.config(pushDir, name, email);
8483
});
85-
exports.commit = () => __awaiter(void 0, void 0, void 0, function* () { return helper.commit(misc_1.getParams().pushDir, misc_1.getCommitMessage()); });
86-
exports.getDeleteTestTag = (tagName, prefix) => __awaiter(void 0, void 0, void 0, function* () {
84+
exports.commit = (helper) => __awaiter(void 0, void 0, void 0, function* () { return helper.commit(misc_1.getParams().pushDir, misc_1.getCommitMessage()); });
85+
exports.getDeleteTestTag = (tagName, prefix, helper) => __awaiter(void 0, void 0, void 0, function* () {
8786
return (yield helper.getTags(misc_1.getParams().pushDir))
8887
.filter(tag => getPrefixRegExp(prefix).test(tag))
8988
.map(tag => tag.replace(getPrefixRegExp(prefix), ''))
9089
.filter(tag => versionCompare(tag, tagName, false) < 0) // eslint-disable-line no-magic-numbers
9190
.map(tag => `${prefix}${tag}`);
9291
});
93-
exports.deleteTestTags = (context) => __awaiter(void 0, void 0, void 0, function* () {
92+
exports.deleteTestTags = (helper, context) => __awaiter(void 0, void 0, void 0, function* () {
9493
const tagName = getTagName(context);
9594
const { pushDir } = misc_1.getParams();
9695
if (!misc_1.isTestTag(tagName) && misc_1.isEnabledCleanTestTag()) {
9796
const prefixForTestTag = misc_1.getTestTagPrefix();
9897
if (prefixForTestTag) {
99-
yield helper.deleteTag(pushDir, yield exports.getDeleteTestTag(tagName, prefixForTestTag), context);
98+
yield helper.deleteTag(pushDir, yield exports.getDeleteTestTag(tagName, prefixForTestTag, helper), context);
10099
const prefixForOriginalTag = misc_1.getOriginalTagPrefix();
101100
if (prefixForOriginalTag) {
102-
yield helper.deleteTag(pushDir, yield exports.getDeleteTestTag(tagName, prefixForOriginalTag + prefixForTestTag), context);
101+
yield helper.deleteTag(pushDir, yield exports.getDeleteTestTag(tagName, prefixForOriginalTag + prefixForTestTag, helper), context);
103102
}
104103
}
105104
}
106105
});
107-
exports.push = (context) => __awaiter(void 0, void 0, void 0, function* () {
106+
exports.push = (helper, context) => __awaiter(void 0, void 0, void 0, function* () {
108107
const { pushDir, branchName } = misc_1.getParams();
109108
const tagName = getTagName(context);
110109
startProcess('Pushing to %s@%s (tag: %s)...', getRepository(context), branchName, tagName);
@@ -116,7 +115,7 @@ exports.push = (context) => __awaiter(void 0, void 0, void 0, function* () {
116115
}
117116
const tagNames = misc_1.getCreateTags(tagName);
118117
yield helper.fetchTags(pushDir, context);
119-
yield exports.deleteTestTags(context);
118+
yield exports.deleteTestTags(helper, context);
120119
// eslint-disable-next-line no-magic-numbers
121120
yield helper.deleteTag(pushDir, tagNames, context, 1);
122121
yield helper.addLocalTag(pushDir, tagNames);
@@ -150,26 +149,27 @@ exports.copyFiles = () => __awaiter(void 0, void 0, void 0, function* () {
150149
args: ['-rl', '--exclude', '.git', '--delete', `${buildDir}/`, pushDir],
151150
});
152151
});
153-
exports.prepareCommit = (context) => __awaiter(void 0, void 0, void 0, function* () {
154-
yield exports.clone(context);
155-
yield exports.checkBranch(yield helper.getCurrentBranchName(misc_1.getParams().pushDir));
156-
yield exports.prepareFiles(context);
152+
exports.prepareCommit = (helper, context) => __awaiter(void 0, void 0, void 0, function* () {
153+
yield exports.clone(helper, context);
154+
yield exports.checkBranch(yield helper.getCurrentBranchName(misc_1.getParams().pushDir), helper);
155+
yield exports.prepareFiles(helper, context);
157156
yield exports.createBuildInfoFile(context);
158157
yield exports.copyFiles();
159158
});
160-
const executeCommit = (release, octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
161-
yield exports.config();
162-
if (!(yield exports.commit())) {
159+
const executeCommit = (release, helper, octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
160+
yield exports.config(helper);
161+
if (!(yield exports.commit(helper))) {
163162
return false;
164163
}
165-
yield exports.push(context);
164+
yield exports.push(helper, context);
166165
yield exports.updateRelease(release, octokit, context);
167166
return true;
168167
});
169168
exports.deploy = (octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
170169
const { branchName } = misc_1.getParams();
171170
startProcess('Deploying branch %s to %s...', branchName, getRepository(context));
171+
const helper = new github_action_helper_1.GitHelper(logger, { depth: misc_1.getFetchDepth() });
172172
const release = yield findRelease(octokit, context);
173-
yield exports.prepareCommit(context);
174-
yield executeCommit(release, octokit, context);
173+
yield exports.prepareCommit(helper, context);
174+
yield executeCommit(release, helper, octokit, context);
175175
});

lib/utils/misc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ exports.getCreateTags = (tagName) => {
120120
{ condition: exports.isCreatePatchVersionTag, createTag: exports.getPatchTag },
121121
];
122122
const createTag = exports.isTestTag(tagName) ? (create) => exports.getTestTagPrefix() + create(exports.getTestTag(tagName)) : (create) => create(tagName);
123-
return uniqueArray(settings.filter(setting => setting.condition()).map(setting => createTag(setting.createTag)).concat(tagName));
123+
return uniqueArray(settings.filter(setting => setting.condition()).map(setting => createTag(setting.createTag)).concat(tagName)).sort().reverse();
124124
};
125125
exports.getParams = () => {
126126
const workDir = path_1.default.resolve(getWorkspace(), '.work');

node_modules/.bin/semver

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)