Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(keygen): Add host property to support self-hosted Keygen instances #8711

Merged
merged 8 commits into from
Dec 6, 2024
8 changes: 8 additions & 0 deletions .changeset/kind-poems-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"app-builder-lib": minor
"builder-util-runtime": minor
"electron-publish": minor
"electron-updater": minor
---

Add `host` property to support self-hosted Keygen instances
5 changes: 5 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1578,6 +1578,11 @@
"default": "stable",
"description": "The channel."
},
"host": {
"default": "api.keygen.sh",
"description": "Keygen host for self-hosted instances",
"type": "string"
},
"platform": {
"description": "The target Platform. Is set programmatically explicitly during publishing.",
"type": [
Expand Down
6 changes: 6 additions & 0 deletions packages/builder-util-runtime/src/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,12 @@ export interface KeygenOptions extends PublishConfiguration {
*/
readonly provider: "keygen"

/**
* Keygen host for self-hosted instances
* @default "api.keygen.sh"
*/
readonly host?: string

/**
* Keygen account's UUID
*/
Expand Down
6 changes: 5 additions & 1 deletion packages/electron-publish/src/keygenPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ export interface KeygenArtifact {

export class KeygenPublisher extends HttpPublisher {
readonly providerName = "keygen"
readonly hostname = "api.keygen.sh"
readonly defaultHostname = "api.keygen.sh"

private readonly info: KeygenOptions
private readonly auth: string
private readonly version: string
private readonly basePath: string

get hostname() {
return this.info.host || this.defaultHostname
}

constructor(context: PublishContext, info: KeygenOptions, version: string) {
super(context)

Expand Down
4 changes: 3 additions & 1 deletion packages/electron-updater/src/providers/KeygenProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getChannelFilename, newBaseUrl, newUrlFromBase } from "../util"
import { parseUpdateInfo, Provider, ProviderRuntimeOptions, resolveFiles } from "./Provider"

export class KeygenProvider extends Provider<UpdateInfo> {
private readonly defaultHostname = "api.keygen.sh"
private readonly baseUrl: URL

constructor(
Expand All @@ -16,7 +17,8 @@ export class KeygenProvider extends Provider<UpdateInfo> {
...runtimeOptions,
isUseMultipleRangeRequest: false,
})
this.baseUrl = newBaseUrl(`https://api.keygen.sh/v1/accounts/${this.configuration.account}/artifacts?product=${this.configuration.product}`)
const host = this.configuration.host || this.defaultHostname
this.baseUrl = newBaseUrl(`https://${host}/v1/accounts/${this.configuration.account}/artifacts?product=${this.configuration.product}`)
}

private get channel(): string {
Expand Down
Loading