mirror of
https://github.com/docker/metadata-action.git
synced 2024-11-23 04:25:40 +01:00
Allow to disable latest tag (#23)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
4c2760ba7a
commit
9de4428611
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@ -82,6 +82,12 @@ jobs:
|
|||||||
|
|
||||||
tag-semver:
|
tag-semver:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
tag-latest:
|
||||||
|
- 'true'
|
||||||
|
- 'false'
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
@ -97,6 +103,7 @@ jobs:
|
|||||||
{{raw}}
|
{{raw}}
|
||||||
{{version}}
|
{{version}}
|
||||||
{{major}}.{{minor}}.{{patch}}
|
{{major}}.{{minor}}.{{patch}}
|
||||||
|
tag-latest: ${{ matrix.tag-latest }}
|
||||||
|
|
||||||
docker-push:
|
docker-push:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -116,7 +123,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
images: ${{ env.DOCKER_IMAGE }}
|
images: ${{ env.DOCKER_IMAGE }}
|
||||||
tag-sha: true
|
tag-sha: true
|
||||||
tag-match: '\d{1,3}.\d{1,3}.\d{1,3}'
|
tag-semver: |
|
||||||
|
v{{version}}
|
||||||
|
v{{major}}.{{minor}}
|
||||||
|
v{{major}}
|
||||||
-
|
-
|
||||||
name: Set up QEMU
|
name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
|
@ -241,10 +241,10 @@ 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-semver` | List | Handle Git tag as semver [template](#handle-semver-tag) if possible |
|
| `tag-semver` | List/CSV | Handle Git tag as semver [template](#handle-semver-tag) if possible |
|
||||||
| `tag-match` | String | RegExp to match against a Git tag and use first match as Docker tag |
|
| `tag-match` | String | RegExp to match against a Git tag and use first match as Docker tag |
|
||||||
| `tag-match-group` | Number | Group to get if `tag-match` matches (default `0`) |
|
| `tag-match-group` | Number | Group to get if `tag-match` matches (default `0`) |
|
||||||
| `tag-match-latest` | Bool | Set `latest` Docker tag if `tag-match` matches or on Git tag event (default `true`) |
|
| `tag-latest` | Bool | Set `latest` Docker tag if `tag-semver`, `tag-match` or Git tag event occurs (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`) |
|
||||||
|
@ -437,7 +437,7 @@ describe('push tag', () => {
|
|||||||
{
|
{
|
||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagMatch: `\\d{8}`,
|
tagMatch: `\\d{8}`,
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: '20200110',
|
main: '20200110',
|
||||||
@ -464,7 +464,7 @@ describe('push tag', () => {
|
|||||||
images: ['user/app'],
|
images: ['user/app'],
|
||||||
tagMatch: `(.*)-RC`,
|
tagMatch: `(.*)-RC`,
|
||||||
tagMatchGroup: 1,
|
tagMatchGroup: 1,
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: '20200110',
|
main: '20200110',
|
||||||
@ -742,15 +742,15 @@ describe('push tag', () => {
|
|||||||
{
|
{
|
||||||
images: ['ghcr.io/user/app'],
|
images: ['ghcr.io/user/app'],
|
||||||
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
||||||
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'sometag',
|
main: 'sometag',
|
||||||
partial: [],
|
partial: [],
|
||||||
latest: true
|
latest: false
|
||||||
} as Version,
|
} as Version,
|
||||||
[
|
[
|
||||||
'ghcr.io/user/app:sometag',
|
'ghcr.io/user/app:sometag'
|
||||||
'ghcr.io/user/app:latest',
|
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"org.opencontainers.image.title=Hello-World",
|
"org.opencontainers.image.title=Hello-World",
|
||||||
@ -932,7 +932,7 @@ describe('latest', () => {
|
|||||||
'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'],
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'v1.1.1',
|
main: 'v1.1.1',
|
||||||
@ -958,7 +958,7 @@ describe('latest', () => {
|
|||||||
'event_tag_v1.1.1.env',
|
'event_tag_v1.1.1.env',
|
||||||
{
|
{
|
||||||
images: ['org/app', 'ghcr.io/MyUSER/MyApp'],
|
images: ['org/app', 'ghcr.io/MyUSER/MyApp'],
|
||||||
tagMatchLatest: false,
|
tagLatest: false,
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: 'v1.1.1',
|
main: 'v1.1.1',
|
||||||
|
@ -31,8 +31,13 @@ inputs:
|
|||||||
description: 'Group to get if tag-match matches (default 0)'
|
description: 'Group to get if tag-match matches (default 0)'
|
||||||
default: '0'
|
default: '0'
|
||||||
required: false
|
required: false
|
||||||
|
tag-latest:
|
||||||
|
description: 'Set latest Docker tag if tag-semver, tag-match or Git tag event occurs'
|
||||||
|
default: 'true'
|
||||||
|
required: false
|
||||||
tag-match-latest:
|
tag-match-latest:
|
||||||
description: 'Set latest Docker tag if tag-match matches or on Git tag event'
|
deprecationMessage: 'tag-match-latest is deprecated. Use tag-latest instead'
|
||||||
|
description: '(DEPRECATED) Set latest Docker tag if tag-match matches or on Git tag event'
|
||||||
default: 'true'
|
default: 'true'
|
||||||
required: false
|
required: false
|
||||||
tag-schedule:
|
tag-schedule:
|
||||||
|
8
dist/index.js
generated
vendored
8
dist/index.js
generated
vendored
@ -28,7 +28,7 @@ function getInputs() {
|
|||||||
tagSemver: getInputList('tag-semver'),
|
tagSemver: getInputList('tag-semver'),
|
||||||
tagMatch: core.getInput('tag-match'),
|
tagMatch: core.getInput('tag-match'),
|
||||||
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
||||||
tagMatchLatest: /true/i.test(core.getInput('tag-match-latest') || 'true'),
|
tagLatest: /true/i.test(core.getInput('tag-latest') || 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`,
|
||||||
@ -210,7 +210,7 @@ class Meta {
|
|||||||
version.main = handlebars.compile('{{version}}')(sver);
|
version.main = handlebars.compile('{{version}}')(sver);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
version.latest = true;
|
version.latest = this.inputs.tagLatest;
|
||||||
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
||||||
for (const semverTpl of this.inputs.tagSemver) {
|
for (const semverTpl of this.inputs.tagSemver) {
|
||||||
const partial = handlebars.compile(semverTpl)(sver);
|
const partial = handlebars.compile(semverTpl)(sver);
|
||||||
@ -232,11 +232,11 @@ class Meta {
|
|||||||
}
|
}
|
||||||
if (tagMatch) {
|
if (tagMatch) {
|
||||||
version.main = tagMatch[this.inputs.tagMatchGroup];
|
version.main = tagMatch[this.inputs.tagMatchGroup];
|
||||||
version.latest = this.inputs.tagMatchLatest;
|
version.latest = this.inputs.tagLatest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
version.latest = this.inputs.tagMatchLatest;
|
version.latest = this.inputs.tagLatest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (/^refs\/heads\//.test(this.context.ref)) {
|
else if (/^refs\/heads\//.test(this.context.ref)) {
|
||||||
|
@ -8,7 +8,7 @@ export interface Inputs {
|
|||||||
tagSemver: string[];
|
tagSemver: string[];
|
||||||
tagMatch: string;
|
tagMatch: string;
|
||||||
tagMatchGroup: number;
|
tagMatchGroup: number;
|
||||||
tagMatchLatest: boolean;
|
tagLatest: boolean;
|
||||||
tagSchedule: string;
|
tagSchedule: string;
|
||||||
sepTags: string;
|
sepTags: string;
|
||||||
sepLabels: string;
|
sepLabels: string;
|
||||||
@ -24,7 +24,7 @@ export function getInputs(): Inputs {
|
|||||||
tagSemver: getInputList('tag-semver'),
|
tagSemver: getInputList('tag-semver'),
|
||||||
tagMatch: core.getInput('tag-match'),
|
tagMatch: core.getInput('tag-match'),
|
||||||
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
tagMatchGroup: Number(core.getInput('tag-match-group')) || 0,
|
||||||
tagMatchLatest: /true/i.test(core.getInput('tag-match-latest') || 'true'),
|
tagLatest: /true/i.test(core.getInput('tag-latest') || 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`,
|
||||||
|
@ -57,7 +57,7 @@ export class Meta {
|
|||||||
if (semver.prerelease(version.main)) {
|
if (semver.prerelease(version.main)) {
|
||||||
version.main = handlebars.compile('{{version}}')(sver);
|
version.main = handlebars.compile('{{version}}')(sver);
|
||||||
} else {
|
} else {
|
||||||
version.latest = true;
|
version.latest = this.inputs.tagLatest;
|
||||||
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
||||||
for (const semverTpl of this.inputs.tagSemver) {
|
for (const semverTpl of this.inputs.tagSemver) {
|
||||||
const partial = handlebars.compile(semverTpl)(sver);
|
const partial = handlebars.compile(semverTpl)(sver);
|
||||||
@ -77,10 +77,10 @@ export class Meta {
|
|||||||
}
|
}
|
||||||
if (tagMatch) {
|
if (tagMatch) {
|
||||||
version.main = tagMatch[this.inputs.tagMatchGroup];
|
version.main = tagMatch[this.inputs.tagMatchGroup];
|
||||||
version.latest = this.inputs.tagMatchLatest;
|
version.latest = this.inputs.tagLatest;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
version.latest = this.inputs.tagMatchLatest;
|
version.latest = this.inputs.tagLatest;
|
||||||
}
|
}
|
||||||
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
} else if (/^refs\/heads\//.test(this.context.ref)) {
|
||||||
version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
|
version.main = this.context.ref.replace(/^refs\/heads\//g, '').replace(/\//g, '-');
|
||||||
|
Loading…
Reference in New Issue
Block a user