-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f79ea70
commit e6fde29
Showing
4 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "semantic-versioning-tag" | ||
description: "help to process a tag if it follow the semantic versionning pattern." | ||
|
||
outputs: | ||
major: | ||
description: major version | ||
minor: | ||
description: minor version | ||
patch: | ||
description: patch version | ||
prerelease: | ||
description: pre-release data | ||
buildmetadata: | ||
description: build meta data | ||
runs: | ||
using: "node12" | ||
main: "index.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const core = require("@actions/core"); | ||
const github = require("@actions/github"); | ||
|
||
const regexStr = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/gm; | ||
|
||
const ref = github.context.ref; | ||
const tagPath = "refs/tags/"; | ||
if (ref && ref.startsWith(tagPath)) { | ||
var regex = new RegExp(regexStr); | ||
var result = regex.exec(tag); | ||
if (!result) { | ||
core.setFailed("not semantic versionning tag"); | ||
} | ||
core.setOutput("major", result["major"]); | ||
core.setOutput("minor", result["minor"]); | ||
core.setOutput("patch", result["patch"]); | ||
core.setOutput("prerelease", result["prerelease"]); | ||
core.setOutput("buildmetadata", result["buildmetadata"]); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "semantic-versioning-tag", | ||
"version": "1.0.0", | ||
"description": "help to process a tag if it follow the semantic versionning pattern.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/LongOddCode/semantic-versioning-tag.git" | ||
}, | ||
"keywords": [ | ||
"github", | ||
"action", | ||
"tag", | ||
"semantic version" | ||
], | ||
"author": "", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/LongOddCode/semantic-versioning-tag/issues" | ||
}, | ||
"homepage": "https://github.com/LongOddCode/semantic-versioning-tag#readme", | ||
"dependencies": { | ||
"@actions/core": "^1.2.6", | ||
"@actions/github": "^4.0.0" | ||
} | ||
} |