Skip to content

Commit

Permalink
feat: add major, minor and patch outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed May 27, 2023
1 parent e8ba8d6 commit c767917
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
6 changes: 6 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ inputs:
outputs:
version:
description: 'New version in the format of vMAJOR.YYYMMDD.PATCH'
major:
description: 'Major version in the format of "1"'
minor:
description: 'Minor version in the format of "YYYMMDD"'
patch:
description: 'Patch version in the format of "1"'
runs:
using: 'node16'
main: 'dist/index.js'
12 changes: 7 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13061,11 +13061,10 @@ async function run() {
const currentVersion = semver.parse(currentVersionStr)
core.info(`Found latest version: ${currentVersionStr}`)

const newVersionParts = [
currentVersion.major + Number(level === 'major'),
minorVersion,
level !== 'major' && currentVersion.minor === minorVersion ? currentVersion.patch + 1 : 0,
]
const major = currentVersion.major + Number(level === 'major')
const minor = minorVersion
const patch = level !== 'major' && currentVersion.minor === minorVersion ? currentVersion.patch + 1 : 0
const newVersionParts = [major, minor, patch]
const newVersion = `v${newVersionParts.join('.')}`

// Commit the tag to the repo
Expand All @@ -13085,6 +13084,9 @@ async function run() {
core.notice(`New version: ${newVersion}`)

core.setOutput('version', newVersion)
core.setOutput('major', major)
core.setOutput('minor', minor)
core.setOutput('patch', patch)
}

run().catch((err) => core.setFailed(err.message))
Expand Down
12 changes: 7 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ async function run() {
const currentVersion = semver.parse(currentVersionStr)
core.info(`Found latest version: ${currentVersionStr}`)

const newVersionParts = [
currentVersion.major + Number(level === 'major'),
minorVersion,
level !== 'major' && currentVersion.minor === minorVersion ? currentVersion.patch + 1 : 0,
]
const major = currentVersion.major + Number(level === 'major')
const minor = minorVersion
const patch = level !== 'major' && currentVersion.minor === minorVersion ? currentVersion.patch + 1 : 0
const newVersionParts = [major, minor, patch]
const newVersion = `v${newVersionParts.join('.')}`

// Commit the tag to the repo
Expand All @@ -56,6 +55,9 @@ async function run() {
core.notice(`New version: ${newVersion}`)

core.setOutput('version', newVersion)
core.setOutput('major', major)
core.setOutput('minor', minor)
core.setOutput('patch', patch)
}

run().catch((err) => core.setFailed(err.message))

0 comments on commit c767917

Please sign in to comment.