Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c53f88523a | ||
|
6b4bf4724e | ||
|
d48c7d2917 | ||
|
7cb65aaacb | ||
|
0dca12c226 | ||
|
6f270f37d4 | ||
|
2860e42b1f | ||
|
6a86fe1739 | ||
|
86dc87790d |
12
CHANGELOG.md
12
CHANGELOG.md
@@ -1,5 +1,17 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 1.8.5 (2020/11/24)
|
||||||
|
|
||||||
|
* Use sepLabels when joining labels for output (#17)
|
||||||
|
|
||||||
|
## 1.8.4 (2020/11/20)
|
||||||
|
|
||||||
|
* Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag for `tag-semver`
|
||||||
|
|
||||||
|
## 1.8.3 (2020/11/20)
|
||||||
|
|
||||||
|
* Lowercase image name (#16)
|
||||||
|
|
||||||
## 1.8.2 (2020/11/18)
|
## 1.8.2 (2020/11/18)
|
||||||
|
|
||||||
* Remove duplicated tags
|
* Remove duplicated tags
|
||||||
|
50
README.md
50
README.md
@@ -26,8 +26,8 @@ ___
|
|||||||
* [outputs](#outputs)
|
* [outputs](#outputs)
|
||||||
* [Notes](#notes)
|
* [Notes](#notes)
|
||||||
* [Latest tag](#latest-tag)
|
* [Latest tag](#latest-tag)
|
||||||
* [`tag-match` examples](#tag-match-examples)
|
|
||||||
* [Handle semver tag](#handle-semver-tag)
|
* [Handle semver tag](#handle-semver-tag)
|
||||||
|
* [`tag-match` examples](#tag-match-examples)
|
||||||
* [Schedule tag](#schedule-tag)
|
* [Schedule tag](#schedule-tag)
|
||||||
* [Overwrite labels](#overwrite-labels)
|
* [Overwrite labels](#overwrite-labels)
|
||||||
* [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)
|
||||||
@@ -168,11 +168,11 @@ jobs:
|
|||||||
| Event | Ref | Commit SHA | Docker Tags |
|
| Event | Ref | Commit SHA | Docker Tags |
|
||||||
|-----------------|-------------------------------|------------|-----------------------------------------|
|
|-----------------|-------------------------------|------------|-----------------------------------------|
|
||||||
| `schedule` | `refs/heads/master` | `45f132a` | `sha-45f132a`, `nightly` |
|
| `schedule` | `refs/heads/master` | `45f132a` | `sha-45f132a`, `nightly` |
|
||||||
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-45f132a`, `pr-2` |
|
| `pull_request` | `refs/pull/2/merge` | `a123b57` | `sha-a123b57`, `pr-2` |
|
||||||
| `push` | `refs/heads/master` | `cf20257` | `sha-45f132a`, `master` |
|
| `push` | `refs/heads/master` | `cf20257` | `sha-cf20257`, `master` |
|
||||||
| `push` | `refs/heads/my/branch` | `a5df687` | `sha-45f132a`, `my-branch` |
|
| `push` | `refs/heads/my/branch` | `a5df687` | `sha-a5df687`, `my-branch` |
|
||||||
| `push tag` | `refs/tags/v1.2.3` | `ad132f5` | `sha-45f132a`, `1.2.3`, `1.2`, `latest` |
|
| `push tag` | `refs/tags/v1.2.3` | `ad132f5` | `sha-ad132f5`, `1.2.3`, `1.2`, `latest` |
|
||||||
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `sha-45f132a`, `2.0.8-beta.67` |
|
| `push tag` | `refs/tags/v2.0.8-beta.67` | `fc89efd` | `sha-fc89efd`, `2.0.8-beta.67` |
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: ci
|
name: ci
|
||||||
@@ -200,6 +200,7 @@ jobs:
|
|||||||
uses: crazy-max/ghaction-docker-meta@v1
|
uses: crazy-max/ghaction-docker-meta@v1
|
||||||
with:
|
with:
|
||||||
images: name/app
|
images: name/app
|
||||||
|
tag-sha: true
|
||||||
tag-semver: |
|
tag-semver: |
|
||||||
{{version}}
|
{{version}}
|
||||||
{{major}}.{{minor}}
|
{{major}}.{{minor}}
|
||||||
@@ -250,6 +251,8 @@ Following inputs can be used as `step.with` keys
|
|||||||
|
|
||||||
> List/CSV type can be a newline or comma delimited string
|
> List/CSV type can be a newline or comma delimited string
|
||||||
|
|
||||||
|
> `tag-semver` and `tag-match` are mutually exclusive
|
||||||
|
|
||||||
### outputs
|
### outputs
|
||||||
|
|
||||||
Following outputs are available
|
Following outputs are available
|
||||||
@@ -266,18 +269,8 @@ Following outputs are available
|
|||||||
|
|
||||||
Latest Docker tag will be generated by default on `push tag` event. If for example you push the `v1.2.3` Git tag,
|
Latest Docker tag will be generated by default on `push tag` event. If for example you push the `v1.2.3` Git tag,
|
||||||
you will have at the output of this action the Docker tags `v1.2.3` and `latest`. But you can allow the latest tag to be
|
you will have at the output of this action the Docker tags `v1.2.3` and `latest`. But you can allow the latest tag to be
|
||||||
generated only if the Git tag matches a regular expression with the [`tag-match` input](#tag-match-examples) or if
|
generated only if `tag-semver` is a valid [semver](https://semver.org/) or if Git tag matches a regular expression
|
||||||
`tag-semver` is valid [semver](https://semver.org/).
|
with the [`tag-match` input](#tag-match-examples).
|
||||||
|
|
||||||
### `tag-match` examples
|
|
||||||
|
|
||||||
| Git tag | `tag-match` | `tag-match-group` | Match | Output tags | Output version |
|
|
||||||
|-------------------------|------------------------------------|-------------------|----------------------|---------------------------|------------------------------|
|
|
||||||
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
|
|
||||||
| `v2.0.8-beta.67` | `v(.*)` | `1` | :white_check_mark: | `2.0.8-beta.67`, `latest` | `2.0.8-beta.67` |
|
|
||||||
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | :white_check_mark: | `2.0`, `latest` | `2.0` |
|
|
||||||
| `release1` | `\d{1,3}.\d{1,3}` | `0` | :x: | `release1` | `release1` |
|
|
||||||
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` | `20200110` |
|
|
||||||
|
|
||||||
### Handle semver tag
|
### Handle semver tag
|
||||||
|
|
||||||
@@ -292,12 +285,27 @@ If Git tag is a valid [semver](https://semver.org/) you can handle it to output
|
|||||||
| `v1.2.3` | `v{{major}}` | :white_check_mark: | `v1`, `latest` | `v1` |
|
| `v1.2.3` | `v{{major}}` | :white_check_mark: | `v1`, `latest` | `v1` |
|
||||||
| `v1.2.3` | `{{minor}}` | :white_check_mark: | `2`, `latest` | `2` |
|
| `v1.2.3` | `{{minor}}` | :white_check_mark: | `2`, `latest` | `2` |
|
||||||
| `v1.2.3` | `{{patch}}` | :white_check_mark: | `3`, `latest` | `3` |
|
| `v1.2.3` | `{{patch}}` | :white_check_mark: | `3`, `latest` | `3` |
|
||||||
| `v1.2.3` | `{{major}}.{{minor}}`<br>`{{major}}.{{minor}}.{{patch}}` | :white_check_mark: | `1.2`, `1.2.3`, `latest` | `1.2` |
|
| `v1.2.3` | `{{major}}.{{minor}}`<br>`{{major}}.{{minor}}.{{patch}}` | :white_check_mark: | `1.2`, `1.2.3`, `latest` | `1.2`* |
|
||||||
| `v2.0.8-beta.67` | `{{raw}}` | :white_check_mark: | `v2.0.8-beta.67` | `v2.0.8-beta.67` |
|
| `v2.0.8-beta.67` | `{{raw}}` | :white_check_mark: | `2.0.8-beta.67`** | `2.0.8-beta.67` |
|
||||||
| `v2.0.8-beta.67` | `{{version}}` | :white_check_mark: | `2.0.8-beta.67` | `2.0.8-beta.67` |
|
| `v2.0.8-beta.67` | `{{version}}` | :white_check_mark: | `2.0.8-beta.67` | `2.0.8-beta.67` |
|
||||||
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | :white_check_mark: | `2.0` | `2.0` |
|
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | :white_check_mark: | `2.0.8-beta.67`** | `2.0.8-beta.67` |
|
||||||
| `release1` | `{{raw}}` | :x: | `release1` | `release1` |
|
| `release1` | `{{raw}}` | :x: | `release1` | `release1` |
|
||||||
|
|
||||||
|
> *First occurrence of `tag-semver` will be taken as `output.version`
|
||||||
|
|
||||||
|
> **Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag because they are updated frequently,
|
||||||
|
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
|
||||||
|
|
||||||
|
### `tag-match` examples
|
||||||
|
|
||||||
|
| Git tag | `tag-match` | `tag-match-group` | Match | Output tags | Output version |
|
||||||
|
|-------------------------|------------------------------------|-------------------|----------------------|---------------------------|------------------------------|
|
||||||
|
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
|
||||||
|
| `v2.0.8-beta.67` | `v(.*)` | `1` | :white_check_mark: | `2.0.8-beta.67`, `latest` | `2.0.8-beta.67` |
|
||||||
|
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | :white_check_mark: | `2.0`, `latest` | `2.0` |
|
||||||
|
| `release1` | `\d{1,3}.\d{1,3}` | `0` | :x: | `release1` | `release1` |
|
||||||
|
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` | `20200110` |
|
||||||
|
|
||||||
### Schedule tag
|
### Schedule tag
|
||||||
|
|
||||||
`tag-schedule` is specially crafted input to support [Handlebars template](https://handlebarsjs.com/guide/) with
|
`tag-schedule` is specially crafted input to support [Handlebars template](https://handlebarsjs.com/guide/) with
|
||||||
|
@@ -715,7 +715,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'],
|
||||||
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
|
tagSemver: ['{{major}}.{{minor}}', '{{major}}'],
|
||||||
} as Inputs,
|
} as Inputs,
|
||||||
{
|
{
|
||||||
main: '2.0.8-beta.67',
|
main: '2.0.8-beta.67',
|
||||||
@@ -928,6 +928,32 @@ describe('latest', () => {
|
|||||||
"org.opencontainers.image.licenses=MIT"
|
"org.opencontainers.image.licenses=MIT"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'event_tag_v1.1.1.env',
|
||||||
|
{
|
||||||
|
images: ['org/app', 'ghcr.io/MyUSER/MyApp'],
|
||||||
|
tagMatchLatest: false,
|
||||||
|
} as Inputs,
|
||||||
|
{
|
||||||
|
main: 'v1.1.1',
|
||||||
|
partial: [],
|
||||||
|
latest: false
|
||||||
|
} as Version,
|
||||||
|
[
|
||||||
|
'org/app:v1.1.1',
|
||||||
|
'ghcr.io/myuser/myapp:v1.1.1',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"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=v1.1.1",
|
||||||
|
"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);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
20
dist/index.js
generated
vendored
20
dist/index.js
generated
vendored
@@ -149,7 +149,7 @@ function run() {
|
|||||||
core.info(label);
|
core.info(label);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('labels', labels.join(inputs.sepTags));
|
core.setOutput('labels', labels.join(inputs.sepLabels));
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
@@ -201,9 +201,12 @@ class Meta {
|
|||||||
const sver = semver.parse(version.main, {
|
const sver = semver.parse(version.main, {
|
||||||
includePrerelease: true
|
includePrerelease: true
|
||||||
});
|
});
|
||||||
version.latest = !semver.prerelease(version.main);
|
if (semver.prerelease(version.main)) {
|
||||||
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
version.main = handlebars.compile('{{version}}')(sver);
|
||||||
if (version.latest) {
|
}
|
||||||
|
else {
|
||||||
|
version.latest = true;
|
||||||
|
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);
|
||||||
if (partial == version.main) {
|
if (partial == version.main) {
|
||||||
@@ -250,15 +253,16 @@ class Meta {
|
|||||||
}
|
}
|
||||||
let tags = [];
|
let tags = [];
|
||||||
for (const image of this.inputs.images) {
|
for (const image of this.inputs.images) {
|
||||||
tags.push(`${image}:${version.main}`);
|
const imageLc = image.toLowerCase();
|
||||||
|
tags.push(`${imageLc}:${version.main}`);
|
||||||
for (const partial of version.partial) {
|
for (const partial of version.partial) {
|
||||||
tags.push(`${image}:${partial}`);
|
tags.push(`${imageLc}:${partial}`);
|
||||||
}
|
}
|
||||||
if (version.latest) {
|
if (version.latest) {
|
||||||
tags.push(`${image}:latest`);
|
tags.push(`${imageLc}:latest`);
|
||||||
}
|
}
|
||||||
if (this.context.sha && this.inputs.tagSha) {
|
if (this.context.sha && this.inputs.tagSha) {
|
||||||
tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
|
tags.push(`${imageLc}:sha-${this.context.sha.substr(0, 7)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
|
@@ -47,7 +47,7 @@ async function run() {
|
|||||||
core.info(label);
|
core.info(label);
|
||||||
}
|
}
|
||||||
core.endGroup();
|
core.endGroup();
|
||||||
core.setOutput('labels', labels.join(inputs.sepTags));
|
core.setOutput('labels', labels.join(inputs.sepLabels));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
|
17
src/meta.ts
17
src/meta.ts
@@ -47,9 +47,11 @@ export class Meta {
|
|||||||
const sver = semver.parse(version.main, {
|
const sver = semver.parse(version.main, {
|
||||||
includePrerelease: true
|
includePrerelease: true
|
||||||
});
|
});
|
||||||
version.latest = !semver.prerelease(version.main);
|
if (semver.prerelease(version.main)) {
|
||||||
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
|
version.main = handlebars.compile('{{version}}')(sver);
|
||||||
if (version.latest) {
|
} else {
|
||||||
|
version.latest = true;
|
||||||
|
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);
|
||||||
if (partial == version.main) {
|
if (partial == version.main) {
|
||||||
@@ -94,15 +96,16 @@ export class Meta {
|
|||||||
|
|
||||||
let tags: Array<string> = [];
|
let tags: Array<string> = [];
|
||||||
for (const image of this.inputs.images) {
|
for (const image of this.inputs.images) {
|
||||||
tags.push(`${image}:${version.main}`);
|
const imageLc = image.toLowerCase();
|
||||||
|
tags.push(`${imageLc}:${version.main}`);
|
||||||
for (const partial of version.partial) {
|
for (const partial of version.partial) {
|
||||||
tags.push(`${image}:${partial}`);
|
tags.push(`${imageLc}:${partial}`);
|
||||||
}
|
}
|
||||||
if (version.latest) {
|
if (version.latest) {
|
||||||
tags.push(`${image}:latest`);
|
tags.push(`${imageLc}:latest`);
|
||||||
}
|
}
|
||||||
if (this.context.sha && this.inputs.tagSha) {
|
if (this.context.sha && this.inputs.tagSha) {
|
||||||
tags.push(`${image}:sha-${this.context.sha.substr(0, 7)}`);
|
tags.push(`${imageLc}:sha-${this.context.sha.substr(0, 7)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tags;
|
return tags;
|
||||||
|
Reference in New Issue
Block a user