Compare commits

..

6 Commits

Author SHA1 Message Date
CrazyMax
2e1a5c7fa4 Update CHANGELOG 2021-04-07 21:00:00 +02:00
CrazyMax
1a678de43d Allow to override flavor (#63)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-04-07 20:54:35 +02:00
CrazyMax
84b9e75d44 Prefix/suffix not taken into account (#62)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-04-07 20:31:35 +02:00
CrazyMax
f39f06a624 Update CHANGELOG 2021-04-05 21:30:44 +02:00
CrazyMax
36ae18e02c Skip and display warning if tag does not match (#59)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-04-05 21:19:05 +02:00
CrazyMax
e87dd9466c Fix workflow 2021-04-03 18:44:12 +02:00
9 changed files with 324 additions and 133 deletions

View File

@@ -1,9 +1,6 @@
name: label-sponsor name: label-sponsor
on: on:
pull_request:
types:
- 'opened'
issues: issues:
types: types:
- 'opened' - 'opened'

View File

@@ -1,5 +1,14 @@
# Changelog # Changelog
## 2.3.0 (2021/04/07)
* Allow overriding flavor (#63)
* Prefix/suffix not taken into account for `match`, `semver` and `schedule` types (#62)
## 2.2.1 (2021/04/05)
* Skip and display warning if tag does not match (#59)
## 2.2.0 (2021/04/03) ## 2.2.0 (2021/04/03)
* Improve logging (#58) * Improve logging (#58)

View File

@@ -437,6 +437,7 @@ a custom value through `value` attribute.
| `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` | | `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` |
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` | | `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` |
| `20200110-RC2` | `\d+` | `0` | `20200110` | | `20200110-RC2` | `\d+` | `0` | `20200110` |
| `p1/v1.2.3` | `p1-v(\d.\d.\d)` | `1` | `1.2.3` |
Extended attributes and default values: Extended attributes and default values:
@@ -470,11 +471,11 @@ tags: |
```yaml ```yaml
tags: | tags: |
# minimal branch event # branch event
type=ref,event=branch type=ref,event=branch
# minimal tag event # tag event
type=ref,event=tag type=ref,event=tag
# minimal pull request event # pull request event
type=ref,event=pr type=ref,event=pr
``` ```
@@ -495,11 +496,11 @@ Extended attributes and default values:
```yaml ```yaml
tags: | tags: |
# event branch # branch event
type=ref,enable=true,priority=600,prefix=,suffix=,event= type=ref,enable=true,priority=600,prefix=,suffix=,event=
# event tag # tag event
type=ref,enable=true,priority=600,prefix=,suffix=,event= type=ref,enable=true,priority=600,prefix=,suffix=,event=
# event pr # pull request event
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event= type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=
``` ```

View File

@@ -0,0 +1,23 @@
GITHUB_ACTION=crazy-maxghaction-dump-context
GITHUB_ACTIONS=true
GITHUB_ACTION_PATH=/home/runner/work/_actions/crazy-max/ghaction-dump-context/v1
GITHUB_ACTOR=crazy-max
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_EVENT_NAME=push
#GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=event
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_6ee180c2-b331-434a-a867-89534cbefd83
GITHUB_REF=refs/tags/p1/v1.0.0
GITHUB_REPOSITORY=crazy-max/test-docker-action
GITHUB_REPOSITORY_OWNER=crazy-max
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=325968230
GITHUB_RUN_NUMBER=4
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=90dd6032fac8bda1b6c4436a2e65de27961ed071
GITHUB_WORKFLOW=event
GITHUB_WORKSPACE=/home/runner/work/test-docker-action/test-docker-action

View File

@@ -837,24 +837,29 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=/^v(\\d.\\d.\\d)$/ig",group=1`, `type=match,"pattern=v(.*)-beta.(.*)",group=1`,
`type=match,"pattern=v(.*)-beta.(.*)",group=2`,
] ]
} as Inputs, } as Inputs,
{ {
main: 'v2.0.8-beta.67', main: '2.0.8',
partial: [], partial: ['67'],
latest: false latest: true
} as Version, } as Version,
[ [
'org/app:v2.0.8-beta.67', 'org/app:2.0.8',
'ghcr.io/user/app:v2.0.8-beta.67' 'org/app:67',
'org/app:latest',
'ghcr.io/user/app:2.0.8',
'ghcr.io/user/app:67',
'ghcr.io/user/app:latest'
], ],
[ [
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!", "org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=v2.0.8-beta.67", "org.opencontainers.image.version=2.0.8",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
@@ -870,20 +875,17 @@ describe('tag', () => {
] ]
} as Inputs, } as Inputs,
{ {
main: 'sometag', main: undefined,
partial: [], partial: [],
latest: false latest: false
} as Version, } as Version,
[ [],
'org/app:sometag',
'ghcr.io/user/app:sometag'
],
[ [
"org.opencontainers.image.title=Hello-World", "org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!", "org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World", "org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World", "org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=sometag", "org.opencontainers.image.version=",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z", "org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
@@ -1089,6 +1091,125 @@ describe('tag', () => {
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
] ]
],
[
'tag17',
'event_tag_p1-v1.0.0.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=match,"pattern=/^v(\\d.\\d.\\d)$/ig",group=1`,
`type=match,pattern=\\d.\\d.\\d`,
`type=match,pattern=\\d.\\d`,
`type=ref,event=pr`,
`type=sha`
]
} as Inputs,
{
main: '1.0.0',
partial: ['1.0', 'sha-90dd603'],
latest: true
} as Version,
[
'org/app:1.0.0',
'org/app:1.0',
'org/app:sha-90dd603',
'org/app:latest',
'ghcr.io/user/app:1.0.0',
'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-90dd603',
'ghcr.io/user/app:latest'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.0",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
[
'tag18',
'event_tag_p1-v1.0.0.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=match,pattern=p1-v(\\d.\\d.\\d),group=1`,
`type=match,pattern=p1-v(\\d.\\d),group=1`,
`type=match,pattern=p1-v(\\d.\\d),group=3`,
`type=ref,event=pr`,
`type=sha`
]
} as Inputs,
{
main: '1.0.0',
partial: ['1.0', 'sha-90dd603'],
latest: true
} as Version,
[
'org/app:1.0.0',
'org/app:1.0',
'org/app:sha-90dd603',
'org/app:latest',
'ghcr.io/user/app:1.0.0',
'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-90dd603',
'ghcr.io/user/app:latest'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.0",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
[
'tag19',
'event_tag_p1-v1.0.0.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=match,pattern=p1-v(\\d.\\d.\\d),group=1`,
`type=match,pattern=p1-v(\\d.\\d),group=1,suffix=`,
`type=ref,event=pr`,
`type=sha`
],
flavor: [
`suffix=-dev`
]
} as Inputs,
{
main: '1.0.0-dev',
partial: ['1.0', 'sha-90dd603-dev'],
latest: true
} as Version,
[
'org/app:1.0.0-dev',
'org/app:1.0',
'org/app:sha-90dd603-dev',
'org/app:latest',
'ghcr.io/user/app:1.0.0-dev',
'ghcr.io/user/app:1.0',
'ghcr.io/user/app:sha-90dd603-dev',
'ghcr.io/user/app:latest'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=1.0.0-dev",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
] ]
])('given %p with %p event', tagsLabelsTest); ])('given %p with %p event', tagsLabelsTest);
}); });
@@ -1498,6 +1619,72 @@ describe('pr', () => {
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
] ]
], ],
[
'pr05',
'event_pull_request.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=ref,event=pr`
],
flavor: [
`prefix=glo-`,
`suffix=-bal`
]
} as Inputs,
{
main: 'pr-2-bal',
partial: [],
latest: false
} as Version,
[
'org/app:pr-2-bal',
'ghcr.io/user/app:pr-2-bal'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=pr-2-bal",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
"org.opencontainers.image.licenses=MIT"
]
],
[
'pr06',
'event_pull_request.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=ref,event=pr,prefix=`
],
flavor: [
`prefix=glo-`,
`suffix=-bal`
]
} as Inputs,
{
main: '2-bal',
partial: [],
latest: false
} as Version,
[
'org/app:2-bal',
'ghcr.io/user/app:2-bal'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=2-bal",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=1e9249f05bfc090e0688b8fb9c1b347586add504",
"org.opencontainers.image.licenses=MIT"
]
]
])('given %p with %p event', tagsLabelsTest); ])('given %p with %p event', tagsLabelsTest);
}); });
@@ -1678,6 +1865,39 @@ describe('schedule', () => {
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
] ]
], ],
[
'schedule07',
'event_schedule.env',
{
images: ['org/app', 'ghcr.io/user/app'],
tags: [
`type=schedule`,
],
flavor: [
`prefix=glo-`,
`suffix=-bal`
]
} as Inputs,
{
main: 'glo-nightly-bal',
partial: [],
latest: false
} as Version,
[
'org/app:glo-nightly-bal',
'ghcr.io/user/app:glo-nightly-bal'
],
[
"org.opencontainers.image.title=Hello-World",
"org.opencontainers.image.description=This your first repo!",
"org.opencontainers.image.url=https://github.com/octocat/Hello-World",
"org.opencontainers.image.source=https://github.com/octocat/Hello-World",
"org.opencontainers.image.version=glo-nightly-bal",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
])('given %p with %p event', tagsLabelsTest); ])('given %p with %p event', tagsLabelsTest);
}); });

