Skip to content

Commit 7cb65aa

Browse files
committed
Pre-release (rc, beta, alpha) will only extend {{version}} as tag for tag-semver
1 parent 0dca12c commit 7cb65aa

5 files changed

Lines changed: 34 additions & 22 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.8.4 (2020/11/20)
4+
5+
* Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag for `tag-semver`
6+
37
## 1.8.3 (2020/11/20)
48

59
* Lowercase image name (#16)

README.md

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ ___
2626
* [outputs](#outputs)
2727
* [Notes](#notes)
2828
* [Latest tag](#latest-tag)
29-
* [`tag-match` examples](#tag-match-examples)
3029
* [Handle semver tag](#handle-semver-tag)
30+
* [`tag-match` examples](#tag-match-examples)
3131
* [Schedule tag](#schedule-tag)
3232
* [Overwrite labels](#overwrite-labels)
3333
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
@@ -250,6 +250,8 @@ Following inputs can be used as `step.with` keys
250250

251251
> List/CSV type can be a newline or comma delimited string
252252

253+
> `tag-semver` and `tag-match` are mutually exclusive
254+
253255
### outputs
254256

255257
Following outputs are available
@@ -266,18 +268,8 @@ Following outputs are available
266268

267269
Latest Docker tag will be generated by default on `push tag` event. If for example you push the `v1.2.3` Git tag,
268270
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
269-
generated only if the Git tag matches a regular expression with the [`tag-match` input](#tag-match-examples) or if
270-
`tag-semver` is valid [semver](https://semver.org/).
271-
272-
### `tag-match` examples
273-
274-
| Git tag | `tag-match` | `tag-match-group` | Match | Output tags | Output version |
275-
|-------------------------|------------------------------------|-------------------|----------------------|---------------------------|------------------------------|
276-
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
277-
| `v2.0.8-beta.67` | `v(.*)` | `1` | :white_check_mark: | `2.0.8-beta.67`, `latest` | `2.0.8-beta.67` |
278-
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | :white_check_mark: | `2.0`, `latest` | `2.0` |
279-
| `release1` | `\d{1,3}.\d{1,3}` | `0` | :x: | `release1` | `release1` |
280-
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` | `20200110` |
271+
generated only if `tag-semver` is a valid [semver](https://semver.org/) or if Git tag matches a regular expression
272+
with the [`tag-match` input](#tag-match-examples).
281273

282274
### Handle semver tag
283275

@@ -293,14 +285,25 @@ If Git tag is a valid [semver](https://semver.org/) you can handle it to output
293285
| `v1.2.3` | `{{minor}}` | :white_check_mark: | `2`, `latest` | `2` |
294286
| `v1.2.3` | `{{patch}}` | :white_check_mark: | `3`, `latest` | `3` |
295287
| `v1.2.3` | `{{major}}.{{minor}}`<br>`{{major}}.{{minor}}.{{patch}}` | :white_check_mark: | `1.2`, `1.2.3`, `latest` | `1.2`* |
296-
| `v2.0.8-beta.67` | `{{raw}}` | :white_check_mark: | `2.0.8-beta.67` | `2.0.8-beta.67` |
288+
| `v2.0.8-beta.67` | `{{raw}}` | :white_check_mark: | `2.0.8-beta.67`** | `2.0.8-beta.67` |
297289
| `v2.0.8-beta.67` | `{{version}}` | :white_check_mark: | `2.0.8-beta.67` | `2.0.8-beta.67` |
298290
| `v2.0.8-beta.67` | `{{major}}.{{minor}}` | :white_check_mark: | `2.0.8-beta.67`** | `2.0.8-beta.67` |
299291
| `release1` | `{{raw}}` | :x: | `release1` | `release1` |
300292

301293
> *First occurrence of `tag-semver` will be taken as `output.version`
302294

303-
> **Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag
295+
> **Pre-release (rc, beta, alpha) will only extend `{{version}}` as tag because they are updated frequently,
296+
> and contain many breaking changes that are (by the author's design) not yet fit for public consumption.
297+
298+
### `tag-match` examples
299+
300+
| Git tag | `tag-match` | `tag-match-group` | Match | Output tags | Output version |
301+
|-------------------------|------------------------------------|-------------------|----------------------|---------------------------|------------------------------|
302+
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | :white_check_mark: | `1.2.3`, `latest` | `1.2.3` |
303+
| `v2.0.8-beta.67` | `v(.*)` | `1` | :white_check_mark: | `2.0.8-beta.67`, `latest` | `2.0.8-beta.67` |
304+
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | :white_check_mark: | `2.0`, `latest` | `2.0` |
305+
| `release1` | `\d{1,3}.\d{1,3}` | `0` | :x: | `release1` | `release1` |
306+
| `20200110-RC2` | `\d+` | `0` | :white_check_mark: | `20200110`, `latest` | `20200110` |
304307

305308
### Schedule tag
306309

__tests__/meta.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ describe('push tag', () => {
715715
'event_tag_v2.0.8-beta.67.env',
716716
{
717717
images: ['org/app', 'ghcr.io/user/app'],
718-
tagSemver: ['{{version}}', '{{major}}.{{minor}}', '{{major}}'],
718+
tagSemver: ['{{major}}.{{minor}}', '{{major}}'],
719719
} as Inputs,
720720
{
721721
main: '2.0.8-beta.67',

dist/index.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/meta.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ export class Meta {
4747
const sver = semver.parse(version.main, {
4848
includePrerelease: true
4949
});
50-
version.latest = !semver.prerelease(version.main);
51-
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
52-
if (version.latest) {
50+
if (semver.prerelease(version.main)) {
51+
version.main = handlebars.compile('{{version}}')(sver);
52+
} else {
53+
version.latest = true;
54+
version.main = handlebars.compile(this.inputs.tagSemver[0])(sver);
5355
for (const semverTpl of this.inputs.tagSemver) {
5456
const partial = handlebars.compile(semverTpl)(sver);
5557
if (partial == version.main) {

0 commit comments

Comments
 (0)