Skip to content

Commit

Permalink
allow loose pre-release identifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
LongLiveCHIEF committed Nov 28, 2020
1 parent 9f4d522 commit 601b0fc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
12 changes: 12 additions & 0 deletions __tests__/__data__/taggingStrategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,16 @@ exports.scenarios = [
'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

0 comments on commit 601b0fc

Please sign in to comment.