View File

@@ -21,8 +21,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Schedule], "priority": DefaultPriorities[Type.Schedule],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "nightly" "pattern": "nightly"
} }
}, },
@@ -31,8 +29,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Semver], "priority": DefaultPriorities[Type.Semver],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "{{version}}", "pattern": "{{version}}",
"value": "" "value": ""
} }
@@ -42,8 +38,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Match], "priority": DefaultPriorities[Type.Match],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "\\d.\\d.\\d", "pattern": "\\d.\\d.\\d",
"group": "0", "group": "0",
"value": "" "value": ""
@@ -54,8 +48,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Edge], "priority": DefaultPriorities[Type.Edge],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"branch": "" "branch": ""
} }
}, },
@@ -64,8 +56,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Ref], "priority": DefaultPriorities[Type.Ref],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"event": RefEvent.Branch "event": RefEvent.Branch
} }
}, },
@@ -74,8 +64,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Ref], "priority": DefaultPriorities[Type.Ref],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"event": RefEvent.Tag "event": RefEvent.Tag
} }
}, },
@@ -85,7 +73,6 @@ describe('transform', () => {
"priority": DefaultPriorities[Type.Ref], "priority": DefaultPriorities[Type.Ref],
"enable": "true", "enable": "true",
"prefix": "pr-", "prefix": "pr-",
"suffix": "",
"event": RefEvent.PR "event": RefEvent.PR
} }
}, },
@@ -94,8 +81,6 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Raw], "priority": DefaultPriorities[Type.Raw],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"value": "foo" "value": "foo"
} }
}, },
@@ -104,8 +89,7 @@ describe('transform', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Sha], "priority": DefaultPriorities[Type.Sha],
"enable": "true", "enable": "true",
"prefix": "sha-", "prefix": "sha-"
"suffix": ""
} }
} }
] as Tag[], ] as Tag[],
@@ -135,8 +119,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Schedule], "priority": DefaultPriorities[Type.Schedule],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "{{date 'YYYYMMDD'}}" "pattern": "{{date 'YYYYMMDD'}}"
} }
} as Tag, } as Tag,
@@ -149,8 +131,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Semver], "priority": DefaultPriorities[Type.Semver],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "{{version}}", "pattern": "{{version}}",
"value": "" "value": ""
} }
@@ -164,8 +144,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": "1", "priority": "1",
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "{{version}}", "pattern": "{{version}}",
"value": "" "value": ""
} }
@@ -179,8 +157,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": "1", "priority": "1",
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "{{version}}", "pattern": "{{version}}",
"value": "v1.0.0" "value": "v1.0.0"
} }
@@ -194,8 +170,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Match], "priority": DefaultPriorities[Type.Match],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "v(.*)", "pattern": "v(.*)",
"group": "1", "group": "1",
"value": "" "value": ""
@@ -210,8 +184,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Match], "priority": DefaultPriorities[Type.Match],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "^v(\\d.\\d.\\d)$", "pattern": "^v(\\d.\\d.\\d)$",
"group": "1", "group": "1",
"value": "" "value": ""
@@ -226,8 +198,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": "700", "priority": "700",
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "v(.*)", "pattern": "v(.*)",
"group": "1", "group": "1",
"value": "" "value": ""
@@ -242,8 +212,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Match], "priority": DefaultPriorities[Type.Match],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"pattern": "v(.*)", "pattern": "v(.*)",
"group": "1", "group": "1",
"value": "v1.2.3" "value": "v1.2.3"
@@ -263,8 +231,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Edge], "priority": DefaultPriorities[Type.Edge],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"branch": "" "branch": ""
} }
} as Tag, } as Tag,
@@ -277,8 +243,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Edge], "priority": DefaultPriorities[Type.Edge],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"branch": "master" "branch": "master"
} }
} as Tag, } as Tag,
@@ -291,8 +255,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Ref], "priority": DefaultPriorities[Type.Ref],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"event": RefEvent.Tag "event": RefEvent.Tag
} }
} as Tag, } as Tag,
@@ -305,8 +267,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Ref], "priority": DefaultPriorities[Type.Ref],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"event": RefEvent.Branch "event": RefEvent.Branch
} }
} as Tag, } as Tag,
@@ -320,7 +280,6 @@ describe('parse', () => {
"priority": DefaultPriorities[Type.Ref], "priority": DefaultPriorities[Type.Ref],
"enable": "true", "enable": "true",
"prefix": "pr-", "prefix": "pr-",
"suffix": "",
"event": RefEvent.PR "event": RefEvent.PR
} }
} as Tag, } as Tag,
@@ -343,8 +302,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Raw], "priority": DefaultPriorities[Type.Raw],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"value": "acustomtag" "value": "acustomtag"
} }
} as Tag, } as Tag,
@@ -362,8 +319,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Raw], "priority": DefaultPriorities[Type.Raw],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"value": "acustomtag2" "value": "acustomtag2"
} }
} as Tag, } as Tag,
@@ -376,8 +331,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Raw], "priority": DefaultPriorities[Type.Raw],
"enable": "true", "enable": "true",
"prefix": "",
"suffix": "",
"value": "acustomtag4" "value": "acustomtag4"
} }
} as Tag, } as Tag,
@@ -390,8 +343,6 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Raw], "priority": DefaultPriorities[Type.Raw],
"enable": "false", "enable": "false",
"prefix": "",
"suffix": "",
"value": "acustomtag5" "value": "acustomtag5"
} }
} as Tag, } as Tag,
@@ -404,8 +355,7 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Sha], "priority": DefaultPriorities[Type.Sha],
"enable": "true", "enable": "true",
"prefix": "sha-", "prefix": "sha-"
"suffix": ""
} }
} as Tag, } as Tag,
false false
@@ -417,8 +367,7 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Sha], "priority": DefaultPriorities[Type.Sha],
"enable": "true", "enable": "true",
"prefix": "", "prefix": ""
"suffix": ""
} }
} as Tag, } as Tag,
false false
@@ -430,8 +379,7 @@ describe('parse', () => {
attrs: { attrs: {
"priority": DefaultPriorities[Type.Sha], "priority": DefaultPriorities[Type.Sha],
"enable": "false", "enable": "false",
"prefix": "sha-", "prefix": "sha-"
"suffix": ""
} }
} as Tag, } as Tag,
false false

