Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/silent-oranges-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"app-builder-lib": patch
"builder-util-runtime": patch
"electron-publish": patch
"electron-updater": patch
---

Support gitlab publisher
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,11 @@ jobs:
echo $TEST_RUNNER_IMAGE_TAG
pnpm test-linux
env:
TEST_FILES: nsisUpdaterTest,PublishManagerTest,differentialUpdateTest
TEST_FILES: nsisUpdaterTest,PublishManagerTest,differentialUpdateTest,GitlabPublisherTest,GitlabPublisher.integration.test
KEYGEN_TOKEN: ${{ secrets.KEYGEN_TOKEN }}
BITBUCKET_TOKEN: ${{ secrets.BITBUCKET_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
FORCE_COLOR: 1
TEST_RUNNER_IMAGE_TAG: electronuserland/builder:${{ env.TEST_IMAGE_NODE_MAJOR_VERSION }}-wine-mono

Expand Down
12 changes: 11 additions & 1 deletion packages/app-builder-lib/src/publish/PublishManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
GithubOptions,
githubTagPrefix,
githubUrl,
GitlabOptions,
KeygenOptions,
Nullish,
PublishConfiguration,
Expand All @@ -18,6 +19,7 @@ import {
BitbucketPublisher,
getCiTag,
GitHubPublisher,
GitlabPublisher,
KeygenPublisher,
PublishContext,
Publisher,
Expand Down Expand Up @@ -315,6 +317,9 @@ export async function createPublisher(
case "github":
return new GitHubPublisher(context, publishConfig as GithubOptions, version, options)

case "gitlab":
return new GitlabPublisher(context, publishConfig as GitlabOptions, version)

case "keygen":
return new KeygenPublisher(context, publishConfig as KeygenOptions, version)

Expand All @@ -336,6 +341,9 @@ async function requireProviderClass(provider: string, packager: Packager): Promi
case "github":
return GitHubPublisher

case "gitlab":
return GitlabPublisher

case "generic":
return null

Expand Down Expand Up @@ -442,6 +450,8 @@ async function resolvePublishConfigurations(
let serviceName: PublishProvider | null = null
if (!isEmptyOrSpaces(process.env.GH_TOKEN) || !isEmptyOrSpaces(process.env.GITHUB_TOKEN)) {
serviceName = "github"
} else if (!isEmptyOrSpaces(process.env.GITLAB_TOKEN)) {
serviceName = "gitlab"
} else if (!isEmptyOrSpaces(process.env.KEYGEN_TOKEN)) {
serviceName = "keygen"
} else if (!isEmptyOrSpaces(process.env.BITBUCKET_TOKEN)) {
Expand Down Expand Up @@ -499,7 +509,7 @@ async function getResolvedPublishConfig(
options: PublishConfiguration,
arch: Arch | null,
errorIfCannot: boolean
): Promise<PublishConfiguration | GithubOptions | BitbucketOptions | null> {
): Promise<PublishConfiguration | GithubOptions | BitbucketOptions | GitlabOptions | null> {
options = { ...options }
expandPublishConfig(options, platformPackager, packager, arch)

Expand Down
2 changes: 2 additions & 0 deletions packages/builder-util-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export {
S3Options,
SnapStoreOptions,
SpacesOptions,
GitlabReleaseInfo,
GitlabReleaseAsset,
} from "./publishOptions"
export { retry } from "./retry"
export { parseDn } from "./rfc2253Parser"
Expand Down
45 changes: 41 additions & 4 deletions packages/builder-util-runtime/src/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,26 +174,38 @@ export interface GitlabOptions extends PublishConfiguration {
readonly provider: "gitlab"

/**
* The GitLab project ID or namespace/project-name.
* The GitLab project ID or path (e.g., "12345678" or "namespace/project").
*/
readonly projectId: string | number
readonly projectId?: string | number | null

/**
* The host (including the port if needed).
* The GitLab host (including the port if need).
* @default gitlab.com
*/
readonly host?: string | null

/**
* The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files. Only for [setFeedURL](./auto-update.md#appupdatersetfeedurloptions).
* The access token to support auto-update from private GitLab repositories. Never specify it in the configuration files.
*/
readonly token?: string | null

/**
* Whether to use `v`-prefixed tag name.
* @default true
*/
readonly vPrefixedTagName?: boolean

/**
* The channel.
* @default latest
*/
readonly channel?: string | null

/**
* Upload target method. Can be "project_upload" for GitLab project uploads or "generic_package" for GitLab generic packages.
* @default "project_upload"
*/
readonly uploadTarget?: "project_upload" | "generic_package" | null
}

/**
Expand Down Expand Up @@ -447,6 +459,31 @@ export interface SpacesOptions extends BaseS3Options {
readonly region: string
}

export interface GitlabReleaseInfo {
name: string
tag_name: string
description: string
created_at: string
released_at: string
upcoming_release: boolean
assets: GitlabReleaseAsset
}

export interface GitlabReleaseAsset {
count: number
sources: Array<{
format: string
url: string
}>
links: Array<{
id: number
name: string
url: string
direct_asset_url: string
link_type: string
}>
}

export function getS3LikeProviderBaseUrl(configuration: PublishConfiguration) {
const provider = configuration.provider
if (provider === "s3") {
Expand Down
Loading
Loading