From 3e27c518af9a3d781b70e0cf1cbccc626ae7f4f3 Mon Sep 17 00:00:00 2001 From: cycjimmy Date: Sun, 19 Jan 2020 10:15:24 +0800 Subject: [PATCH] fix(branch): parameter `branch` does not work in semantic v16 parameter `branch` does not work in semantic v16(#15) #15 --- .github/workflows/checkPullRequest.yml | 1 + .github/workflows/testRelease.yml | 1 + src/handleOptions.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checkPullRequest.yml b/.github/workflows/checkPullRequest.yml index 6da633e..e27ee90 100644 --- a/.github/workflows/checkPullRequest.yml +++ b/.github/workflows/checkPullRequest.yml @@ -16,6 +16,7 @@ jobs: - name: Semantic Release uses: ./ with: + branch: master extra_plugins: | @semantic-release/git @semantic-release/changelog diff --git a/.github/workflows/testRelease.yml b/.github/workflows/testRelease.yml index b61e6af..b0257d5 100644 --- a/.github/workflows/testRelease.yml +++ b/.github/workflows/testRelease.yml @@ -20,6 +20,7 @@ jobs: uses: cycjimmy/semantic-release-action@v2 id: semantic with: + branch: master extra_plugins: | @semantic-release/git @semantic-release/changelog diff --git a/src/handleOptions.js b/src/handleOptions.js index 281a03d..3330708 100644 --- a/src/handleOptions.js +++ b/src/handleOptions.js @@ -9,8 +9,18 @@ exports.handleBranchOption = () => { const branchOption = {}; const branch = core.getInput(inputs.branch); - if (branch) { + if (!branch) { + return branchOption; + } + + const semanticVersion = require('semantic-release/package.json').version; + const semanticMajorVersion = Number(semanticVersion.replace(/\..+/g, '')); + core.debug(`semanticMajorVersion: ${semanticMajorVersion}`); + + if (semanticMajorVersion < 16) { branchOption.branch = branch; + } else { + branchOption.branches = [branch]; } return branchOption;