mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-21 16:00:59 -05:00
parent
86e7074aca
commit
b34393cfcd
2 changed files with 21 additions and 2 deletions
|
@ -63,8 +63,27 @@ export class GitHubContext {
|
|||
* Gets the tag associated with the context, if available.
|
||||
*/
|
||||
get tag(): string | undefined {
|
||||
const payload = this.payload;
|
||||
if (payload.release?.tag_name) {
|
||||
return payload.release.tag_name;
|
||||
}
|
||||
|
||||
const ref = this.ref;
|
||||
return ref?.startsWith(GITHUB_REF_TAG_PREFIX) && ref.substring(GITHUB_REF_TAG_PREFIX.length);
|
||||
if (ref?.startsWith(GITHUB_REF_TAG_PREFIX)) {
|
||||
return ref.substring(GITHUB_REF_TAG_PREFIX.length);
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the version associated with the context, if available.
|
||||
*/
|
||||
get version(): string | undefined {
|
||||
const tag = this.tag;
|
||||
|
||||
// Remove the `v` prefix, popularized by GitHub.
|
||||
return /v\d/.test(tag) ? tag.substring(1) : tag;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,7 +111,7 @@ async function fillInDefaultValues<T extends McPublishInput[P], P extends Platfo
|
|||
const unwrappedGameVersions = gameVersions ? GameVersionFilter.filter(gameVersions, options.gameVersionFilter).map(x => x.id) : wrappedGameVersions;
|
||||
|
||||
(options as UnionToIntersection<McPublishInput[PlatformType]>).id ||= metadata?.getProjectId(platform) || "";
|
||||
options.version ||= githubContext.payload.release?.tag_name || metadata?.version;
|
||||
options.version ||= githubContext.version || metadata?.version;
|
||||
options.versionType ||= VersionType.parseFromFileName(metadata?.version || primaryFile.name);
|
||||
options.name ??= githubContext.payload.release?.name || options.version;
|
||||
options.changelog ??= githubContext.payload.release?.body || "";
|
||||
|
|
Loading…
Reference in a new issue