Skip to content

Commit

Permalink
ref: Better logging for github target
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed May 16, 2024
1 parent 532b8d1 commit 3e175cf
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/targets/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,22 @@ export class GitHubTarget extends BaseTarget {
repo: this.githubConfig.repo,
});

const latestReleaseTag = latestRelease?.tag_name;
this.logger.info(
latestReleaseTag
? `Previous release: ${latestReleaseTag}`
: 'No previous release found'
);

const isLatest = isPreview
? false
: isLatestRelease(latestRelease, version);
: isLatestRelease(latestReleaseTag, version);

this.logger.info(
isLatest
? 'Tagging release as latest, because new version is greater than old version'
: 'Not tagging release as latest, because new version is not greater than old version'
);

const { data } = await this.github.repos.createRelease({
draft: true,
Expand Down Expand Up @@ -423,11 +436,8 @@ export class GitHubTarget extends BaseTarget {
}
}

export function isLatestRelease(
githubRelease: { tag_name: string } | undefined,
version: string
) {
const latestVersion = githubRelease && parseVersion(githubRelease.tag_name);
export function isLatestRelease(previousVersion: string, version: string) {
const latestVersion = parseVersion(previousVersion);
const versionToPublish = parseVersion(version);
return latestVersion && versionToPublish
? versionGreaterOrEqualThan(versionToPublish, latestVersion)
Expand Down

0 comments on commit 3e175cf

Please sign in to comment.