diff --git a/__tests__/__data__/parser.js b/__tests__/__data__/parser.js index c60a9b7..bfc0d6f 100644 --- a/__tests__/__data__/parser.js +++ b/__tests__/__data__/parser.js @@ -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 = [ diff --git a/__tests__/__data__/taggingStrategy.js b/__tests__/__data__/taggingStrategy.js index ddbe53e..1561b9e 100644 --- a/__tests__/__data__/taggingStrategy.js +++ b/__tests__/__data__/taggingStrategy.js @@ -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'} + ], ] diff --git a/dist/index.js b/dist/index.js index ebc6252..58467fa 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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} diff --git a/package-lock.json b/package-lock.json index 8c256ba..a055f69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tagging-strategy", - "version": "2.0.0-rc2", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 45db91b..1cd5408 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/parser.js b/src/parser.js index 7cdadd2..fea1ce7 100644 --- a/src/parser.js +++ b/src/parser.js @@ -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} diff --git a/try.js b/try.js deleted file mode 100644 index 054927f..0000000 --- a/try.js +++ /dev/null @@ -1,9 +0,0 @@ -const {taggingStrategy} = require('./src/taggingStrategy') - -const strategy = { - latest: true, - tagName: '1.7.3', - inputTags: '%X%,%X.Y%,%X.Y.Z%' -} - -console.log(taggingStrategy(strategy)) \ No newline at end of file