Skip to content

Commit 5cdc5ce

Browse files
Action semver validator
1 parent 43e3799 commit 5cdc5ce

File tree

246 files changed

+147959
-41060
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+147959
-41060
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
# Hello world JavaScript action
1+
# Semver validation action
22

3-
This action prints "Hello World" or "Hello" + the name of a person to greet to the log. To learn how this action was built, see "[Creating a JavaScript action](https://help.github.com/en/articles/creating-a-javascript-action)" in the GitHub Help documentation.
3+
SEMVER validator
44

55
## Inputs
66

7-
### `who-to-greet`
7+
### `version`
88

9-
**Required** The name of the person to greet. Default `"World"`.
9+
**Required** Version to validate. Default `"0.0.0"`.
1010

1111
## Outputs
1212

13-
### `time`
13+
### `is-valid`
1414

15-
The time we greeted you.
15+
Return if version is valid.
1616

1717
## Example usage
1818

1919
```yaml
20-
uses: actions/hello-world-javascript-action@master
20+
uses: actions/semver-validation-action@master
2121
with:
22-
who-to-greet: 'Mona the Octocat'
22+
version: '0.7.9'
2323
```
24+
25+
```yaml
26+
uses: actions/semver-validation-action@master
27+
with:
28+
version: '0.7.9-beta.1'
29+
```

action.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: 'Hello World'
2-
description: 'Greet someone and record the time'
1+
name: 'SEMVER validator'
2+
description: 'Validate SEMVER version'
33
inputs:
4-
who-to-greet: # id of input
4+
version: # id of input
55
description: 'Who to greet'
66
required: true
7-
default: 'World'
7+
default: '0.0.0'
88
outputs:
9-
time: # id of output
10-
description: 'The time we we greeted you'
9+
is-valid: # id of output
10+
description: 'Return if the input version is valid'
1111
runs:
1212
using: 'node12'
1313
main: 'index.js'

index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ const core = require('@actions/core');
22
const github = require('@actions/github');
33

44
try {
5-
// `who-to-greet` input defined in action metadata file
6-
const nameToGreet = core.getInput('who-to-greet');
7-
console.log(`Hello ${nameToGreet}!`);
8-
const time = (new Date()).toTimeString();
9-
core.setOutput("time", time);
5+
// `version` input defined in action metadata file
6+
const version = core.getInput('version');
7+
console.log(`Checking version: ${version}!`);
8+
9+
var isValid = false;
10+
var re = new RegExp('[0-9]+\.[0-9]+\.[0-9]+(-(0|[1-9]\d*|(beta|alpha).*))?$');
11+
if (re.exec(version) != null) {
12+
isValid = true;
13+
}
14+
core.setOutput("is-valid", isValid);
1015
// Get the JSON webhook payload for the event that triggered the workflow
1116
const payload = JSON.stringify(github.context.payload, undefined, 2)
1217
console.log(`The event payload: ${payload}`);

node_modules/@actions/core/README.md

Lines changed: 63 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.d.ts

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js

Lines changed: 31 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/command.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@actions/core/lib/core.d.ts

Lines changed: 27 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)