Skip to content

Commit 7ba0e44

Browse files
feat: build for release
1 parent bd550ae commit 7ba0e44

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

README.ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
| COMMIT_MESSAGE | コミット時に設定するメッセージ | `feat: build for release` | true | `feat: release` |
8181
| COMMIT_NAME | コミット時に設定する名前 | `github-actions[bot]` | true | |
8282
| COMMIT_EMAIL | コミット時に設定する名前 | `41898282+github-actions[bot]@users.noreply.github.com` | true | |
83-
| BRANCH_NAME | GitHub Actions 用のブランチ名 | `gh-actions` | true | |
83+
| BRANCH_NAME | GitHub Actions 用のブランチ名 | `releases/${MAJOR}` | true | `releases/${MINOR}`, `releases/${PATCH}` |
8484
| BUILD_COMMAND_TARGET | ビルド用コマンド検索ターゲット | `build, production, prod, package` | | `compile` |
8585
| CREATE_MAJOR_VERSION_TAG | メジャーバージョンタグ(例:v1)を作成するかどうか<br>[タグの詳細](#tags) | `true` | | `false` |
8686
| CREATE_MINOR_VERSION_TAG | マイナーバージョンタグ(例:v1.2)を作成するかどうか<br>[タグの詳細](#tags) | `true` | | `false` |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ jobs:
8080
| COMMIT_MESSAGE | Commit message | `feat: build for release` | true | `feat: release` |
8181
| COMMIT_NAME | Commit name | `github-actions[bot]` | true | |
8282
| COMMIT_EMAIL | Commit email | `41898282+github-actions[bot]@users.noreply.github.com` | true | |
83-
| BRANCH_NAME | Branch name for `GitHub Actions` release | `gh-actions` | true | |
83+
| BRANCH_NAME | Branch name for `GitHub Actions` release | `releases/${MAJOR}` | true | `releases/${MINOR}`, `releases/${PATCH}` |
8484
| BUILD_COMMAND_TARGET | Command for search build command | `build, production, prod, package` | | `compile` |
8585
| CREATE_MAJOR_VERSION_TAG | Whether to create major version tag (e.g. v1)<br>[Detail of tags](#tags) | `true` | | `false` |
8686
| CREATE_MINOR_VERSION_TAG | Whether to create minor version tag (e.g. v1.2)<br>[Detail of tags](#tags) | `true` | | `false` |

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":"54bde01a01edebff8a373f683cab253abac63a66","ref":"refs/tags/test/v4.0.0.50299278","tagName":"test/v4.0.0.50299278","branch":"releases/v4","tags":["test/v4.0.0.50299278","test/v4.0.0","test/v4.0","test/v4"],"updated_at":"2020-03-05T18:56:55.040Z"}
1+
{"owner":"technote-space","repo":"release-github-actions","sha":"f14b22bdaa8aa87b01ea54886b43ef372d724230","ref":"refs/tags/test/v4.0.0.1","tagName":"test/v4.0.0.1","branch":"releases/v4","tags":["test/v4.0.0.1","test/v4.0.0","test/v4.0","test/v4"],"updated_at":"2020-03-06T04:13:23.517Z"}

lib/utils/command.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ exports.deleteTestTags = (helper, context) => __awaiter(void 0, void 0, void 0,
9393
}
9494
});
9595
exports.push = (logger, helper, context) => __awaiter(void 0, void 0, void 0, function* () {
96-
const { pushDir, branchName, tagName } = misc_1.getParams(context);
96+
const { pushDir, branchName, tagName, branchNames } = misc_1.getParams(context);
9797
logger.startProcess('Pushing to %s@%s (tag: %s)...', github_action_helper_1.ContextHelper.getRepository(context), branchName, tagName);
9898
const prefixForOriginalTag = misc_1.getOriginalTagPrefix();
9999
if (prefixForOriginalTag) {
@@ -108,6 +108,11 @@ exports.push = (logger, helper, context) => __awaiter(void 0, void 0, void 0, fu
108108
yield helper.deleteTag(pushDir, tagNames, context, 1);
109109
yield helper.addLocalTag(pushDir, tagNames);
110110
yield helper.push(pushDir, branchName, context, { withTag: true });
111+
yield branchNames.reduce((prev, branch) => __awaiter(void 0, void 0, void 0, function* () {
112+
yield prev;
113+
yield helper.createBranch(pushDir, branch);
114+
yield helper.forcePush(pushDir, branch, context);
115+
}), Promise.resolve());
111116
});
112117
const findRelease = (octokit, context) => __awaiter(void 0, void 0, void 0, function* () {
113118
const { tagName } = misc_1.getParams(context);

lib/utils/misc.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ exports.getBuildCommands = (buildDir, pushDir) => {
9898
exports.getCommitMessage = () => core_1.getInput('COMMIT_MESSAGE', { required: true });
9999
exports.getCommitName = () => core_1.getInput('COMMIT_NAME', { required: true });
100100
exports.getCommitEmail = () => core_1.getInput('COMMIT_EMAIL', { required: true });
101-
exports.getBranchName = () => core_1.getInput('BRANCH_NAME', { required: true });
101+
exports.getBranchNames = () => github_action_helper_1.Utils.getArrayInput('BRANCH_NAME', true);
102102
exports.getFetchDepth = () => {
103103
const depth = core_1.getInput('FETCH_DEPTH');
104104
if (depth && /^\d+$/.test(depth)) {
@@ -145,12 +145,16 @@ const params = (context) => {
145145
const pushDir = path_1.resolve(workDir, 'push');
146146
const tagName = github_action_helper_1.ContextHelper.getTagName(context);
147147
const normalized = exports.isTestTag(tagName) ? exports.getTestTag(tagName) : tagName;
148-
const branchName = [
148+
const rawBranchNames = exports.getBranchNames();
149+
const getBranch = (branch) => [
149150
{ key: 'MAJOR', func: exports.getMajorTag },
150151
{ key: 'MINOR', func: exports.getMinorTag },
151152
{ key: 'PATCH', func: exports.getPatchTag },
152-
].reduce((acc, item) => github_action_helper_1.Utils.replaceAll(acc, `\${${item.key}}`, item.func(normalized)), exports.getBranchName());
153-
return { workDir, buildDir, pushDir, branchName, tagName };
153+
].reduce((acc, item) => github_action_helper_1.Utils.replaceAll(acc, `\${${item.key}}`, item.func(normalized)), branch);
154+
const branchNames = rawBranchNames.map(getBranch);
155+
const branchName = branchNames[0];
156+
// eslint-disable-next-line no-magic-numbers
157+
return { workDir, buildDir, pushDir, branchName, branchNames: branchNames.slice(1), tagName };
154158
};
155159
exports.getParams = memize_1.default(params);
156160
exports.getReplaceDirectory = (context) => {

0 commit comments

Comments
 (0)