mirror of
https://github.com/docker/metadata-action.git
synced 2024-11-29 23:45:40 +01:00
Warn on invalid semver (#22)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
ef12c77b87
commit
4c2760ba7a
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -83,9 +83,11 @@ jobs:
|
|||||||
tag-semver:
|
tag-semver:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
-
|
||||||
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Docker meta
|
-
|
||||||
|
name: Docker meta
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
|
@ -737,6 +737,32 @@ describe('push tag', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'event_tag_sometag.env',
|
||||||
|
{
|
||||||
|
images: ['ghcr.io/user/app'],
|
||||||
|
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'sometag',
|
||||||
|
partial: [],
|
||||||
|
latest: true
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'ghcr.io/user/app:sometag',
|
||||||
|
'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=sometag",
|
||||||
|
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
|
||||||
|
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
|
||||||
|
"org.opencontainers.image.licenses=MIT"
|
||||||
|
]
|
||||||
|
],
|
||||||
])('given %p event ', tagsLabelsTest);
|
])('given %p event ', tagsLabelsTest);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
4
dist/index.js
generated
vendored
4
dist/index.js
generated
vendored
@ -171,6 +171,7 @@ exports.Meta = void 0;
|
|||||||
const handlebars = __webpack_require__(7492);
|
const handlebars = __webpack_require__(7492);
|
||||||
const moment = __webpack_require__(9623);
|
const moment = __webpack_require__(9623);
|
||||||
const semver = __webpack_require__(1383);
|
const semver = __webpack_require__(1383);
|
||||||
|
const core = __webpack_require__(2186);
|
||||||
class Meta {
|
class Meta {
|
||||||
constructor(inputs, context, repo) {
|
constructor(inputs, context, repo) {
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
@ -198,6 +199,9 @@ class Meta {
|
|||||||
}
|
}
|
||||||
else if (/^refs\/tags\//.test(this.context.ref)) {
|
else if (/^refs\/tags\//.test(this.context.ref)) {
|
||||||
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
|
if (this.inputs.tagSemver.length > 0 && !semver.valid(version.main)) {
|
||||||
|
core.warning(`${version.main} is not a valid semver. More info: https://semver.org/`);
|
||||||
|
}
|
||||||
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
|
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
|
||||||
const sver = semver.parse(version.main, {
|
const sver = semver.parse(version.main, {
|
||||||
includePrerelease: true
|
includePrerelease: true
|
||||||
|
@ -2,6 +2,7 @@ import * as handlebars from 'handlebars';
|
|||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
import * as semver from 'semver';
|
import * as semver from 'semver';
|
||||||
import {Inputs} from './context';
|
import {Inputs} from './context';
|
||||||
|
import * as core from '@actions/core';
|
||||||
import {Context} from '@actions/github/lib/context';
|
import {Context} from '@actions/github/lib/context';
|
||||||
import {ReposGetResponseData} from '@octokit/types';
|
import {ReposGetResponseData} from '@octokit/types';
|
||||||
|
|
||||||
@ -46,6 +47,9 @@ export class Meta {
|
|||||||
});
|
});
|
||||||
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
} else if (/^refs\/tags\//.test(this.context.ref)) {
|
||||||
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
version.main = this.context.ref.replace(/^refs\/tags\//g, '').replace(/\//g, '-');
|
||||||
|
if (this.inputs.tagSemver.length > 0 && !semver.valid(version.main)) {
|
||||||
|
core.warning(`${version.main} is not a valid semver. More info: https://semver.org/`);
|
||||||
|
}
|
||||||
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
|
if (this.inputs.tagSemver.length > 0 && semver.valid(version.main)) {
|
||||||
const sver = semver.parse(version.main, {
|
const sver = semver.parse(version.main, {
|
||||||
includePrerelease: true
|
includePrerelease: true
|
||||||
|
Loading…
Reference in New Issue
Block a user