mirror of
https://github.com/docker/metadata-action.git
synced 2025-06-23 19:27:58 +02:00
fix: handle raw statement for semver pre-release
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
19
dist/index.js
generated
vendored
19
dist/index.js
generated
vendored
@ -526,7 +526,12 @@ class Meta {
|
||||
includePrerelease: true
|
||||
});
|
||||
if (semver.prerelease(vraw)) {
|
||||
vraw = this.setValue(handlebars.compile('{{version}}')(sver), tag);
|
||||
if (Meta.isRawStatement(tag.attrs['pattern'])) {
|
||||
vraw = this.setValue(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||
}
|
||||
else {
|
||||
vraw = this.setValue(handlebars.compile('{{version}}')(sver), tag);
|
||||
}
|
||||
}
|
||||
else {
|
||||
vraw = this.setValue(handlebars.compile(tag.attrs['pattern'])(sver), tag);
|
||||
@ -671,6 +676,18 @@ class Meta {
|
||||
}
|
||||
return version;
|
||||
}
|
||||
static isRawStatement(pattern) {
|
||||
try {
|
||||
const hp = handlebars.parseWithoutProcessing(pattern);
|
||||
if (hp.body.length == 1 && hp.body[0].type == 'MustacheStatement') {
|
||||
return hp.body[0]['path']['parts'].length == 1 && hp.body[0]['path']['parts'][0] == 'raw';
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
setValue(val, tag) {
|
||||
if (tag.attrs.hasOwnProperty('prefix')) {
|
||||
val = `${this.setGlobalExp(tag.attrs['prefix'])}${val}`;
|
||||
|
Reference in New Issue
Block a user