diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3560e74..cf01200 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,9 +60,9 @@ jobs: env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - - name: Push updates to branch v1 + - name: Push updates to branch for major version if: steps.semantic.outputs.new-release-published == 'true' - run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/v1" + run: "git push https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/${steps.semantic.outputs.new-release-major-version}" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index cf75479..5464c61 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,10 @@ GitHub Action for [Semantic Release](https://github.com/semantic-release/semanti * `dry_run`: [Optional] Whether to run semantic release in "dry-run" mode. It will override the dryRun attribute in your configuration file. Default `""`. * outputs: * `new-release-published`: Whether a new release was published. `true` or `false` + * `new-release-version`: Version of the new release + * `new-release-major-version`: Major version of the new release + * `new-release-minor-version`: Minor version of the new release + * `new-release-patch-version`: Patch version of the new release A simple example ```yaml diff --git a/action.yml b/action.yml index 6598bac..3f6d950 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,14 @@ inputs: outputs: new-release-published: description: 'Whether a new release was published' + new-release-version: + description: "Version of the new release" + new-release-major-version: + description: "Major version of the new release" + new-release-minor-version: + description: "Minor version of the new release" + new-release-patch-version: + description: "Patch version of the new release" runs: using: 'node12' main: 'index.js' diff --git a/src/index.js b/src/index.js index 58aa000..7ba2f95 100644 --- a/src/index.js +++ b/src/index.js @@ -3,7 +3,13 @@ const path = require('path'); const core = require('@actions/core'); const semanticRelease = require('semantic-release'); -const OutputKey_NewReleasePublished = 'new-release-published'; +const OutputKeys = { + newReleasePublished: 'new-release-published', + newReleaseVersion: 'new-release-version', + newReleaseMajor: 'new-release-major-version', + newReleaseMinor: 'new-release-minor-version', + newReleasePatch: 'new-release-patch-version', +}; /** * handleDryRunOption @@ -33,7 +39,7 @@ const release = async () => { const extraPlugins = core.getInput('extra_plugins', {required: false}) || ''; // set outputs default - core.setOutput(OutputKey_NewReleasePublished, 'false'); + core.setOutput(OutputKeys.newReleasePublished, 'false'); // pre-install plugins if (extraPlugins) { @@ -71,8 +77,15 @@ const release = async () => { core.debug(`The release was published with plugin "${release.pluginName}".`); } - // set outputs default - core.setOutput(OutputKey_NewReleasePublished, 'true'); + const {version} = nextRelease; + const [major, minor, patch] = version.split('.'); + + // set outputs + core.setOutput(OutputKeys.newReleasePublished, 'true'); + core.setOutput(OutputKeys.newReleaseVersion, version); + core.setOutput(OutputKeys.newReleaseMajor, major); + core.setOutput(OutputKeys.newReleaseMinor, minor); + core.setOutput(OutputKeys.newReleasePatch, patch); };