Skip to content

Commit

Permalink
Merge pull request #39 from HackerHappyHour/support-non-delimited-pre…
Browse files Browse the repository at this point in the history
…releases

Support non delimited prereleases
  • Loading branch information
LongLiveCHIEF authored Nov 28, 2020
2 parents e36eeb4 + 601b0fc commit 5e3d07d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
4 changes: 3 additions & 1 deletion __tests__/__data__/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ exports.parseTagScenarios = [
['%X.Y%-foobar', '1.0.0-rc.1', '1.0-rc.1-foobar'],
['%X%-foobar', '1.0.0-rc1', '1-rc1-foobar'],
['%X%-foobar', '1.0.0-rc.1', '1-rc.1-foobar'],
['%X%-foobar', '1.0.0', '1-foobar']
['%X%-foobar', '1.0.0', '1-foobar'],
['%X%', '2.0.0rc3', '2-rc3'],
['%X.Y%', '2.0.0rc3', '2.0-rc3']
]

exports.parseInputListScenarios = [
Expand Down
16 changes: 16 additions & 0 deletions __tests__/__data__/taggingStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,20 @@ exports.scenarios = [
'hello/world:1-foobar,hello/world:1.0-foobar,hello/world:1.0.0-foobar,hello/world:latest',
{inputTags:'%X%-foobar,%X.Y%-foobar,%X.Y.Z%-foobar', tagName:'1.0.0', latest: true, imageName: 'hello/world'}
],
[
'1-rc1,1.0-rc1,1.0.0-rc1',
{inputTags:'%X%,%X.Y%,%X.Y.Z%', tagName:'1.0.0rc1'}
],
[
'1-rc1-foobar,1.0-rc1-foobar,1.0.0-rc1-foobar',
{inputTags:'%X%-foobar,%X.Y%-foobar,%X.Y.Z%-foobar', tagName:'1.0.0rc1'}
],
[
'hello/world:1-rc1-foobar,hello/world:1.0-rc1-foobar,hello/world:1.0.0-rc1-foobar',
{inputTags:'%X%-foobar,%X.Y%-foobar,%X.Y.Z%-foobar', tagName:'1.0.0rc1', imageName: 'hello/world'}
],
[
'hello/world:1-rc1-foobar,hello/world:1.0-rc1-foobar,hello/world:1.0.0-rc1-foobar,hello/world:latest',
{latest: true, inputTags:'%X%-foobar,%X.Y%-foobar,%X.Y.Z%-foobar', tagName:'1.0.0rc1', imageName: 'hello/world'}
],
]
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7982,7 +7982,7 @@ exports.parseTag = (pattern, tag) => {

// if 'tag' is valid, attempt to parse it
// otherwise error: value is not valid or cannot be coerced
var parsedTag = s.parse(tag, {includePrerelease: true})
var parsedTag = s.parse(s.clean(tag, {loose: true}), {includePrerelease: true})
if (!parsedTag){
parsedTag = s.parse(s.valid(s.coerce(tag)))
if (!parsedTag) return {error: invalidTag}
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tagging-strategy",
"version": "2.0.0-rc2",
"version": "2.1.0",
"description": "A github action for specifying tagging strategies for docker images using semver or other common docker tags",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports.parseTag = (pattern, tag) => {

// if 'tag' is valid, attempt to parse it
// otherwise error: value is not valid or cannot be coerced
var parsedTag = s.parse(tag, {includePrerelease: true})
var parsedTag = s.parse(s.clean(tag, {loose: true}), {includePrerelease: true})
if (!parsedTag){
parsedTag = s.parse(s.valid(s.coerce(tag)))
if (!parsedTag) return {error: invalidTag}
Expand Down
9 changes: 0 additions & 9 deletions try.js

This file was deleted.

0 comments on commit 5e3d07d

Please sign in to comment.