Skip to content

Commit

Permalink
Update readme and exit if invalid version
Browse files Browse the repository at this point in the history
  • Loading branch information
eb-rubenespinosa committed Mar 20, 2020
1 parent 968401c commit 37f2de6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ SEMVER validator

### `version`

**Required** Version to validate. Default `"0.0.0"`.

## Outputs

### `is-valid`

Return if version is valid.
**Required** Version to validate.

## Example usage

```yaml
uses: actions/semver-validation-action@master
with:
version: '0.7.9'
version: ${{ github.event.release.tag_name }}
```
```yaml
Expand Down
14 changes: 3 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,11 @@ try {
const version = core.getInput('version');
console.log(`Checking version: ${version}!`);

var isValid = false;
console.log(`isValid false`);
var re = new RegExp("[0-9]+\.[0-9]+\.[0-9]+(-(0|[1-9]\d*|(beta|alpha).*))?$");
console.log(`RegExp`);
if (re.exec(version) != null) {
isValid = true;
console.log(`isValid true`);
if (re.exec(version) == null) {
core.setFailed("Invalid version");
}
core.setOutput("is-valid", isValid);
console.log(`setOutput`);
// Get the JSON webhook payload for the event that triggered the workflow
const payload = JSON.stringify(github.context.payload, undefined, 2)
console.log(`The event payload: ${payload}`);

} catch (error) {
core.setFailed(error.message);
}

0 comments on commit 37f2de6

Please sign in to comment.