48
dist/index.js generated vendored
View File

@@ -439,11 +439,11 @@ class Meta {
return version; return version;
} }
const currentDate = this.date; const currentDate = this.date;
const vraw = handlebars.compile(tag.attrs['pattern'])({ const vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])({
date: function (format) { date: function (format) {
return moment_1.default(currentDate).utc().format(format); return moment_1.default(currentDate).utc().format(format);
} }
}); }), tag);
if (version.main == undefined) { if (version.main == undefined) {
version.main = vraw; version.main = vraw;
} }
@@ -475,24 +475,18 @@ class Meta {
includePrerelease: true includePrerelease: true
}); });
if (semver.prerelease(vraw)) { if (semver.prerelease(vraw)) {
vraw = handlebars.compile('{{version}}')(sver); vraw = this.setFlavor(handlebars.compile('{{version}}')(sver), tag);
if (version.main == undefined) {
version.main = vraw;
}
else if (vraw !== version.main) {
version.partial.push(vraw);
}
} }
else { else {
vraw = handlebars.compile(tag.attrs['pattern'])(sver); vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])(sver), tag);
if (version.main == undefined) {
version.main = vraw;
}
else if (vraw !== version.main) {
version.partial.push(vraw);
}
latest = true; latest = true;
} }
if (version.main == undefined) {
version.main = vraw;
}
else if (vraw !== version.main) {
version.partial.push(vraw);
}
if (version.latest == undefined) { if (version.latest == undefined) {
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true'; version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
} }
@@ -518,10 +512,16 @@ class Meta {
else { else {
tmatch = vraw.match(tag.attrs['pattern']); tmatch = vraw.match(tag.attrs['pattern']);
} }
if (tmatch) { if (!tmatch) {
vraw = tmatch[tag.attrs['group']]; core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
latest = true; return version;
} }
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
return version;
}
vraw = this.setFlavor(tmatch[tag.attrs['group']], tag);
latest = true;
if (version.main == undefined) { if (version.main == undefined) {
version.main = vraw; version.main = vraw;
} }
@@ -634,13 +634,13 @@ class Meta {
return version; return version;
} }
setFlavor(val, tag) { setFlavor(val, tag) {
if (tag.attrs['prefix'].length > 0) { if (tag.attrs.hasOwnProperty('prefix')) {
val = `${tag.attrs['prefix']}${val}`; val = `${tag.attrs['prefix']}${val}`;
} }
else if (this.flavor.prefix.length > 0) { else if (this.flavor.prefix.length > 0) {
val = `${this.flavor.prefix}${val}`; val = `${this.flavor.prefix}${val}`;
} }
if (tag.attrs['suffix'].length > 0) { if (tag.attrs.hasOwnProperty('suffix')) {
val = `${val}${tag.attrs['suffix']}`; val = `${val}${tag.attrs['suffix']}`;
} }
else if (this.flavor.suffix.length > 0) { else if (this.flavor.suffix.length > 0) {
@@ -912,12 +912,6 @@ function Parse(s) {
if (!tag.attrs.hasOwnProperty('priority')) { if (!tag.attrs.hasOwnProperty('priority')) {
tag.attrs['priority'] = exports.DefaultPriorities[tag.type]; tag.attrs['priority'] = exports.DefaultPriorities[tag.type];
} }
if (!tag.attrs.hasOwnProperty('prefix')) {
tag.attrs['prefix'] = '';
}
if (!tag.attrs.hasOwnProperty('suffix')) {
tag.attrs['suffix'] = '';
}
if (!['true', 'false'].includes(tag.attrs['enable'])) { if (!['true', 'false'].includes(tag.attrs['enable'])) {
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`); throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
} }

View File

@@ -99,11 +99,14 @@ export class Meta {
} }
const currentDate = this.date; const currentDate = this.date;
const vraw = handlebars.compile(tag.attrs['pattern'])({ const vraw = this.setFlavor(
date: function (format) { handlebars.compile(tag.attrs['pattern'])({
return moment(currentDate).utc().format(format); date: function (format) {
} return moment(currentDate).utc().format(format);
}); }
}),
tag
);
if (version.main == undefined) { if (version.main == undefined) {
version.main = vraw; version.main = vraw;
@@ -138,21 +141,16 @@ export class Meta {
includePrerelease: true includePrerelease: true
}); });
if (semver.prerelease(vraw)) { if (semver.prerelease(vraw)) {
vraw = handlebars.compile('{{version}}')(sver); vraw = this.setFlavor(handlebars.compile('{{version}}')(sver), tag);
if (version.main == undefined) {
version.main = vraw;
} else if (vraw !== version.main) {
version.partial.push(vraw);
}
} else { } else {
vraw = handlebars.compile(tag.attrs['pattern'])(sver); vraw = this.setFlavor(handlebars.compile(tag.attrs['pattern'])(sver), tag);
if (version.main == undefined) {
version.main = vraw;
} else if (vraw !== version.main) {
version.partial.push(vraw);
}
latest = true; latest = true;
} }
if (version.main == undefined) {
version.main = vraw;
} else if (vraw !== version.main) {
version.partial.push(vraw);
}
if (version.latest == undefined) { if (version.latest == undefined) {
version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true'; version.latest = this.flavor.latest == 'auto' ? latest : this.flavor.latest == 'true';
} }
@@ -180,10 +178,17 @@ export class Meta {
} else { } else {
tmatch = vraw.match(tag.attrs['pattern']); tmatch = vraw.match(tag.attrs['pattern']);
} }
if (tmatch) { if (!tmatch) {
vraw = tmatch[tag.attrs['group']]; core.warning(`${tag.attrs['pattern']} does not match ${vraw}.`);
latest = true; return version;
} }
if (typeof tmatch[tag.attrs['group']] === 'undefined') {
core.warning(`Group ${tag.attrs['group']} does not exist for ${tag.attrs['pattern']} pattern.`);
return version;
}
vraw = this.setFlavor(tmatch[tag.attrs['group']], tag);
latest = true;
if (version.main == undefined) { if (version.main == undefined) {
version.main = vraw; version.main = vraw;
@@ -310,12 +315,12 @@ export class Meta {
} }
private setFlavor(val: string, tag: tcl.Tag): string { private setFlavor(val: string, tag: tcl.Tag): string {
if (tag.attrs['prefix'].length > 0) { if (tag.attrs.hasOwnProperty('prefix')) {
val = `${tag.attrs['prefix']}${val}`; val = `${tag.attrs['prefix']}${val}`;
} else if (this.flavor.prefix.length > 0) { } else if (this.flavor.prefix.length > 0) {
val = `${this.flavor.prefix}${val}`; val = `${this.flavor.prefix}${val}`;
} }
if (tag.attrs['suffix'].length > 0) { if (tag.attrs.hasOwnProperty('suffix')) {
val = `${val}${tag.attrs['suffix']}`; val = `${val}${tag.attrs['suffix']}`;
} else if (this.flavor.suffix.length > 0) { } else if (this.flavor.suffix.length > 0) {
val = `${val}${this.flavor.suffix}`; val = `${val}${this.flavor.suffix}`;

View File

@@ -185,12 +185,6 @@ export function Parse(s: string): Tag {
if (!tag.attrs.hasOwnProperty('priority')) { if (!tag.attrs.hasOwnProperty('priority')) {
tag.attrs['priority'] = DefaultPriorities[tag.type]; tag.attrs['priority'] = DefaultPriorities[tag.type];
} }
if (!tag.attrs.hasOwnProperty('prefix')) {
tag.attrs['prefix'] = '';
}
if (!tag.attrs.hasOwnProperty('suffix')) {
tag.attrs['suffix'] = '';
}
if (!['true', 'false'].includes(tag.attrs['enable'])) { if (!['true', 'false'].includes(tag.attrs['enable'])) {
throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`); throw new Error(`Invalid value for enable attribute: ${tag.attrs['enable']}`);
} }