Skip to content

Commit 44b2899

Browse files
authored
feat(github): Add tagNamePrefix option to github publisher options (deprecates vPrefixedTagName) (#9216)
1 parent d031eea commit 44b2899

File tree

6 files changed

+34
-3
lines changed

6 files changed

+34
-3
lines changed

.changeset/chatty-points-shop.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"app-builder-lib": patch
3+
"builder-util-runtime": patch
4+
"electron-publish": patch
5+
---
6+
7+
feat(github): Add `tagNamePrefix` option and deprecate `vPrefixedTagName`

packages/app-builder-lib/scheme.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,10 @@
16031603
"default": true,
16041604
"description": "Whether to use `v`-prefixed tag name.",
16051605
"type": "boolean"
1606+
},
1607+
"tagNamePrefix": {
1608+
"description": "Sets the prefix of the tag name that comes before the semver number. Overrides vPrefixedTagName.",
1609+
"type": "string"
16061610
}
16071611
},
16081612
"required": [

packages/app-builder-lib/src/publish/PublishManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
GenericServerOptions,
66
getS3LikeProviderBaseUrl,
77
GithubOptions,
8+
githubTagPrefix,
89
githubUrl,
910
KeygenOptions,
1011
Nullish,
@@ -385,7 +386,7 @@ export function computeDownloadUrl(publishConfiguration: PublishConfiguration, f
385386
let baseUrl
386387
if (publishConfiguration.provider === "github") {
387388
const gh = publishConfiguration as GithubOptions
388-
baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/${gh.vPrefixedTagName === false ? "" : "v"}${packager.appInfo.version}`
389+
baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/${githubTagPrefix(gh)}${packager.appInfo.version}`
389390
} else {
390391
baseUrl = getS3LikeProviderBaseUrl(publishConfiguration)
391392
}

packages/builder-util-runtime/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export {
2626
getS3LikeProviderBaseUrl,
2727
GithubOptions,
2828
githubUrl,
29+
githubTagPrefix,
2930
GitlabOptions,
3031
KeygenOptions,
3132
PublishConfiguration,

packages/builder-util-runtime/src/publishOptions.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,17 @@ export interface GithubOptions extends PublishConfiguration {
9898
/**
9999
* Whether to use `v`-prefixed tag name.
100100
* @default true
101+
* @deprecated please use #tagNamePrefix instead.
101102
*/
102103
readonly vPrefixedTagName?: boolean
103104

105+
/**
106+
* If defined, sets the prefix of the tag name that comes before the semver number.
107+
* e.g. "v" in "v1.2.3" or "test" of "test1.2.3".
108+
* Overrides `vPrefixedTagName`
109+
*/
110+
readonly tagNamePrefix?: string
111+
104112
/**
105113
* The host (including the port if need).
106114
* @default github.com
@@ -143,6 +151,16 @@ export function githubUrl(options: GithubOptions, defaultHost = "github.com") {
143151
return `${options.protocol || "https"}://${options.host || defaultHost}`
144152
}
145153

154+
export function githubTagPrefix(options: GithubOptions) {
155+
if (options.tagNamePrefix) {
156+
return options.tagNamePrefix
157+
}
158+
if (options.vPrefixedTagName ?? true) {
159+
return 'v'
160+
}
161+
return ''
162+
}
163+
146164
/**
147165
* [GitLab](https://docs.gitlab.com/ee/user/project/releases/) options.
148166
*

packages/electron-publish/src/gitHubPublisher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Arch, Fields, httpExecutor, InvalidConfigurationError, isEmptyOrSpaces, isEnvTrue, isTokenCharValid, log } from "builder-util"
2-
import { configureRequestOptions, GithubOptions, HttpError, parseJson } from "builder-util-runtime"
2+
import { configureRequestOptions, GithubOptions, HttpError, parseJson, githubTagPrefix } from "builder-util-runtime"
33
import { ClientRequest } from "http"
44
import { Lazy } from "lazy-val"
55
import * as mime from "mime"
@@ -65,7 +65,7 @@ export class GitHubPublisher extends HttpPublisher {
6565
throw new InvalidConfigurationError(`Version must not start with "v": ${version}`)
6666
}
6767

68-
this.tag = info.vPrefixedTagName === false ? version : `v${version}`
68+
this.tag = githubTagPrefix(info) + version
6969

7070
if (isEnvTrue(process.env.EP_DRAFT)) {
7171
this.releaseType = "draft"

0 commit comments

Comments
 (0)