@ticatec/omniflow-github 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/README_CN.md +93 -0
- package/dist/artifacts/GitHubContainerPublisher.d.ts +16 -0
- package/dist/artifacts/GitHubContainerPublisher.d.ts.map +1 -0
- package/dist/artifacts/GitHubContainerPublisher.js +47 -0
- package/dist/artifacts/GitHubContainerPublisher.js.map +1 -0
- package/dist/artifacts/GitHubMavenPublisher.d.ts +25 -0
- package/dist/artifacts/GitHubMavenPublisher.d.ts.map +1 -0
- package/dist/artifacts/GitHubMavenPublisher.js +186 -0
- package/dist/artifacts/GitHubMavenPublisher.js.map +1 -0
- package/dist/artifacts/GitHubNpmPublisher.d.ts +21 -0
- package/dist/artifacts/GitHubNpmPublisher.d.ts.map +1 -0
- package/dist/artifacts/GitHubNpmPublisher.js +49 -0
- package/dist/artifacts/GitHubNpmPublisher.js.map +1 -0
- package/dist/artifacts/GitHubReleasePublisher.d.ts +31 -0
- package/dist/artifacts/GitHubReleasePublisher.d.ts.map +1 -0
- package/dist/artifacts/GitHubReleasePublisher.js +192 -0
- package/dist/artifacts/GitHubReleasePublisher.js.map +1 -0
- package/dist/client/GitHubClient.d.ts +76 -0
- package/dist/client/GitHubClient.d.ts.map +1 -0
- package/dist/client/GitHubClient.js +170 -0
- package/dist/client/GitHubClient.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
- package/src/artifacts/GitHubContainerPublisher.ts +54 -0
- package/src/artifacts/GitHubMavenPublisher.ts +238 -0
- package/src/artifacts/GitHubNpmPublisher.ts +66 -0
- package/src/artifacts/GitHubReleasePublisher.ts +238 -0
- package/src/client/GitHubClient.ts +242 -0
- package/src/index.ts +54 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ticatec
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @ticatec/omniflow-github
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
|
|
6
|
+
[中文文档](./README_CN.md)
|
|
7
|
+
|
|
8
|
+
All-in-one GitHub artifact provider for OmniFlow. Provides full-stack artifact publishing (GitHub Container Registry ghcr.io, GitHub Packages NPM, GitHub Packages Maven, and GitHub Releases Generic Assets) under a single unified credential model.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- **Container Registry (GHCR)**: Push Docker/OCI container images directly to `ghcr.io` (`GitHubContainerPublisher`).
|
|
15
|
+
- **NPM Package Registry**: Publish scoped npm packages to `npm.pkg.github.com` (`GitHubNpmPublisher`).
|
|
16
|
+
- **Maven Package Registry**: Publish Java JAR and POM packages to `maven.pkg.github.com` via direct HTTP PUT (`GitHubMavenPublisher`).
|
|
17
|
+
- **Releases / Generic Package Registry**: Publish frontend distribution archives, binaries, or release assets to GitHub Releases (`GitHubReleasePublisher`). Also implements `download()`, which `deploy.web` uses to fetch an archive by name and version.
|
|
18
|
+
- **Unified Client & Credentials**: Same Personal Access Token (PAT with `repo` and `write:packages` scopes) or GitHub Actions `GITHUB_TOKEN` powers all package registries.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## How to Register
|
|
23
|
+
|
|
24
|
+
### 1. One-Click Registration (Recommended)
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { defaultArtifactPublisherRegistry } from '@ticatec/omniflow-artifact'
|
|
28
|
+
import { registerGitHub } from '@ticatec/omniflow-github'
|
|
29
|
+
|
|
30
|
+
// Register all GitHub drivers (Container + NPM + Maven + Releases)
|
|
31
|
+
registerGitHub({
|
|
32
|
+
artifactRegistry: defaultArtifactPublisherRegistry
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Granular Registration
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { registerArtifactPublisher } from '@ticatec/omniflow-artifact'
|
|
40
|
+
import {
|
|
41
|
+
GitHubContainerPublisher,
|
|
42
|
+
GitHubNpmPublisher,
|
|
43
|
+
GitHubMavenPublisher,
|
|
44
|
+
GitHubReleasePublisher
|
|
45
|
+
} from '@ticatec/omniflow-github'
|
|
46
|
+
|
|
47
|
+
registerArtifactPublisher(new GitHubContainerPublisher())
|
|
48
|
+
registerArtifactPublisher(new GitHubNpmPublisher())
|
|
49
|
+
registerArtifactPublisher(new GitHubMavenPublisher())
|
|
50
|
+
registerArtifactPublisher(new GitHubReleasePublisher())
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Configuration Example (`omniflow.yaml`)
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
omniflow:
|
|
59
|
+
registries:
|
|
60
|
+
# 1. GitHub Container Registry (GHCR)
|
|
61
|
+
docker:
|
|
62
|
+
ghcr:
|
|
63
|
+
server: ghcr.io
|
|
64
|
+
namespace: my-org
|
|
65
|
+
username: github-user
|
|
66
|
+
password: ${GITHUB_TOKEN}
|
|
67
|
+
|
|
68
|
+
# 2. GitHub NPM Registry
|
|
69
|
+
npm:
|
|
70
|
+
github:
|
|
71
|
+
server: https://npm.pkg.github.com
|
|
72
|
+
namespace: my-org
|
|
73
|
+
token: ${GITHUB_TOKEN}
|
|
74
|
+
|
|
75
|
+
# 3. GitHub Maven Registry
|
|
76
|
+
maven:
|
|
77
|
+
github:
|
|
78
|
+
server: https://maven.pkg.github.com/my-org/my-repo
|
|
79
|
+
token: ${GITHUB_TOKEN}
|
|
80
|
+
|
|
81
|
+
# 4. GitHub Releases Generic Packages
|
|
82
|
+
generic:
|
|
83
|
+
github:
|
|
84
|
+
server: https://github.com
|
|
85
|
+
namespace: my-org/my-repo
|
|
86
|
+
token: ${GITHUB_TOKEN}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT License.
|
package/README_CN.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @ticatec/omniflow-github
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://nodejs.org/)
|
|
5
|
+
|
|
6
|
+
[English Documentation](./README.md)
|
|
7
|
+
|
|
8
|
+
OmniFlow 的 GitHub 一体化制品库驱动插件。在统一凭证(Personal Access Token / `GITHUB_TOKEN`)体系下,提供全栈制品发布能力(GHCR 容器镜像、GitHub Packages NPM、GitHub Packages Maven、GitHub Releases 发行资产通用归档)。
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 特性
|
|
13
|
+
|
|
14
|
+
- **容器镜像仓库 (GHCR)**:将 Docker/OCI 镜像推送到 GitHub Container Registry `ghcr.io` (`GitHubContainerPublisher`)。
|
|
15
|
+
- **NPM 制品库**:自动生成 `.npmrc` 并发布 Scoped npm 包到 `npm.pkg.github.com` (`GitHubNpmPublisher`)。
|
|
16
|
+
- **Maven 制品库**:直接通过 HTTP PUT 将 Java JAR 和 POM 包发布到 `maven.pkg.github.com` (`GitHubMavenPublisher`)。
|
|
17
|
+
- **Releases 发行资产发布**:自动根据版本 tag 创建 Release 或将通用归档文件 (`.tar.gz`/`.zip`) 上传至 GitHub Releases (`GitHubReleasePublisher`);同时实现 `download()`,`deploy.web` 用它按名称和版本取回归档。
|
|
18
|
+
- **统一凭证体系**:同一套 Personal Access Token (PAT,具备 `repo` 和 `write:packages` 权限) 或 GitHub Actions 内置的 `GITHUB_TOKEN` 即可覆盖全品类制品库。
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 如何注册
|
|
23
|
+
|
|
24
|
+
### 1. 一键全量注册(推荐)
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { defaultArtifactPublisherRegistry } from '@ticatec/omniflow-artifact'
|
|
28
|
+
import { registerGitHub } from '@ticatec/omniflow-github'
|
|
29
|
+
|
|
30
|
+
// 注册所有 GitHub 驱动(容器镜像 + NPM + Maven + Releases 通用归档)
|
|
31
|
+
registerGitHub({
|
|
32
|
+
artifactRegistry: defaultArtifactPublisherRegistry
|
|
33
|
+
})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. 按需单项注册
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
import { registerArtifactPublisher } from '@ticatec/omniflow-artifact'
|
|
40
|
+
import {
|
|
41
|
+
GitHubContainerPublisher,
|
|
42
|
+
GitHubNpmPublisher,
|
|
43
|
+
GitHubMavenPublisher,
|
|
44
|
+
GitHubReleasePublisher
|
|
45
|
+
} from '@ticatec/omniflow-github'
|
|
46
|
+
|
|
47
|
+
registerArtifactPublisher(new GitHubContainerPublisher())
|
|
48
|
+
registerArtifactPublisher(new GitHubNpmPublisher())
|
|
49
|
+
registerArtifactPublisher(new GitHubMavenPublisher())
|
|
50
|
+
registerArtifactPublisher(new GitHubReleasePublisher())
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 配置示例 (`omniflow.yaml`)
|
|
56
|
+
|
|
57
|
+
```yaml
|
|
58
|
+
omniflow:
|
|
59
|
+
registries:
|
|
60
|
+
# 1. GitHub 容器镜像仓库 (GHCR)
|
|
61
|
+
docker:
|
|
62
|
+
ghcr:
|
|
63
|
+
server: ghcr.io
|
|
64
|
+
namespace: my-org
|
|
65
|
+
username: github-user
|
|
66
|
+
password: ${GITHUB_TOKEN}
|
|
67
|
+
|
|
68
|
+
# 2. GitHub NPM 制品库
|
|
69
|
+
npm:
|
|
70
|
+
github:
|
|
71
|
+
server: https://npm.pkg.github.com
|
|
72
|
+
namespace: my-org
|
|
73
|
+
token: ${GITHUB_TOKEN}
|
|
74
|
+
|
|
75
|
+
# 3. GitHub Maven 制品库
|
|
76
|
+
maven:
|
|
77
|
+
github:
|
|
78
|
+
server: https://maven.pkg.github.com/my-org/my-repo
|
|
79
|
+
token: ${GITHUB_TOKEN}
|
|
80
|
+
|
|
81
|
+
# 4. GitHub Releases 通用包
|
|
82
|
+
generic:
|
|
83
|
+
github:
|
|
84
|
+
server: https://github.com
|
|
85
|
+
namespace: my-org/my-repo
|
|
86
|
+
token: ${GITHUB_TOKEN}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 许可证
|
|
92
|
+
|
|
93
|
+
MIT License.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseDockerPublisher } from '@ticatec/omniflow-artifact';
|
|
2
|
+
import type { RegistryConfig } from '@ticatec/omniflow-artifact';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub Container Registry (GHCR) Publisher.
|
|
5
|
+
*
|
|
6
|
+
* Supports ghcr.io and GitHub Enterprise Container Registries.
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitHubContainerPublisher extends BaseDockerPublisher {
|
|
9
|
+
readonly id = "github-container";
|
|
10
|
+
readonly name = "GitHub Container Registry";
|
|
11
|
+
readonly platform = "github";
|
|
12
|
+
readonly priority = 20;
|
|
13
|
+
detect(registry: RegistryConfig): boolean;
|
|
14
|
+
buildRepositoryUrl(registry: RegistryConfig, imageName: string): string;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=GitHubContainerPublisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubContainerPublisher.d.ts","sourceRoot":"","sources":["../../src/artifacts/GitHubContainerPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,mBAAmB;IAC/D,QAAQ,CAAC,EAAE,sBAAqB;IAChC,QAAQ,CAAC,IAAI,+BAA8B;IAC3C,QAAQ,CAAC,QAAQ,YAAW;IAC5B,SAAkB,QAAQ,MAAK;IAEtB,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO;IAoBzC,kBAAkB,CAAC,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;CAkBjF"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BaseDockerPublisher } from '@ticatec/omniflow-artifact';
|
|
2
|
+
import { GitHubClient } from '../client/GitHubClient.js';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub Container Registry (GHCR) Publisher.
|
|
5
|
+
*
|
|
6
|
+
* Supports ghcr.io and GitHub Enterprise Container Registries.
|
|
7
|
+
*/
|
|
8
|
+
export class GitHubContainerPublisher extends BaseDockerPublisher {
|
|
9
|
+
id = 'github-container';
|
|
10
|
+
name = 'GitHub Container Registry';
|
|
11
|
+
platform = 'github';
|
|
12
|
+
priority = 20;
|
|
13
|
+
detect(registry) {
|
|
14
|
+
if (registry.type !== 'docker' && registry.type !== 'container') {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
const regName = (registry.name || '').toLowerCase();
|
|
18
|
+
if (regName === 'github' || regName === 'ghcr' || regName.startsWith('github-') || regName.startsWith('ghcr-')) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const server = (registry.server || '').toLowerCase();
|
|
22
|
+
try {
|
|
23
|
+
const parsed = new URL(server.includes('://') ? server : `https://${server}`);
|
|
24
|
+
const host = parsed.hostname.toLowerCase();
|
|
25
|
+
return host === 'ghcr.io' || host.endsWith('.ghcr.io') || GitHubClient.isGitHubHost(host);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
buildRepositoryUrl(registry, imageName) {
|
|
32
|
+
let host = this.normalizeServerHost(registry.server);
|
|
33
|
+
if (!host || host === 'github' || host === 'ghcr') {
|
|
34
|
+
host = 'ghcr.io';
|
|
35
|
+
}
|
|
36
|
+
const cleanImage = imageName.replace(/^\/+/, '');
|
|
37
|
+
const ns = (registry.namespace || '').replace(/\/+$/, '');
|
|
38
|
+
if (ns) {
|
|
39
|
+
if (cleanImage.startsWith(`${ns}/`)) {
|
|
40
|
+
return `${host}/${cleanImage}`;
|
|
41
|
+
}
|
|
42
|
+
return `${host}/${ns}/${cleanImage}`;
|
|
43
|
+
}
|
|
44
|
+
return `${host}/${cleanImage}`;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=GitHubContainerPublisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubContainerPublisher.js","sourceRoot":"","sources":["../../src/artifacts/GitHubContainerPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD;;;;GAIG;AACH,MAAM,OAAO,wBAAyB,SAAQ,mBAAmB;IACtD,EAAE,GAAG,kBAAkB,CAAA;IACvB,IAAI,GAAG,2BAA2B,CAAA;IAClC,QAAQ,GAAG,QAAQ,CAAA;IACV,QAAQ,GAAG,EAAE,CAAA;IAEtB,MAAM,CAAC,QAAwB;QACtC,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;YAChE,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;QACnD,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC/G,OAAO,IAAI,CAAA;QACb,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;QACpD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,MAAM,EAAE,CAAC,CAAA;YAC7E,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAA;YAC1C,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAC3F,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAEQ,kBAAkB,CAAC,QAAwB,EAAE,SAAiB;QACrE,IAAI,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;QACpD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YAClD,IAAI,GAAG,SAAS,CAAA;QAClB,CAAC;QAED,MAAM,UAAU,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAChD,MAAM,EAAE,GAAG,CAAC,QAAQ,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QAEzD,IAAI,EAAE,EAAE,CAAC;YACP,IAAI,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;gBACpC,OAAO,GAAG,IAAI,IAAI,UAAU,EAAE,CAAA;YAChC,CAAC;YACD,OAAO,GAAG,IAAI,IAAI,EAAE,IAAI,UAAU,EAAE,CAAA;QACtC,CAAC;QAED,OAAO,GAAG,IAAI,IAAI,UAAU,EAAE,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { BasePublisher } from '@ticatec/omniflow-artifact';
|
|
2
|
+
import type { ArtifactPayload, PublishOptions, RegistryConfig } from '@ticatec/omniflow-artifact';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub Maven Package Registry Publisher.
|
|
5
|
+
*
|
|
6
|
+
* Endpoint format: PUT https://maven.pkg.github.com/<owner>/<repo>/{groupId}/{artifactId}/{version}/{filename}
|
|
7
|
+
*/
|
|
8
|
+
export declare class GitHubMavenPublisher extends BasePublisher {
|
|
9
|
+
readonly id = "github-maven";
|
|
10
|
+
readonly name = "GitHub Packages (Maven)";
|
|
11
|
+
readonly platform = "github";
|
|
12
|
+
readonly artifactType = "maven";
|
|
13
|
+
readonly priority = 20;
|
|
14
|
+
detect(registry: RegistryConfig): boolean;
|
|
15
|
+
buildTargetRef(artifact: ArtifactPayload, _registry: RegistryConfig): string;
|
|
16
|
+
protected resolveBaseRepoUrl(registry: RegistryConfig): string;
|
|
17
|
+
exists(artifact: ArtifactPayload, registry: RegistryConfig, options?: PublishOptions): Promise<boolean>;
|
|
18
|
+
login(registry: RegistryConfig, _options?: PublishOptions): Promise<void>;
|
|
19
|
+
protected doPublish(artifact: ArtifactPayload, registry: RegistryConfig, options?: PublishOptions): Promise<{
|
|
20
|
+
ref: string;
|
|
21
|
+
digest?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=GitHubMavenPublisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubMavenPublisher.d.ts","sourceRoot":"","sources":["../../src/artifacts/GitHubMavenPublisher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAuE,MAAM,4BAA4B,CAAA;AAC/H,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGjG;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,aAAa;IACrD,QAAQ,CAAC,EAAE,kBAAiB;IAC5B,QAAQ,CAAC,IAAI,6BAA4B;IACzC,QAAQ,CAAC,QAAQ,YAAW;IAC5B,QAAQ,CAAC,YAAY,WAAU;IAC/B,SAAkB,QAAQ,MAAK;IAEtB,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO;IAmBzC,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,GAAG,MAAM;IAOrF,SAAS,CAAC,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM;IAiB/C,MAAM,CACnB,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,OAAO,CAAC;IA2Db,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;cAO/D,SAAS,CACvB,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QACT,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACnC,CAAC;CAiGH"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import crypto from 'crypto';
|
|
4
|
+
import { BasePublisher, resolveMavenArtifactFilenames, mavenPomPathFor, isMavenArtifactFile } from '@ticatec/omniflow-artifact';
|
|
5
|
+
import { GitHubClient } from '../client/GitHubClient.js';
|
|
6
|
+
/**
|
|
7
|
+
* GitHub Maven Package Registry Publisher.
|
|
8
|
+
*
|
|
9
|
+
* Endpoint format: PUT https://maven.pkg.github.com/<owner>/<repo>/{groupId}/{artifactId}/{version}/{filename}
|
|
10
|
+
*/
|
|
11
|
+
export class GitHubMavenPublisher extends BasePublisher {
|
|
12
|
+
id = 'github-maven';
|
|
13
|
+
name = 'GitHub Packages (Maven)';
|
|
14
|
+
platform = 'github';
|
|
15
|
+
artifactType = 'maven';
|
|
16
|
+
priority = 20;
|
|
17
|
+
detect(registry) {
|
|
18
|
+
if (registry.type !== 'maven' && registry.type !== 'jar') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
const regName = (registry.name || '').toLowerCase();
|
|
22
|
+
if (regName === 'github' || regName.startsWith('github-')) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const server = (registry.server || '').toLowerCase();
|
|
26
|
+
try {
|
|
27
|
+
const parsed = new URL(server.includes('://') ? server : `https://${server}`);
|
|
28
|
+
return parsed.hostname === 'maven.pkg.github.com' || GitHubClient.isGitHubHost(parsed.hostname);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
buildTargetRef(artifact, _registry) {
|
|
35
|
+
const version = artifact.tags && artifact.tags.length > 0 ? artifact.tags[0] : '1.0.0';
|
|
36
|
+
const artifactId = artifact.metadata?.artifactId || artifact.name;
|
|
37
|
+
const groupId = artifact.metadata?.groupId?.trim();
|
|
38
|
+
return groupId ? `${groupId}:${artifactId}:${version}` : `${artifactId}:${version}`;
|
|
39
|
+
}
|
|
40
|
+
resolveBaseRepoUrl(registry) {
|
|
41
|
+
let repoPath = registry.namespace || '';
|
|
42
|
+
let server = registry.server || 'https://maven.pkg.github.com';
|
|
43
|
+
if (!/^https?:\/\//i.test(server)) {
|
|
44
|
+
server = `https://${server}`;
|
|
45
|
+
}
|
|
46
|
+
if (server.includes('maven.pkg.github.com') && server.split('/').filter(Boolean).length >= 4) {
|
|
47
|
+
return server.replace(/\/+$/, '');
|
|
48
|
+
}
|
|
49
|
+
if (!repoPath) {
|
|
50
|
+
throw new Error(`GitHub Maven packages require repository namespace (<owner>/<repo>) to be configured.`);
|
|
51
|
+
}
|
|
52
|
+
return `https://maven.pkg.github.com/${repoPath.replace(/^\/+/, '').replace(/\/+$/, '')}`;
|
|
53
|
+
}
|
|
54
|
+
async exists(artifact, registry, options) {
|
|
55
|
+
const creds = this.resolveCredentials(registry);
|
|
56
|
+
const token = creds.token || creds.password;
|
|
57
|
+
let baseRepoUrl;
|
|
58
|
+
try {
|
|
59
|
+
baseRepoUrl = this.resolveBaseRepoUrl(registry);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const client = new GitHubClient({
|
|
65
|
+
token,
|
|
66
|
+
timeoutMs: options?.timeoutMs
|
|
67
|
+
});
|
|
68
|
+
let jarPath = artifact.source;
|
|
69
|
+
if (jarPath) {
|
|
70
|
+
const stat = await fs.stat(jarPath).catch(() => null);
|
|
71
|
+
if (stat?.isDirectory()) {
|
|
72
|
+
const files = await fs.readdir(jarPath).catch(() => []);
|
|
73
|
+
const jarFile = files.find(f => isMavenArtifactFile(f));
|
|
74
|
+
if (jarFile) {
|
|
75
|
+
jarPath = path.join(jarPath, jarFile);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const { groupId, artifactId, version, groupPath, jarFilename } = resolveMavenArtifactFilenames(artifact, jarPath, undefined, 'GitHub');
|
|
80
|
+
const probeUrl = `${baseRepoUrl}/${groupPath}/${artifactId}/${version}/${jarFilename}`;
|
|
81
|
+
try {
|
|
82
|
+
const res = await client.request(probeUrl, { method: 'HEAD' });
|
|
83
|
+
if (res.ok || res.status === 200 || res.status === 204) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (res.status === 404) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
const errText = await client.extractErrorMessage(res);
|
|
90
|
+
throw new Error(`Failed to check artifact existence in GitHub Maven registry (${res.status}): ${errText}`);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
if (err?.message?.includes('Failed to check artifact existence in GitHub')) {
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
throw new Error(`Failed to check artifact existence in GitHub Maven registry: ${client.maskSecrets(err?.message || String(err))}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async login(registry, _options) {
|
|
100
|
+
const creds = this.resolveCredentials(registry);
|
|
101
|
+
if (!creds.token && !creds.password) {
|
|
102
|
+
this.log(` ℹ No auth token configured for GitHub Maven repository ${registry.server}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async doPublish(artifact, registry, options) {
|
|
106
|
+
const creds = this.resolveCredentials(registry);
|
|
107
|
+
const token = creds.token || creds.password;
|
|
108
|
+
const repoBaseUrl = this.resolveBaseRepoUrl(registry);
|
|
109
|
+
const client = new GitHubClient({
|
|
110
|
+
token,
|
|
111
|
+
timeoutMs: options?.timeoutMs
|
|
112
|
+
});
|
|
113
|
+
// Locate jar file
|
|
114
|
+
let jarPath = artifact.source;
|
|
115
|
+
const stat = await fs.stat(jarPath).catch(() => null);
|
|
116
|
+
if (stat?.isDirectory()) {
|
|
117
|
+
const files = await fs.readdir(jarPath);
|
|
118
|
+
const jarFile = files.find(f => isMavenArtifactFile(f));
|
|
119
|
+
if (!jarFile) {
|
|
120
|
+
throw new Error(`No jar/war artifact found in directory: ${jarPath}`);
|
|
121
|
+
}
|
|
122
|
+
jarPath = path.join(jarPath, jarFile);
|
|
123
|
+
}
|
|
124
|
+
const { groupId, artifactId, version, groupPath, jarFilename, pomFilename } = resolveMavenArtifactFilenames(artifact, jarPath, undefined, 'GitHub');
|
|
125
|
+
const jarBuffer = await fs.readFile(jarPath);
|
|
126
|
+
const digest = `sha256:${crypto.createHash('sha256').update(jarBuffer).digest('hex')}`;
|
|
127
|
+
const targetUrl = `${repoBaseUrl}/${groupPath}/${artifactId}/${version}/${jarFilename}`;
|
|
128
|
+
this.log(` 📤 Uploading Maven JAR to GitHub: ${targetUrl}`);
|
|
129
|
+
if (options?.dryRun) {
|
|
130
|
+
this.log(` [dryRun] Would PUT ${jarFilename} (${jarBuffer.length} bytes) to ${targetUrl}`);
|
|
131
|
+
return {
|
|
132
|
+
ref: `${groupId}:${artifactId}:${version}`,
|
|
133
|
+
digest,
|
|
134
|
+
metadata: { targetUrl, size: jarBuffer.length }
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// The POM goes up first, deliberately.
|
|
138
|
+
//
|
|
139
|
+
// The existence probe checks for the jar/war, so uploading that last is what
|
|
140
|
+
// makes the probe mean "this artifact is complete". With the artifact first, a
|
|
141
|
+
// run that uploaded it and then failed on the POM would leave a coordinate that
|
|
142
|
+
// probes as present: the retry skips it as already published, and the POM never
|
|
143
|
+
// arrives — a jar in the repository forever, with no dependency information.
|
|
144
|
+
// Upload pom if exists
|
|
145
|
+
const pomPath = mavenPomPathFor(jarPath);
|
|
146
|
+
const pomStat = await fs.stat(pomPath).catch(() => null);
|
|
147
|
+
if (pomStat?.isFile()) {
|
|
148
|
+
const pomBuffer = await fs.readFile(pomPath);
|
|
149
|
+
const targetPomFilename = pomFilename || `${artifactId}-${version}.pom`;
|
|
150
|
+
const pomTargetUrl = `${repoBaseUrl}/${groupPath}/${artifactId}/${version}/${targetPomFilename}`;
|
|
151
|
+
this.log(` 📤 Uploading Maven POM to GitHub: ${pomTargetUrl}`);
|
|
152
|
+
const pomRes = await client.request(pomTargetUrl, {
|
|
153
|
+
method: 'PUT',
|
|
154
|
+
headers: { 'Content-Type': 'application/xml' },
|
|
155
|
+
body: pomBuffer
|
|
156
|
+
});
|
|
157
|
+
if (!pomRes.ok && pomRes.status !== 201 && pomRes.status !== 200) {
|
|
158
|
+
const pomErr = await client.extractErrorMessage(pomRes);
|
|
159
|
+
throw new Error(`Failed to upload Maven POM to GitHub (${pomRes.status}): ${pomErr}`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const res = await client.request(targetUrl, {
|
|
163
|
+
method: 'PUT',
|
|
164
|
+
headers: {
|
|
165
|
+
'Content-Type': 'application/java-archive'
|
|
166
|
+
},
|
|
167
|
+
body: jarBuffer
|
|
168
|
+
});
|
|
169
|
+
if (!res.ok && res.status !== 201 && res.status !== 200) {
|
|
170
|
+
const errText = await client.extractErrorMessage(res);
|
|
171
|
+
throw new Error(`Failed to upload Maven JAR to GitHub (${res.status}): ${errText}`);
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
ref: `${groupId}:${artifactId}:${version}`,
|
|
175
|
+
digest,
|
|
176
|
+
metadata: {
|
|
177
|
+
groupId,
|
|
178
|
+
artifactId,
|
|
179
|
+
version,
|
|
180
|
+
targetUrl,
|
|
181
|
+
size: jarBuffer.length
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=GitHubMavenPublisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubMavenPublisher.js","sourceRoot":"","sources":["../../src/artifacts/GitHubMavenPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAA;AACnC,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAE/H,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAC5C,EAAE,GAAG,cAAc,CAAA;IACnB,IAAI,GAAG,yBAAyB,CAAA;IAChC,QAAQ,GAAG,QAAQ,CAAA;IACnB,YAAY,GAAG,OAAO,CAAA;IACb,QAAQ,GAAG,EAAE,CAAA;IAEtB,MAAM,CAAC,QAAwB;QACtC,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO,IAAI,QAAQ,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACzD,OAAO,KAAK,CAAA;QACd,CAAC;QAED,MAAM,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;QACnD,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC1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3C;YACD,IAAI,EAAE,SAAS;SAChB,CAAC,CAAA;QAEF,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACxD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAA;YACrD,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,CAAC,MAAM,MAAM,OAAO,EAAE,CAAC,CAAA;QACrF,CAAC;QAED,OAAO;YACL,GAAG,EAAE,GAAG,OAAO,IAAI,UAAU,IAAI,OAAO,EAAE;YAC1C,MAAM;YACN,QAAQ,EAAE;gBACR,OAAO;gBACP,UAAU;gBACV,OAAO;gBACP,SAAS;gBACT,IAAI,EAAE,SAAS,CAAC,MAAM;aACvB;SACF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { BaseNpmPublisher } from '@ticatec/omniflow-artifact';
|
|
2
|
+
import type { ArtifactPayload, PublishOptions, RegistryConfig } from '@ticatec/omniflow-artifact';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub NPM Package Registry Publisher.
|
|
5
|
+
*
|
|
6
|
+
* Endpoint format: https://npm.pkg.github.com/
|
|
7
|
+
* GitHub requires npm packages to be scoped, e.g. @owner/package-name.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GitHubNpmPublisher extends BaseNpmPublisher {
|
|
10
|
+
readonly id = "github-npm";
|
|
11
|
+
readonly name = "GitHub Packages (NPM)";
|
|
12
|
+
readonly platform = "github";
|
|
13
|
+
readonly priority = 20;
|
|
14
|
+
detect(registry: RegistryConfig): boolean;
|
|
15
|
+
normalizeRegistryUrl(server: string, _namespace?: string): string;
|
|
16
|
+
protected doPublish(artifact: ArtifactPayload, registry: RegistryConfig, options?: PublishOptions): Promise<{
|
|
17
|
+
ref: string;
|
|
18
|
+
metadata?: Record<string, unknown>;
|
|
19
|
+
}>;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=GitHubNpmPublisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubNpmPublisher.d.ts","sourceRoot":"","sources":["../../src/artifacts/GitHubNpmPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGjG;;;;;GAKG;AACH,qBAAa,kBAAmB,SAAQ,gBAAgB;IACtD,QAAQ,CAAC,EAAE,gBAAe;IAC1B,QAAQ,CAAC,IAAI,2BAA0B;IACvC,QAAQ,CAAC,QAAQ,YAAW;IAC5B,SAAkB,QAAQ,MAAK;IAEtB,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO;IAoBzC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM;cAajD,SAAS,CAChC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,cAAc,EACxB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QACT,GAAG,EAAE,MAAM,CAAA;QACX,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KACnC,CAAC;CASH"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BaseNpmPublisher } from '@ticatec/omniflow-artifact';
|
|
2
|
+
import { GitHubClient } from '../client/GitHubClient.js';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub NPM Package Registry Publisher.
|
|
5
|
+
*
|
|
6
|
+
* Endpoint format: https://npm.pkg.github.com/
|
|
7
|
+
* GitHub requires npm packages to be scoped, e.g. @owner/package-name.
|
|
8
|
+
*/
|
|
9
|
+
export class GitHubNpmPublisher extends BaseNpmPublisher {
|
|
10
|
+
id = 'github-npm';
|
|
11
|
+
name = 'GitHub Packages (NPM)';
|
|
12
|
+
platform = 'github';
|
|
13
|
+
priority = 20;
|
|
14
|
+
detect(registry) {
|
|
15
|
+
if (registry.type !== 'npm') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const regName = (registry.name || '').toLowerCase();
|
|
19
|
+
if (regName === 'github' || regName.startsWith('github-')) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const server = (registry.server || '').toLowerCase();
|
|
23
|
+
try {
|
|
24
|
+
const parsed = new URL(server.includes('://') ? server : `https://${server}`);
|
|
25
|
+
const host = parsed.hostname.toLowerCase();
|
|
26
|
+
return host === 'npm.pkg.github.com' || GitHubClient.isGitHubHost(host);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
normalizeRegistryUrl(server, _namespace) {
|
|
33
|
+
let url = (server || '').trim();
|
|
34
|
+
if (!url || url === 'github') {
|
|
35
|
+
return 'https://npm.pkg.github.com/';
|
|
36
|
+
}
|
|
37
|
+
if (!/^https?:\/\//i.test(url)) {
|
|
38
|
+
url = `https://${url}`;
|
|
39
|
+
}
|
|
40
|
+
return url.endsWith('/') ? url : `${url}/`;
|
|
41
|
+
}
|
|
42
|
+
async doPublish(artifact, registry, options) {
|
|
43
|
+
if (!artifact.name.startsWith('@')) {
|
|
44
|
+
this.log(` ⚠ Notice: Package "${artifact.name}" is not scoped. GitHub Packages requires scoped package names (e.g. @owner/repo).`);
|
|
45
|
+
}
|
|
46
|
+
return super.doPublish(artifact, registry, options);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=GitHubNpmPublisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubNpmPublisher.js","sourceRoot":"","sources":["../../src/artifacts/GitHubNpmPublisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4B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,EAAE,CAAC;YAC7B,OAAO,6BAA6B,CAAA;QACtC,CAAC;QAED,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/B,GAAG,GAAG,WAAW,GAAG,EAAE,CAAA;QACxB,CAAC;QAED,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAA;IAC5C,CAAC;IAEkB,KAAK,CAAC,SAAS,CAChC,QAAyB,EACzB,QAAwB,EACxB,OAAwB;QAKxB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,GAAG,CACN,wBAAwB,QAAQ,CAAC,IAAI,oFAAoF,CAC1H,CAAA;QACH,CAAC;QAED,OAAO,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BasePublisher } from '@ticatec/omniflow-artifact';
|
|
2
|
+
import type { ArtifactPayload, DownloadOptions, DownloadResult, PublishOptions, RegistryConfig } from '@ticatec/omniflow-artifact';
|
|
3
|
+
/**
|
|
4
|
+
* GitHub Releases (Generic Artifact / Asset) Publisher.
|
|
5
|
+
*
|
|
6
|
+
* Publishes arbitrary binary artifacts, distribution tarballs (.tar.gz),
|
|
7
|
+
* or zip files to GitHub Releases under the specified version tag.
|
|
8
|
+
*/
|
|
9
|
+
export declare class GitHubReleasePublisher extends BasePublisher {
|
|
10
|
+
readonly id = "github-release";
|
|
11
|
+
readonly name = "GitHub Releases";
|
|
12
|
+
readonly platform = "github";
|
|
13
|
+
readonly artifactType = "generic";
|
|
14
|
+
readonly priority = 20;
|
|
15
|
+
detect(registry: RegistryConfig): boolean;
|
|
16
|
+
buildTargetRef(artifact: ArtifactPayload, registry: RegistryConfig): string;
|
|
17
|
+
protected resolveOwnerRepo(registry: RegistryConfig): {
|
|
18
|
+
owner: string;
|
|
19
|
+
repo: string;
|
|
20
|
+
};
|
|
21
|
+
exists(artifact: ArtifactPayload, registry: RegistryConfig, options?: PublishOptions): Promise<boolean>;
|
|
22
|
+
download(artifact: ArtifactPayload, registry: RegistryConfig, dest: string, options?: DownloadOptions): Promise<DownloadResult>;
|
|
23
|
+
login(registry: RegistryConfig, _options?: PublishOptions): Promise<void>;
|
|
24
|
+
protected doPublish(artifact: ArtifactPayload, registry: RegistryConfig, options?: PublishOptions): Promise<{
|
|
25
|
+
ref: string;
|
|
26
|
+
digest?: string;
|
|
27
|
+
metadata?: Record<string, unknown>;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
30
|
+
export { GitHubReleasePublisher as GitHubGenericPublisher };
|
|
31
|
+
//# sourceMappingURL=GitHubReleasePublisher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHubReleasePublisher.d.ts","sourceRoot":"","sources":["../../src/artifacts/GitHubReleasePublisher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGlI;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,aAAa;IACvD,QAAQ,CAAC,EAAE,oBAAmB;IAC9B,QAAQ,CAAC,IAAI,qBAAoB;IACjC,QAAQ,CAAC,QAAQ,YAAW;IAC5B,QAAQ,CAAC,YAAY,aAAY;IACjC,SAAkB,QAAQ,MAAK;IAEtB,MAAM,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO;IAmBzC,cAAc,CAAC,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,cAAc,GAAG,MAAM;IAapF,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,cAAc,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