Compare commits

..

8 Commits

Author SHA1 Message Date
CrazyMax
9da1e66de9 Update CHANGELOG 2021-04-03 18:21:52 +02:00
CrazyMax
521a3c5ada Fix README (#56) 2021-04-03 18:18:32 +02:00
CrazyMax
7433b42479 Improve logging (#58)
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
2021-04-03 18:15:27 +02:00
CrazyMax
1a8a264b95 Update README 2021-03-31 10:01:20 +02:00
CrazyMax
e04b4d01a9 Cleanup 2021-03-30 13:57:33 +02:00
CrazyMax
ac90ddf06e Update CHANGELOG 2021-03-30 13:23:09 +02:00
dependabot[bot]
972129059a Bump y18n from 4.0.0 to 4.0.1 (#54)
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-03-30 13:15:08 +02:00
Jakub Bacic
b909bd34ef Fix 'enable' tag attribute (#53) 2021-03-30 13:11:51 +02:00
10 changed files with 205 additions and 39 deletions

View File

@@ -72,9 +72,9 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- tag-match: '\d{1,3}.\d{1,3}.\d{1,3}' - tag-match: '\d.\d.\d'
tag-match-group: '0' tag-match-group: '0'
- tag-match: '\d{1,3}.\d{1,3}' - tag-match: '\d.\d'
tag-match-group: '0' tag-match-group: '0'
- tag-match: 'v(.*)' - tag-match: 'v(.*)'
tag-match-group: '1' tag-match-group: '1'

View File

@@ -1,5 +1,15 @@
# Changelog # Changelog
## 2.2.0 (2021/04/03)
* Improve logging (#58)
* Fix README (#56)
## 2.1.1 (2021/03/30)
* Fix `enable` tag attribute (#53)
* Bump y18n from 4.0.0 to 4.0.1 (#54)
## 2.1.0 (2021/03/29) ## 2.1.0 (2021/03/29)
* Bump semver from 7.3.4 to 7.3.5 (#49) * Bump semver from 7.3.4 to 7.3.5 (#49)

View File

@@ -252,7 +252,7 @@ Following inputs can be used as `step.with` keys
> `List` type is a newline-delimited string > `List` type is a newline-delimited string
> ```yaml > ```yaml
> label-custom: | > labels: |
> org.opencontainers.image.title=MyCustomTitle > org.opencontainers.image.title=MyCustomTitle
> org.opencontainers.image.description=Another description > org.opencontainers.image.description=Another description
> org.opencontainers.image.vendor=MyCompany > org.opencontainers.image.vendor=MyCompany
@@ -420,9 +420,7 @@ tags: |
```yaml ```yaml
tags: | tags: |
# minimal # minimal
type=match,pattern=\d{8} type=match,pattern=\d.\d.\d
# double quotes if comma in pattern
type=match,"pattern=\d{1,3}.\d{1,3}.\d{1,3}"
# define match group # define match group
type=match,pattern=v(.*),group=1 type=match,pattern=v(.*),group=1
# use custom value instead of git tag # use custom value instead of git tag
@@ -435,7 +433,7 @@ a custom value through `value` attribute.
| Git tag | Pattern | Group | Output | | Git tag | Pattern | Group | Output |
|-------------------------|-------------------------------|---------|------------------------| |-------------------------|-------------------------------|---------|------------------------|
| `v1.2.3` | `\d{1,3}.\d{1,3}.\d{1,3}` | `0` | `1.2.3` | | `v1.2.3` | `\d.\d.\d` | `0` | `1.2.3` |
| `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` | | `v2.0.8-beta.67` | `v(.*)` | `1` | `2.0.8-beta.67` |
| `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` | | `v2.0.8-beta.67` | `v(\d.\d)` | `1` | `2.0` |
| `20200110-RC2` | `\d+` | `0` | `20200110` | | `20200110-RC2` | `\d+` | `0` | `20200110` |
@@ -444,7 +442,7 @@ Extended attributes and default values:
```yaml ```yaml
tags: | tags: |
type=group,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value= type=match,enable=true,priority=800,prefix=,suffix=,pattern=,group=0,value=
``` ```
### `type=edge` ### `type=edge`

View File

@@ -557,6 +557,35 @@ describe('push', () => {
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
] ]
],
[
'push16',
'event_push_defbranch.env',
{
images: ['user/app'],
tags: [
`type=match,enable=false,pattern=v(.*),group=1,value=v1.2.3`,
`type=edge`
],
} as Inputs,
{
main: 'edge',
partial: [],
latest: false
} as Version,
[
'user/app:edge'
],
[
"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=edge",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
] ]
])('given %p with %p event', tagsLabelsTest); ])('given %p with %p event', tagsLabelsTest);
}); });
@@ -684,7 +713,7 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d.\\d"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -715,7 +744,7 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",group=1` `type=match,"pattern=^v(\\d.\\d.\\d)$",group=1`
] ]
} as Inputs, } as Inputs,
{ {
@@ -746,7 +775,7 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}-(alpha|beta).\\d{1,3}"` `type=match,"pattern=\\d.\\d.\\d-(alpha|beta).\\d+"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -777,7 +806,7 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -808,7 +837,7 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=/^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$/ig",group=1`, `type=match,"pattern=/^v(\\d.\\d.\\d)$/ig",group=1`,
] ]
} as Inputs, } as Inputs,
{ {
@@ -837,7 +866,7 @@ describe('tag', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -1001,7 +1030,7 @@ describe('tag', () => {
tags: [ tags: [
`type=raw,priority=2000,foo`, `type=raw,priority=2000,foo`,
`type=semver,pattern={{version}}`, `type=semver,pattern={{version}}`,
`type=match,"pattern=\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -1160,7 +1189,7 @@ describe('latest', () => {
{ {
images: ['user/app'], images: ['user/app'],
tags: [ tags: [
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d.\\d"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -1217,7 +1246,7 @@ describe('latest', () => {
{ {
images: ['org/app', 'ghcr.io/user/app'], images: ['org/app', 'ghcr.io/user/app'],
tags: [ tags: [
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d.\\d"`
] ]
} as Inputs, } as Inputs,
{ {
@@ -2015,7 +2044,41 @@ describe('raw', () => {
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071", "org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT" "org.opencontainers.image.licenses=MIT"
] ]
],
[
'raw10',
'event_push.env',
{
images: ['user/app'],
tags: [
`type=raw,foo`,
`type=raw,bar,enable=false`,
`type=raw,baz,enable=true`
],
flavor: [
`latest=false`
] ]
} as Inputs,
{
main: 'foo',
partial: ['baz'],
latest: false
} as Version,
[
'user/app:foo',
'user/app:baz',
],
[
"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=foo",
"org.opencontainers.image.created=2020-01-10T00:30:00.000Z",
"org.opencontainers.image.revision=90dd6032fac8bda1b6c4436a2e65de27961ed071",
"org.opencontainers.image.licenses=MIT"
]
],
])('given %p wth %p event', tagsLabelsTest); ])('given %p wth %p event', tagsLabelsTest);
}); });

