@tahminator/pipeline 1.0.51 → 1.0.52-beta.3f43a4ea
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/README.md +5 -0
- package/dist/gh/client.d.ts +2 -0
- package/dist/gh/client.js +4 -0
- package/dist/gh/tag/index.d.ts +7 -1
- package/dist/gh/tag/index.js +31 -21
- package/dist/internal/upload-npm/beta/index.d.ts +1 -0
- package/dist/internal/upload-npm/beta/index.js +85 -0
- package/dist/npm/client.d.ts +1 -1
- package/dist/npm/client.js +3 -2
- package/dist/pulumi/strategy/workspace.js +4 -1
- package/dist/utils/client.d.ts +2 -0
- package/dist/utils/client.js +2 -0
- package/dist/utils/semver.d.ts +4 -0
- package/dist/utils/semver.js +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,6 +156,11 @@ await npm.publish();
|
|
|
156
156
|
|
|
157
157
|
// dry run
|
|
158
158
|
await npm.publish(true);
|
|
159
|
+
|
|
160
|
+
// publish to the beta dist-tag instead of latest
|
|
161
|
+
// just like before, you should use `Utils.updateAllPackageJsonsWithVersion`
|
|
162
|
+
// with `Utils.SemVar.validate(betaTag)` to set a valid version
|
|
163
|
+
await npm.publish(false, true);
|
|
159
164
|
```
|
|
160
165
|
|
|
161
166
|
### `SonarScannerClient`
|
package/dist/gh/client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { GitHubTagManager } from "./tag";
|
|
|
4
4
|
export declare class GitHubClient {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly isExplicitToken;
|
|
7
|
+
static readonly BASE_VERSION = "1.0.0";
|
|
7
8
|
private readonly tagManager;
|
|
8
9
|
private readonly outputManager;
|
|
9
10
|
private readonly prManager;
|
|
@@ -35,6 +36,7 @@ export declare class GitHubClient {
|
|
|
35
36
|
*/
|
|
36
37
|
static createWithPatCiToken(pat: string): Promise<GitHubClient>;
|
|
37
38
|
createTag(...args: Parameters<GitHubTagManager["createTag"]>): Promise<void>;
|
|
39
|
+
getLatestTag(...args: Parameters<GitHubTagManager["getLatestTag"]>): Promise<string | null>;
|
|
38
40
|
outputToGithubOutput(...args: Parameters<GitHubOutputManager["outputToGithubOutput"]>): Promise<void>;
|
|
39
41
|
updateK8sTagWithPR(...args: Parameters<GitHubPRManager["updateK8sTagWithPR"]>): Promise<void>;
|
|
40
42
|
sendPrMessage(...args: Parameters<GitHubPRManager["sendPrMessage"]>): Promise<void>;
|
package/dist/gh/client.js
CHANGED
|
@@ -6,6 +6,7 @@ import { GitHubTagManager } from "./tag";
|
|
|
6
6
|
export class GitHubClient {
|
|
7
7
|
client;
|
|
8
8
|
isExplicitToken;
|
|
9
|
+
static BASE_VERSION = GitHubTagManager.BASE_VERSION;
|
|
9
10
|
tagManager;
|
|
10
11
|
outputManager;
|
|
11
12
|
prManager;
|
|
@@ -56,6 +57,9 @@ export class GitHubClient {
|
|
|
56
57
|
createTag(...args) {
|
|
57
58
|
return this.tagManager.createTag(...args);
|
|
58
59
|
}
|
|
60
|
+
getLatestTag(...args) {
|
|
61
|
+
return this.tagManager.getLatestTag(...args);
|
|
62
|
+
}
|
|
59
63
|
outputToGithubOutput(...args) {
|
|
60
64
|
return this.outputManager.outputToGithubOutput(...args);
|
|
61
65
|
}
|
package/dist/gh/tag/index.d.ts
CHANGED
|
@@ -4,9 +4,15 @@ import type { OwnerString, RepoString } from "../../types";
|
|
|
4
4
|
export declare class GitHubTagManager {
|
|
5
5
|
private readonly client;
|
|
6
6
|
private readonly isExplicitToken;
|
|
7
|
-
|
|
7
|
+
static readonly BASE_VERSION = "1.0.0";
|
|
8
8
|
constructor(client: Octokit, isExplicitToken: boolean);
|
|
9
9
|
private checkToken;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the latest stable semver tag in the repository.
|
|
12
|
+
*/
|
|
13
|
+
getLatestTag({ repositoryOverride, }?: {
|
|
14
|
+
repositoryOverride?: [OwnerString, RepoString];
|
|
15
|
+
}): Promise<string | null>;
|
|
10
16
|
/**
|
|
11
17
|
* Utilizes the GitHub API to create a new tag version in the given repository.
|
|
12
18
|
*
|
package/dist/gh/tag/index.js
CHANGED
|
@@ -14,6 +14,23 @@ export class GitHubTagManager {
|
|
|
14
14
|
throw new Error("You must pass in an explicit GitHub token for this operation. You may either use a PAT or a GitHub App Token");
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns the latest stable semver tag in the repository.
|
|
19
|
+
*/
|
|
20
|
+
async getLatestTag({ repositoryOverride, } = {}) {
|
|
21
|
+
const [owner, repo] = this.parseRepository(repositoryOverride);
|
|
22
|
+
const { data: tags } = await this.client.rest.repos.listTags({
|
|
23
|
+
owner,
|
|
24
|
+
repo,
|
|
25
|
+
});
|
|
26
|
+
return (tags
|
|
27
|
+
.map((t) => t.name)
|
|
28
|
+
.filter((tag) => {
|
|
29
|
+
const parsed = semver.parse(tag);
|
|
30
|
+
return parsed && parsed.prerelease.length === 0;
|
|
31
|
+
})
|
|
32
|
+
.sort(semver.rcompare)[0] ?? null);
|
|
33
|
+
}
|
|
17
34
|
/**
|
|
18
35
|
* Utilizes the GitHub API to create a new tag version in the given repository.
|
|
19
36
|
*
|
|
@@ -23,19 +40,10 @@ export class GitHubTagManager {
|
|
|
23
40
|
*/
|
|
24
41
|
async createTag({ repositoryOverride, releaseType, onPreTagCreate, }) {
|
|
25
42
|
this.checkToken();
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})();
|
|
30
|
-
const [owner, repo] = this.parseRepository(repositoryOverride, repositoryEnv)();
|
|
31
|
-
const { data: tags } = await this.client.rest.repos.listTags({
|
|
32
|
-
owner,
|
|
33
|
-
repo,
|
|
43
|
+
const [owner, repo] = this.parseRepository(repositoryOverride);
|
|
44
|
+
const lastTag = await this.getLatestTag({
|
|
45
|
+
repositoryOverride: [owner, repo],
|
|
34
46
|
});
|
|
35
|
-
const lastTag = tags
|
|
36
|
-
.map((t) => t.name)
|
|
37
|
-
.filter((v) => semver.valid(v))
|
|
38
|
-
.sort(semver.rcompare)[0];
|
|
39
47
|
const nextTag = lastTag ?
|
|
40
48
|
semver.inc(lastTag, releaseType ?? "patch")
|
|
41
49
|
: GitHubTagManager.BASE_VERSION;
|
|
@@ -80,16 +88,18 @@ export class GitHubTagManager {
|
|
|
80
88
|
sha: commit.sha,
|
|
81
89
|
});
|
|
82
90
|
}
|
|
83
|
-
parseRepository(repositoryOverride
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
parseRepository(repositoryOverride) {
|
|
92
|
+
if (repositoryOverride) {
|
|
93
|
+
return [repositoryOverride[0], repositoryOverride[1]];
|
|
94
|
+
}
|
|
95
|
+
const repositoryEnv = (() => {
|
|
96
|
+
const v = process.env.GITHUB_REPOSITORY;
|
|
97
|
+
return v;
|
|
98
|
+
})();
|
|
99
|
+
if (!repositoryEnv) {
|
|
91
100
|
throw new Error("GITHUB_REPOSITORY not found in environment and no explicit github repository override defined");
|
|
92
|
-
}
|
|
101
|
+
}
|
|
102
|
+
return repositoryEnv.split("/");
|
|
93
103
|
}
|
|
94
104
|
async createBlob({ owner, repo, baseSha, changedFiles, }) {
|
|
95
105
|
if (!changedFiles.length) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import yargs from "yargs";
|
|
2
|
+
import { hideBin } from "yargs/helpers";
|
|
3
|
+
import { EnvClient, EnvClientStrategy } from "../../../env";
|
|
4
|
+
import { GitHubClient } from "../../../gh";
|
|
5
|
+
import { NPMClient } from "../../../npm";
|
|
6
|
+
import { Utils } from "../../../utils";
|
|
7
|
+
const { sha, prId } = await yargs(hideBin(process.argv))
|
|
8
|
+
.option("sha", {
|
|
9
|
+
type: "string",
|
|
10
|
+
demandOption: true,
|
|
11
|
+
})
|
|
12
|
+
.option("prId", {
|
|
13
|
+
type: "number",
|
|
14
|
+
demandOption: true,
|
|
15
|
+
})
|
|
16
|
+
.strict()
|
|
17
|
+
.parse();
|
|
18
|
+
async function main() {
|
|
19
|
+
const envClient = EnvClient.create(EnvClientStrategy.GIT_CRYPT);
|
|
20
|
+
const { githubAppAppId, githubAppInstallationId, githubAppPrivateKeyB64 } = parseCiEnv(await envClient.readFromEnv(".env.ci"));
|
|
21
|
+
const ghClient = await GitHubClient.createWithGithubAppToken({
|
|
22
|
+
appId: githubAppAppId,
|
|
23
|
+
installationId: githubAppInstallationId,
|
|
24
|
+
privateKey: await Utils.decodeBase64EncodedString(githubAppPrivateKeyB64),
|
|
25
|
+
});
|
|
26
|
+
const npmClient = await NPMClient.create();
|
|
27
|
+
const shortSha = await getShortSha(sha);
|
|
28
|
+
const lastTag = (await ghClient.getLatestTag()) ?? GitHubClient.BASE_VERSION;
|
|
29
|
+
const betaVersion = `${lastTag}-beta.${shortSha}`;
|
|
30
|
+
if (!Utils.SemVer.validate(betaVersion)) {
|
|
31
|
+
throw new Error(`Generated invalid beta version: ${betaVersion}`);
|
|
32
|
+
}
|
|
33
|
+
await Utils.updateAllPackageJsonsWithVersion(betaVersion);
|
|
34
|
+
await npmClient.publish(false, true);
|
|
35
|
+
console.log(`Uploaded ${betaVersion} to NPM.`);
|
|
36
|
+
await ghClient.sendPrMessage({
|
|
37
|
+
prId,
|
|
38
|
+
owner: "tahminator",
|
|
39
|
+
repository: "pipeline",
|
|
40
|
+
message: `
|
|
41
|
+
## Test Version Uploaded
|
|
42
|
+
|
|
43
|
+
Uploaded ${betaVersion} to NPM. View version on NPM registry [here](https://www.npmjs.com/package/@tahminator/pipeline/v/${betaVersion}).
|
|
44
|
+
`,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function getShortSha(sha) {
|
|
48
|
+
const shortSha = sha.slice(0, 8).toString().trim();
|
|
49
|
+
if (shortSha.length !== 8) {
|
|
50
|
+
throw new Error("Could not parse git SHA");
|
|
51
|
+
}
|
|
52
|
+
return shortSha;
|
|
53
|
+
}
|
|
54
|
+
function parseCiEnv(ciEnv) {
|
|
55
|
+
const githubAppAppId = (() => {
|
|
56
|
+
const v = ciEnv["GITHUB_APP_APP_ID"];
|
|
57
|
+
if (!v) {
|
|
58
|
+
throw new Error("Missing GITHUB_APP_APP_ID from .env.ci");
|
|
59
|
+
}
|
|
60
|
+
return v;
|
|
61
|
+
})();
|
|
62
|
+
const githubAppInstallationId = (() => {
|
|
63
|
+
const v = ciEnv["GITHUB_APP_INSTALLATION_ID"];
|
|
64
|
+
if (!v) {
|
|
65
|
+
throw new Error("Missing GITHUB_APP_INSTALLATION_ID from .env.ci");
|
|
66
|
+
}
|
|
67
|
+
return v;
|
|
68
|
+
})();
|
|
69
|
+
const githubAppPrivateKeyB64 = (() => {
|
|
70
|
+
const v = ciEnv["GITHUB_APP_PRIVATE_KEY_B64"];
|
|
71
|
+
if (!v) {
|
|
72
|
+
throw new Error("Missing GITHUB_APP_PRIVATE_KEY_B64 from .env.ci");
|
|
73
|
+
}
|
|
74
|
+
return v;
|
|
75
|
+
})();
|
|
76
|
+
return { githubAppAppId, githubAppInstallationId, githubAppPrivateKeyB64 };
|
|
77
|
+
}
|
|
78
|
+
main()
|
|
79
|
+
.then(() => {
|
|
80
|
+
process.exit(0);
|
|
81
|
+
})
|
|
82
|
+
.catch((e) => {
|
|
83
|
+
console.error(e);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
package/dist/npm/client.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class NPMClient {
|
|
|
18
18
|
* is filled out with the name of the package and the version you would like to
|
|
19
19
|
* deploy.
|
|
20
20
|
*/
|
|
21
|
-
publish(dryRun?: boolean): Promise<void>;
|
|
21
|
+
publish(dryRun?: boolean, publishBetaTag?: boolean): Promise<void>;
|
|
22
22
|
[Symbol.asyncDispose](): Promise<void>;
|
|
23
23
|
cleanup(): Promise<void>;
|
|
24
24
|
}
|
package/dist/npm/client.js
CHANGED
|
@@ -23,15 +23,16 @@ export class NPMClient {
|
|
|
23
23
|
* is filled out with the name of the package and the version you would like to
|
|
24
24
|
* deploy.
|
|
25
25
|
*/
|
|
26
|
-
async publish(dryRun) {
|
|
26
|
+
async publish(dryRun, publishBetaTag) {
|
|
27
27
|
const dryRunFlag = dryRun ? ["--dry-run"] : [];
|
|
28
|
+
const tagFlag = publishBetaTag ? ["--tag", "beta"] : [];
|
|
28
29
|
if (Utils.Log.isDebug) {
|
|
29
30
|
console.log(await $ `ls .`.text());
|
|
30
31
|
console.log(await $ `ls ./dist/`.text());
|
|
31
32
|
console.log(await $ `pwd`.text());
|
|
32
33
|
console.log(await $ `cat ./package.json`.text());
|
|
33
34
|
}
|
|
34
|
-
await $ `npm publish --access public --provenance ${dryRunFlag} ./`;
|
|
35
|
+
await $ `npm publish --access public --provenance ${tagFlag} ${dryRunFlag} ./`;
|
|
35
36
|
console.log("Package has been successfully published");
|
|
36
37
|
}
|
|
37
38
|
async [Symbol.asyncDispose]() {
|
|
@@ -31,9 +31,12 @@ export class LocalWorkspacePulumiClientStrategy {
|
|
|
31
31
|
refresh: false,
|
|
32
32
|
diff,
|
|
33
33
|
});
|
|
34
|
+
console.log("old stdout", previewResult.stdout);
|
|
35
|
+
const stdout = this.htmlToAnsiConverter.toHtml(previewResult.stdout);
|
|
36
|
+
console.log("new stdout", stdout);
|
|
34
37
|
return {
|
|
35
38
|
...previewResult,
|
|
36
|
-
stdout
|
|
39
|
+
stdout,
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
42
|
async refresh() {
|
package/dist/utils/client.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { decodeBase64EncodedString } from "./b64";
|
|
|
2
2
|
import { isCmdAvailable } from "./cmd";
|
|
3
3
|
import { Colors } from "./colors";
|
|
4
4
|
import { Log } from "./log";
|
|
5
|
+
import { SemVer } from "./semver";
|
|
5
6
|
import { generateShortId } from "./short";
|
|
6
7
|
export declare class Utils {
|
|
7
8
|
static Colors: typeof Colors;
|
|
8
9
|
static Log: typeof Log;
|
|
10
|
+
static SemVer: typeof SemVer;
|
|
9
11
|
static generateShortId(...args: Parameters<typeof generateShortId>): string;
|
|
10
12
|
static updateAllPackageJsonsWithVersion(version: string): Promise<void>;
|
|
11
13
|
static isCmdAvailable(...args: Parameters<typeof isCmdAvailable>): Promise<boolean>;
|
package/dist/utils/client.js
CHANGED
|
@@ -3,11 +3,13 @@ import { decodeBase64EncodedString } from "./b64";
|
|
|
3
3
|
import { isCmdAvailable } from "./cmd";
|
|
4
4
|
import { Colors } from "./colors";
|
|
5
5
|
import { Log } from "./log";
|
|
6
|
+
import { SemVer } from "./semver";
|
|
6
7
|
import { generateShortId } from "./short";
|
|
7
8
|
export class Utils {
|
|
8
9
|
// hoist
|
|
9
10
|
static Colors = Colors;
|
|
10
11
|
static Log = Log;
|
|
12
|
+
static SemVer = SemVer;
|
|
11
13
|
static generateShortId(...args) {
|
|
12
14
|
return generateShortId(...args);
|
|
13
15
|
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"author": "Tahmid Ahmed",
|
|
5
5
|
"description": "A collection of Bun shell scripts that can be re-used in various CICD pipelines.",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.52-beta.3f43a4ea",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "git+https://github.com/tahminator/pipeline.git"
|
|
9
9
|
},
|