Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
  • Loading branch information
LongOddCode committed Mar 18, 2021
1 parent f79ea70 commit e6fde29
Show file tree
Hide file tree
Showing 4 changed files with 237 additions and 0 deletions.
17 changes: 17 additions & 0 deletions action.yml
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"
19 changes: 19 additions & 0 deletions index.js
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"]);
}
172 changes: 172 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions package.json
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"
}
}

0 comments on commit e6fde29

Please sign in to comment.