View File

@@ -13,7 +13,7 @@ describe('transform', () => {
`type=raw,foo`, `type=raw,foo`,
`type=edge`, `type=edge`,
`type=semver,pattern={{version}}`, `type=semver,pattern={{version}}`,
`type=match,"pattern=\\d{1,3}.\\d{1,3}.\\d{1,3}"` `type=match,"pattern=\\d.\\d.\\d",group=0`
], ],
[ [
{ {
@@ -44,7 +44,7 @@ describe('transform', () => {
"enable": "true", "enable": "true",
"prefix": "", "prefix": "",
"suffix": "", "suffix": "",
"pattern": "\\d{1,3}.\\d{1,3}.\\d{1,3}", "pattern": "\\d.\\d.\\d",
"group": "0", "group": "0",
"value": "" "value": ""
} }
@@ -204,7 +204,7 @@ describe('parse', () => {
false false
], ],
[ [
`type=match,enable=true,"pattern=^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$",group=1`, `type=match,enable=true,"pattern=^v(\\d.\\d.\\d)$",group=1`,
{ {
type: Type.Match, type: Type.Match,
attrs: { attrs: {
@@ -212,7 +212,7 @@ describe('parse', () => {
"enable": "true", "enable": "true",
"prefix": "", "prefix": "",
"suffix": "", "suffix": "",
"pattern": "^v(\\d{1,3}.\\d{1,3}.\\d{1,3})$", "pattern": "^v(\\d.\\d.\\d)$",
"group": "1", "group": "1",
"value": "" "value": ""
} }

77
dist/index.js generated vendored
View File

@@ -99,12 +99,32 @@ exports.asyncForEach = (array, callback) => __awaiter(void 0, void 0, void 0, fu
/***/ }), /***/ }),
/***/ 3716: /***/ 3716:
/***/ ((__unused_webpack_module, exports) => { /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Transform = void 0; exports.Transform = void 0;
const core = __importStar(__webpack_require__(2186));
function Transform(inputs) { function Transform(inputs) {
const flavor = { const flavor = {
latest: 'auto', latest: 'auto',
@@ -137,6 +157,11 @@ function Transform(inputs) {
} }
} }
} }
core.startGroup(`Processing flavor input`);
core.info(`latest=${flavor.latest}`);
core.info(`prefix=${flavor.prefix}`);
core.info(`suffix=${flavor.suffix}`);
core.endGroup();
return flavor; return flavor;
} }
exports.Transform = Transform; exports.Transform = Transform;
@@ -361,6 +386,9 @@ class Meta {
latest: undefined latest: undefined
}; };
for (const tag of this.tags) { for (const tag of this.tags) {
if (tag.attrs['enable'] == 'false') {
continue;
}
switch (tag.type) { switch (tag.type) {
case tcl.Type.Schedule: { case tcl.Type.Schedule: {
version = this.procSchedule(version, tag); version = this.procSchedule(version, tag);
@@ -687,12 +715,32 @@ exports.Meta = Meta;
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Parse = exports.Transform = exports.DefaultPriorities = exports.RefEvent = exports.Type = void 0; exports.Parse = exports.Transform = exports.DefaultPriorities = exports.Tag = exports.RefEvent = exports.Type = void 0;
const sync_1 = __importDefault(__webpack_require__(8750)); const sync_1 = __importDefault(__webpack_require__(8750));
const core = __importStar(__webpack_require__(2186));
var Type; var Type;
(function (Type) { (function (Type) {
Type["Schedule"] = "schedule"; Type["Schedule"] = "schedule";
@@ -709,6 +757,19 @@ var RefEvent;
RefEvent["Tag"] = "tag"; RefEvent["Tag"] = "tag";
RefEvent["PR"] = "pr"; RefEvent["PR"] = "pr";
})(RefEvent = exports.RefEvent || (exports.RefEvent = {})); })(RefEvent = exports.RefEvent || (exports.RefEvent = {}));
class Tag {
constructor() {
this.attrs = {};
}
toString() {
const out = [`type=${this.type}`];
for (let attr in this.attrs) {
out.push(`${attr}=${this.attrs[attr]}`);
}
return out.join(',');
}
}
exports.Tag = Tag;
exports.DefaultPriorities = { exports.DefaultPriorities = {
[Type.Schedule]: '1000', [Type.Schedule]: '1000',
[Type.Semver]: '900', [Type.Semver]: '900',
@@ -732,7 +793,7 @@ function Transform(inputs) {
for (const input of inputs) { for (const input of inputs) {
tags.push(Parse(input)); tags.push(Parse(input));
} }
return tags.sort((tag1, tag2) => { const sorted = tags.sort((tag1, tag2) => {
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) { if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
return 1; return 1;
} }
@@ -741,6 +802,12 @@ function Transform(inputs) {
} }
return 0; return 0;
}); });
core.startGroup(`Processing tags input`);
for (const tag of sorted) {
core.info(tag.toString());
}
core.endGroup();
return sorted;
} }
exports.Transform = Transform; exports.Transform = Transform;
function Parse(s) { function Parse(s) {
@@ -748,9 +815,7 @@ function Parse(s) {
relaxColumnCount: true, relaxColumnCount: true,
skipLinesWithEmptyValues: true skipLinesWithEmptyValues: true
})[0]; })[0];
const tag = { const tag = new Tag();
attrs: {}
};
for (const field of fields) { for (const field of fields) {
const parts = field.toString().split('=', 2); const parts = field.toString().split('=', 2);
if (parts.length == 1) { if (parts.length == 1) {

View File

@@ -1,3 +1,5 @@
import * as core from '@actions/core';
export interface Flavor { export interface Flavor {
latest: string; latest: string;
prefix: string; prefix: string;
@@ -38,5 +40,11 @@ export function Transform(inputs: string[]): Flavor {
} }
} }
core.startGroup(`Processing flavor input`);
core.info(`latest=${flavor.latest}`);
core.info(`prefix=${flavor.prefix}`);
core.info(`suffix=${flavor.suffix}`);
core.endGroup();
return flavor; return flavor;
} }

View File

@@ -44,6 +44,9 @@ export class Meta {
}; };
for (const tag of this.tags) { for (const tag of this.tags) {
if (tag.attrs['enable'] == 'false') {
continue;
}
switch (tag.type) { switch (tag.type) {
case tcl.Type.Schedule: { case tcl.Type.Schedule: {
version = this.procSchedule(version, tag); version = this.procSchedule(version, tag);

View File

@@ -1,4 +1,5 @@
import csvparse from 'csv-parse/lib/sync'; import csvparse from 'csv-parse/lib/sync';
import * as core from '@actions/core';
export enum Type { export enum Type {
Schedule = 'schedule', Schedule = 'schedule',
@@ -16,9 +17,21 @@ export enum RefEvent {
PR = 'pr' PR = 'pr'
} }
export interface Tag { export class Tag {
type: Type; public type?: Type;
attrs: Record<string, string>; public attrs: Record<string, string>;
constructor() {
this.attrs = {};
}
public toString(): string {
const out: string[] = [`type=${this.type}`];
for (let attr in this.attrs) {
out.push(`${attr}=${this.attrs[attr]}`);
}
return out.join(',');
}
} }
export const DefaultPriorities: Record<Type, string> = { export const DefaultPriorities: Record<Type, string> = {
@@ -42,10 +55,11 @@ export function Transform(inputs: string[]): Tag[] {
`type=ref,event=${RefEvent.PR}` `type=ref,event=${RefEvent.PR}`
]; ];
} }
for (const input of inputs) { for (const input of inputs) {
tags.push(Parse(input)); tags.push(Parse(input));
} }
return tags.sort((tag1, tag2) => { const sorted = tags.sort((tag1, tag2) => {
if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) { if (Number(tag1.attrs['priority']) < Number(tag2.attrs['priority'])) {
return 1; return 1;
} }
@@ -54,6 +68,14 @@ export function Transform(inputs: string[]): Tag[] {
} }
return 0; return 0;
}); });
core.startGroup(`Processing tags input`);
for (const tag of sorted) {
core.info(tag.toString());
}
core.endGroup();
return sorted;
} }
export function Parse(s: string): Tag { export function Parse(s: string): Tag {
@@ -62,10 +84,7 @@ export function Parse(s: string): Tag {
skipLinesWithEmptyValues: true skipLinesWithEmptyValues: true
})[0]; })[0];
const tag = { const tag = new Tag();
attrs: {}
} as Tag;
for (const field of fields) { for (const field of fields) {
const parts = field.toString().split('=', 2); const parts = field.toString().split('=', 2);
if (parts.length == 1) { if (parts.length == 1) {

View File

@@ -3818,9 +3818,9 @@ xmlchars@^2.2.0:
integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==
y18n@^4.0.0: y18n@^4.0.0:
version "4.0.0" version "4.0.1"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.1.tgz#8db2b83c31c5d75099bb890b23f3094891e247d4"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== integrity sha512-wNcy4NvjMYL8gogWWYAO7ZFWFfHcbdbE57tZO8e4cbpj8tfUcwrwqSl3ad8HxpYWCdXcJUCeKKZS62Av1affwQ==
yallist@^4.0.0: yallist@^4.0.0:
version "4.0.0" version "4.0.0"