mirror of
https://github.com/docker/metadata-action.git
synced 2024-12-23 02:47:42 +01:00
Use RegExp to match against a Git tag instead of coerce
This commit is contained in:
parent
4a3aaf409c
commit
983124bca8
41
README.md
41
README.md
@ -23,8 +23,7 @@ ___
|
|||||||
* [inputs](#inputs)
|
* [inputs](#inputs)
|
||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [Notes](#notes)
|
* [Notes](#notes)
|
||||||
* [Latest tag](#latest-tag)
|
* [`tag-match` examples](#tag-match-examples)
|
||||||
* [Coerces Git tag](#coerces-git-tag)
|
|
||||||
* [Schedule tag](#schedule-tag)
|
* [Schedule tag](#schedule-tag)
|
||||||
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
|
||||||
* [How can I help?](#how-can-i-help)
|
* [How can I help?](#how-can-i-help)
|
||||||
@ -75,10 +74,9 @@ jobs:
|
|||||||
id: docker_meta
|
id: docker_meta
|
||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
with:
|
with:
|
||||||
images: |
|
images: name/app
|
||||||
name/app
|
|
||||||
ghcr.io/name/app
|
|
||||||
tag-sha: true
|
tag-sha: true
|
||||||
|
tag-match: \\d{1,3}.\\d{1,3}.\\d{1,3}
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
@ -116,8 +114,8 @@ Following inputs can be used as `step.with` keys
|
|||||||
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
|
| `tag-sha` | Bool | Add git short SHA as Docker tag (default `false`) |
|
||||||
| `tag-edge` | Bool | Enable edge branch tagging (default `false`) |
|
| `tag-edge` | Bool | Enable edge branch tagging (default `false`) |
|
||||||
| `tag-edge-branch` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
|
| `tag-edge-branch` | String | Branch that will be tagged as edge (default `repo.default_branch`) |
|
||||||
| `tag-coerce-tag` | String | Coerces Git tag to semver if possible using [template](#coerces-git-tag) |
|
| `tag-match` | String | RegExp to match against a Git tag and use match group as Docker tag |
|
||||||
| `tag-latest-match` | String | Set `latest` tag only if [matches with a pattern](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) |
|
| `tag-match-latest` | Bool | Set `latest` Docker tag if `tag-match` matches (default `true`) |
|
||||||
| `tag-schedule` | String | [Template](#schedule-tag) to apply to schedule tag (default `nightly`) |
|
| `tag-schedule` | String | [Template](#schedule-tag) to apply to schedule tag (default `nightly`) |
|
||||||
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
| `sep-tags` | String | Separator to use for tags output (default `\n`) |
|
||||||
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
| `sep-labels` | String | Separator to use for labels output (default `\n`) |
|
||||||
@ -136,28 +134,15 @@ Following outputs are available
|
|||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
### Latest tag
|
### `tag-match` examples
|
||||||
|
|
||||||
`latest` tag is created with the following conditions:
|
| Git tag | `tag-match` | Docker tag
|
||||||
|
|-------------------------|--------------------------------|-------------------|
|
||||||
* Git tag is a valid [semver](https://semver.org/)
|
| `v1.2.3` | `\\d{1,3}.\\d{1,3}.\\d{1,3}` | `1.2.3` |
|
||||||
* Provided `tag-coerce-tag` is valid
|
| `v2.0.8-beta.67` | `\\d{1,3}.\\d{1,3}.\\d{1,3}.*` | `2.0.8-beta.67` |
|
||||||
|
| `v2.0.8-beta.67` | `\\d{1,3}.\\d{1,3}` | `2.0` |
|
||||||
If `tag-latest-match` is filled, then it has priority over the creation of the tag.
|
| `release1` | `\\d{1,3}.\\d{1,3}` | `release1` |
|
||||||
|
| `20200110-RC2` | `\\d+` | `20200110` |
|
||||||
### Coerces Git tag
|
|
||||||
|
|
||||||
Provides a very forgiving translation of a non-semver tag to semver. For more information see
|
|
||||||
[Coercion section](https://www.npmjs.com/package/semver#coercion). `tag-coerce-tag` supports
|
|
||||||
[Handlebars template](https://handlebarsjs.com/guide/) with the following inputs:
|
|
||||||
|
|
||||||
| `tag-coerce-tag` | Git tag | Version |
|
|
||||||
|-------------------------|----------|---------|
|
|
||||||
| `{{raw}}` | `v1.2.3` | `1.2.3` |
|
|
||||||
| `{{major}}.{{minor}}` | `v1.2.3` | `1.2` |
|
|
||||||
| `{{major}}` | `v1.2.3` | `1` |
|
|
||||||
| `{{minor}}` | `v1.2.3` | `2` |
|
|
||||||
| `{{patch}}` | `v1.2.3` | `3` |
|
|
||||||
|
|
||||||
### Schedule tag
|
### Schedule tag
|
||||||
|
|
||||||
|
@ -420,15 +420,15 @@ describe('push tag', () => {
|
|||||||
'event_tag_20200110-RC2.env',
|
'event_tag_20200110-RC2.env',
|
||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagCoerceTag: '{{major}}',
|
tagMatch: `\\d{8}`,
|
||||||
|
tagMatchLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110',
|
version: '20200110',
|
||||||
latest: true
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'user/app:20200110',
|
'user/app:20200110'
|
||||||
'user/app:latest'
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@ -441,34 +441,11 @@ describe('push tag', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'event_tag_v1.1.1.env',
|
|
||||||
{
|
|
||||||
images: ['user/app'],
|
|
||||||
} as Inputs,
|
|
||||||
{
|
|
||||||
version: '1.1.1',
|
|
||||||
latest: true
|
|
||||||
} as Version,
|
|
||||||
[
|
|
||||||
'user/app:1.1.1',
|
|
||||||
'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.git",
|
|
||||||
"org.opencontainers.image.version=1.1.1",
|
|
||||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
||||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
||||||
"org.opencontainers.image.licenses=MIT"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'event_tag_v1.1.1.env',
|
'event_tag_v1.1.1.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '1.1.1',
|
version: '1.1.1',
|
||||||
@ -491,39 +468,11 @@ describe('push tag', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'event_tag_v1.1.1.env',
|
|
||||||
{
|
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
|
||||||
tagSha: true,
|
|
||||||
} as Inputs,
|
|
||||||
{
|
|
||||||
version: '1.1.1',
|
|
||||||
latest: true
|
|
||||||
} as Version,
|
|
||||||
[
|
|
||||||
'org/app:1.1.1',
|
|
||||||
'org/app:latest',
|
|
||||||
'org/app:sha-90dd603',
|
|
||||||
'ghcr.io/user/app:1.1.1',
|
|
||||||
'ghcr.io/user/app:latest',
|
|
||||||
'ghcr.io/user/app:sha-90dd603'
|
|
||||||
],
|
|
||||||
[
|
|
||||||
"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.git",
|
|
||||||
"org.opencontainers.image.version=1.1.1",
|
|
||||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
||||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
||||||
"org.opencontainers.image.licenses=MIT"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'event_tag_v2.0.8-beta.67.env',
|
'event_tag_v2.0.8-beta.67.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}-(alpha|beta).\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '2.0.8-beta.67',
|
version: '2.0.8-beta.67',
|
||||||
@ -550,7 +499,7 @@ describe('push tag', () => {
|
|||||||
'event_tag_v2.0.8-beta.67.env',
|
'event_tag_v2.0.8-beta.67.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
tagCoerceTag: '{{major}}.{{minor}}',
|
tagMatch: `\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '2.0',
|
version: '2.0',
|
||||||
@ -577,7 +526,7 @@ describe('push tag', () => {
|
|||||||
'event_tag_sometag.env',
|
'event_tag_sometag.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
tagCoerceTag: '{{major}}.{{minor}}',
|
tagMatch: `\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'sometag',
|
version: 'sometag',
|
||||||
@ -608,7 +557,7 @@ describe('latest', () => {
|
|||||||
'event_tag_release1.env',
|
'event_tag_release1.env',
|
||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagLatestMatch: `^release`,
|
tagMatch: `^release\\d{1,2}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: 'release1',
|
version: 'release1',
|
||||||
@ -633,7 +582,7 @@ describe('latest', () => {
|
|||||||
'event_tag_20200110-RC2.env',
|
'event_tag_20200110-RC2.env',
|
||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagLatestMatch: `^\\d`,
|
tagMatch: `^\\d+-RC\\d{1,2}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110-RC2',
|
version: '20200110-RC2',
|
||||||
@ -658,8 +607,7 @@ describe('latest', () => {
|
|||||||
'event_tag_20200110-RC2.env',
|
'event_tag_20200110-RC2.env',
|
||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagCoerceTag: '{{major}}',
|
tagMatch: `\\d{8}`,
|
||||||
tagLatestMatch: `\\d`,
|
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '20200110',
|
version: '20200110',
|
||||||
@ -684,7 +632,7 @@ describe('latest', () => {
|
|||||||
'event_tag_v1.1.1.env',
|
'event_tag_v1.1.1.env',
|
||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagLatestMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '1.1.1',
|
version: '1.1.1',
|
||||||
@ -711,46 +659,19 @@ describe('latest', () => {
|
|||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '1.1.1',
|
version: 'v1.1.1',
|
||||||
latest: true
|
|
||||||
} as Version,
|
|
||||||
[
|
|
||||||
'org/app:1.1.1',
|
|
||||||
'org/app:latest',
|
|
||||||
'ghcr.io/user/app:1.1.1',
|
|
||||||
'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.git",
|
|
||||||
"org.opencontainers.image.version=1.1.1",
|
|
||||||
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
|
||||||
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
|
||||||
"org.opencontainers.image.licenses=MIT"
|
|
||||||
]
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'event_tag_v1.1.1.env',
|
|
||||||
{
|
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
|
||||||
tagLatestMatch: `2.\\d{1,3}.\\d{1,3}`,
|
|
||||||
} as Inputs,
|
|
||||||
{
|
|
||||||
version: '1.1.1',
|
|
||||||
latest: false
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'org/app:1.1.1',
|
'org/app:v1.1.1',
|
||||||
'ghcr.io/user/app:1.1.1',
|
'ghcr.io/user/app:v1.1.1',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"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.git",
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
||||||
"org.opencontainers.image.version=1.1.1",
|
"org.opencontainers.image.version=v1.1.1",
|
||||||
"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"
|
||||||
@ -760,16 +681,16 @@ describe('latest', () => {
|
|||||||
'event_tag_v2.0.8-beta.67.env',
|
'event_tag_v2.0.8-beta.67.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/user/app'],
|
images: ['org/app', 'ghcr.io/user/app'],
|
||||||
tagLatestMatch: `^\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
tagMatch: `\\d{1,3}.\\d{1,3}.\\d{1,3}`,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '2.0.8-beta.67',
|
version: '2.0.8',
|
||||||
latest: true
|
latest: true
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'org/app:2.0.8-beta.67',
|
'org/app:2.0.8',
|
||||||
'org/app:latest',
|
'org/app:latest',
|
||||||
'ghcr.io/user/app:2.0.8-beta.67',
|
'ghcr.io/user/app:2.0.8',
|
||||||
'ghcr.io/user/app:latest'
|
'ghcr.io/user/app:latest'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -777,7 +698,7 @@ describe('latest', () => {
|
|||||||
"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.git",
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
||||||
"org.opencontainers.image.version=2.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"
|
||||||
@ -1003,19 +924,18 @@ describe('release', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
version: '1.1.1',
|
version: 'v1.1.1',
|
||||||
latest: true
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'user/app:1.1.1',
|
'user/app:v1.1.1',
|
||||||
'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.git",
|
"org.opencontainers.image.source=https://github.com/octocat/Hello-World.git",
|
||||||
"org.opencontainers.image.version=1.1.1",
|
"org.opencontainers.image.version=v1.1.1",
|
||||||
"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"
|
||||||
|
@ -21,11 +21,12 @@ inputs:
|
|||||||
tag-edge-branch:
|
tag-edge-branch:
|
||||||
description: 'Branch that will be tagged as edge (default repo.default_branch)'
|
description: 'Branch that will be tagged as edge (default repo.default_branch)'
|
||||||
required: false
|
required: false
|
||||||
tag-coerce-tag:
|
tag-match:
|
||||||
description: 'Coerces Git tag to semver if possible using template'
|
description: 'RegExp to match against a Git tag and use match group as Docker tag'
|
||||||
required: false
|
required: false
|
||||||
tag-latest-match:
|
tag-match-latest:
|
||||||
description: 'Set latest tag only if matches with a pattern'
|
description: 'Set latest Docker tag if tag-match matches'
|
||||||
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
tag-schedule:
|
tag-schedule:
|
||||||
description: 'Template to apply to schedule tag'
|
description: 'Template to apply to schedule tag'
|
||||||
|
2181
dist/index.js
generated
vendored
2181
dist/index.js
generated
vendored
File diff suppressed because it is too large
Load Diff
@ -26,8 +26,7 @@
|
|||||||
"@actions/core": "^1.2.6",
|
"@actions/core": "^1.2.6",
|
||||||
"@actions/github": "^4.0.0",
|
"@actions/github": "^4.0.0",
|
||||||
"handlebars": "^4.7.6",
|
"handlebars": "^4.7.6",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1"
|
||||||
"semver": "^7.3.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^26.0.0",
|
"@types/jest": "^26.0.0",
|
||||||
|
@ -5,8 +5,8 @@ export interface Inputs {
|
|||||||
tagSha: boolean;
|
tagSha: boolean;
|
||||||
tagEdge: boolean;
|
tagEdge: boolean;
|
||||||
tagEdgeBranch: string;
|
tagEdgeBranch: string;
|
||||||
tagCoerceTag: string;
|
tagMatch: string;
|
||||||
tagLatestMatch: string;
|
tagMatchLatest: boolean;
|
||||||
tagSchedule: string;
|
tagSchedule: string;
|
||||||
sepTags: string;
|
sepTags: string;
|
||||||
sepLabels: string;
|
sepLabels: string;
|
||||||
@ -19,8 +19,8 @@ export function getInputs(): Inputs {
|
|||||||
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
|
tagSha: /true/i.test(core.getInput('tag-sha') || 'false'),
|
||||||
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
|
tagEdge: /true/i.test(core.getInput('tag-edge') || 'false'),
|
||||||
tagEdgeBranch: core.getInput('tag-edge-branch'),
|
tagEdgeBranch: core.getInput('tag-edge-branch'),
|
||||||
tagCoerceTag: core.getInput('tag-coerce-tag'),
|
tagMatch: core.getInput('tag-match'),
|
||||||
tagLatestMatch: core.getInput('tag-latest-match'),
|
tagMatchLatest: /true/i.test(core.getInput('tag-match-latest') || 'true'),
|
||||||
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
tagSchedule: core.getInput('tag-schedule') || 'nightly',
|
||||||
sepTags: core.getInput('sep-tags') || `\n`,
|
sepTags: core.getInput('sep-tags') || `\n`,
|
||||||
sepLabels: core.getInput('sep-labels') || `\n`,
|
sepLabels: core.getInput('sep-labels') || `\n`,
|
||||||
|
29
src/meta.ts
29
src/meta.ts
@ -1,6 +1,5 @@
|
|||||||
import * as handlebars from 'handlebars';
|
import * as handlebars from 'handlebars';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import * as semver from 'semver';
|
|
||||||
import {Inputs} from './context';
|
import {Inputs} from './context';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
import {ReposGetResponseData} from '@octokit/types';
|
||||||
@ -40,24 +39,13 @@ export class Meta {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
||||||
const tag = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
version.version = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
const sver = semver.clean(tag);
|
if (this.inputs.tagMatch) {
|
||||||
if (this.inputs.tagCoerceTag) {
|
const tagMatch = version.version.match(this.inputs.tagMatch);
|
||||||
const coerce = semver.coerce(tag);
|
if (tagMatch) {
|
||||||
if (coerce) {
|
version.version = tagMatch[0];
|
||||||
version.version = handlebars.compile(this.inputs.tagCoerceTag)(coerce);
|
version.latest = this.inputs.tagMatchLatest;
|
||||||
version.latest = true;
|
|
||||||
} else if (sver) {
|
|
||||||
version.version = sver;
|
|
||||||
version.latest = true;
|
|
||||||
} else {
|
|
||||||
version.version = tag;
|
|
||||||
}
|
}
|
||||||
} else if (sver) {
|
|
||||||
version.version = sver;
|
|
||||||
version.latest = true;
|
|
||||||
} else {
|
|
||||||
version.version = tag;
|
|
||||||
}
|
}
|
||||||
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
||||||
version.version = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
|
version.version = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
|
||||||
@ -68,11 +56,6 @@ export class Meta {
|
|||||||
version.version = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
|
version.version = `pr-${this.context.ref.replace(/^refs\/pull\//g, '').replace(/\/merge$/g, '')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.inputs.tagLatestMatch) {
|
|
||||||
const match = version.version?.match(new RegExp(this.inputs.tagLatestMatch));
|
|
||||||
version.latest = match !== null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user