@noldova/tools.pipelines.github 0.0.0-stage → 0.0.1
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 +68 -2
- package/api/index.d.ts +184 -0
- package/api/index.js +11 -0
- package/api/index.js.map +1 -0
- package/bin/pipelines.js +12 -0
- package/bin/pipelines.js.map +1 -0
- package/models/github-answer.js +41 -0
- package/models/github-answer.js.map +1 -0
- package/models/github-connection.js +18 -0
- package/models/github-connection.js.map +1 -0
- package/package.json +27 -4
- package/resources.js +67 -0
- package/resources.js.map +1 -0
- package/services/github-step-output.js +24 -0
- package/services/github-step-output.js.map +1 -0
- package/services/github-tags.js +79 -0
- package/services/github-tags.js.map +1 -0
- package/services/pipelines-program.js +25 -0
- package/services/pipelines-program.js.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Noldova
|
|
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
CHANGED
|
@@ -1,3 +1,69 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @noldova/tools.pipelines.github
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Runs the steps of `@noldova/tools.pipelines` on GitHub Actions.
|
|
4
|
+
This version holds `pipelines`, the command line a workflow calls, with the source, archive, publish, nightly and tag steps, and the tag step's access to GitHub's REST API.
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm install @noldova/tools.pipelines.github
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Use
|
|
13
|
+
|
|
14
|
+
### In a workflow
|
|
15
|
+
|
|
16
|
+
A job installs the package at an exact version, without install scripts, and calls `pipelines` with a step's name and values in the checkout:
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
- run: npm install --global --ignore-scripts @noldova/tools.pipelines.github@0.0.1
|
|
20
|
+
- run: pipelines source "$VERSION" "$COMMIT"
|
|
21
|
+
- id: nightly
|
|
22
|
+
run: |
|
|
23
|
+
version="$(pipelines nightly "$COMMIT" https://registry.npmjs.org/)"
|
|
24
|
+
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Step | Values |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `source` | `<version> <commit>` |
|
|
30
|
+
| `archive` | `<folder> <version> <commit> <scope>` |
|
|
31
|
+
| `publish` | `<folder> <version> <commit> <scope> <registry> <access>` |
|
|
32
|
+
| `nightly` | `<commit> <registry>` |
|
|
33
|
+
| `tag` | `<version> <commit>` |
|
|
34
|
+
|
|
35
|
+
`@noldova/tools.pipelines`'s README says what each step checks and does.
|
|
36
|
+
|
|
37
|
+
- A step that succeeds writes its message to standard output and exits with code `0`; an empty message, such as the nightly step's when nothing changed, writes nothing.
|
|
38
|
+
- A step that fails writes its message as one error annotation, which the run's summary shows, and exits with code `1`; so does a first value that names no step, with the usage line of every step.
|
|
39
|
+
- The annotation goes to standard error, which GitHub Actions reads workflow commands from as it does standard output, so a step whose output the workflow keeps, such as the nightly version above, still shows it.
|
|
40
|
+
- A fault, such as git failing to start, ends the run with its stack trace and exit code `1`.
|
|
41
|
+
|
|
42
|
+
### The tag step
|
|
43
|
+
|
|
44
|
+
`pipelines tag <version> <commit>` tags the released commit `v<version>` through GitHub's REST API, and never moves a tag.
|
|
45
|
+
It reads `GITHUB_API_URL` and `GITHUB_REPOSITORY`, which GitHub Actions sets, and `GITHUB_TOKEN`, which the workflow passes in; the token needs to write the repository's contents, and is never written anywhere:
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
- env:
|
|
49
|
+
GITHUB_TOKEN: ${{ github.token }}
|
|
50
|
+
run: pipelines tag "$VERSION" "$COMMIT"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The job needs `permissions: contents: write`.
|
|
54
|
+
The step fails, naming the variable, when one is missing or empty, and with the request, the status and GitHub's message for an answer it doesn't expect, such as a missing permission.
|
|
55
|
+
|
|
56
|
+
### From code
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { GitHubStepOutput, PipelinesProgram } from "@noldova/tools.pipelines.github";
|
|
60
|
+
|
|
61
|
+
const program = new PipelinesProgram(new GitHubStepOutput(process.stdout, process.stderr));
|
|
62
|
+
process.exitCode = await program.runAsync(["source", "0.0.4", "225059f4c1e6a3b2d8f7e9a0b1c2d3e4f5a6b7c8"]);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The declaration file `api/index.d.ts` documents every member with its contract and examples.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
MIT; see `LICENSE`.
|
package/api/index.d.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { IStepOutput, ITagHost, StepResult } from "@noldova/tools.pipelines";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Writes a step's messages as a GitHub Actions job reads them: a success to
|
|
13
|
+
* standard output as it is, and a failure as an error annotation, which the
|
|
14
|
+
* run's summary shows.
|
|
15
|
+
*/
|
|
16
|
+
export declare class GitHubStepOutput implements IStepOutput {
|
|
17
|
+
/**
|
|
18
|
+
* Creates the output over two streams.
|
|
19
|
+
*
|
|
20
|
+
* @param standardOutput Where a success goes, such as `process.stdout`.
|
|
21
|
+
* @param standardError Where a failure goes, such as `process.stderr`;
|
|
22
|
+
* GitHub Actions reads workflow commands from it as it does from standard
|
|
23
|
+
* output, so a workflow that keeps a step's standard output, such as the
|
|
24
|
+
* nightly version, still shows the failure.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { GitHubStepOutput } from "@noldova/tools.pipelines.github";
|
|
28
|
+
*
|
|
29
|
+
* const output = new GitHubStepOutput(process.stdout, process.stderr);
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
public constructor(standardOutput: NodeJS.WritableStream, standardError: NodeJS.WritableStream);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Writes the message of a step that succeeded, and a line feed, to standard
|
|
36
|
+
* output; an empty message writes nothing.
|
|
37
|
+
*
|
|
38
|
+
* @param message The step's message.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { GitHubStepOutput } from "@noldova/tools.pipelines.github";
|
|
42
|
+
*
|
|
43
|
+
* const output = new GitHubStepOutput(process.stdout, process.stderr);
|
|
44
|
+
* output.writeSuccess("0.0.5-nightly.20261102"); // writes "0.0.5-nightly.20261102\n"
|
|
45
|
+
* output.writeSuccess(""); // writes nothing
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
public writeSuccess(message: string): void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Writes the message of a step that failed to standard error as one
|
|
52
|
+
* `::error::` workflow command, with `%`, carriage returns and line feeds
|
|
53
|
+
* escaped as `%25`, `%0D` and `%0A`, so a message of several lines is one
|
|
54
|
+
* annotation.
|
|
55
|
+
*
|
|
56
|
+
* @param message What is wrong.
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { GitHubStepOutput } from "@noldova/tools.pipelines.github";
|
|
60
|
+
*
|
|
61
|
+
* const output = new GitHubStepOutput(process.stdout, process.stderr);
|
|
62
|
+
* output.writeFailure("archives has no noldova-tools.pipelines-0.0.4.tgz.\n100% of nothing");
|
|
63
|
+
* // writes "::error::archives has no noldova-tools.pipelines-0.0.4.tgz.%0A100%25 of nothing\n"
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
public writeFailure(message: string): void;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* GitHub's tags, through its REST API, as the tag step of
|
|
71
|
+
* `@noldova/tools.pipelines` reads and creates them.
|
|
72
|
+
*
|
|
73
|
+
* It reaches the API with three environment variables, which GitHub Actions
|
|
74
|
+
* sets in a job, but for the token, which the workflow passes in:
|
|
75
|
+
* `GITHUB_API_URL`, such as `https://api.github.com`; `GITHUB_REPOSITORY`,
|
|
76
|
+
* such as `noldova-com/tools`; and `GITHUB_TOKEN`, a token that may write
|
|
77
|
+
* the repository's contents, such as the job's own. It sends the token only
|
|
78
|
+
* to that API and never writes it anywhere.
|
|
79
|
+
*/
|
|
80
|
+
export declare class GitHubTags implements ITagHost {
|
|
81
|
+
/**
|
|
82
|
+
* Creates the tags over an environment, which it reads at each call.
|
|
83
|
+
*
|
|
84
|
+
* @param environment The environment variables, such as `process.env`.
|
|
85
|
+
* @param timeoutMilliseconds How long it waits for each answer of the API.
|
|
86
|
+
* Omitted, it waits a minute.
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* import { GitHubTags } from "@noldova/tools.pipelines.github";
|
|
90
|
+
*
|
|
91
|
+
* const tags = new GitHubTags(process.env);
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
public constructor(environment: Readonly<Record<string, string | undefined>>, timeoutMilliseconds?: number);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Reads the commit a tag points to, following an annotated tag to its
|
|
98
|
+
* commit.
|
|
99
|
+
*
|
|
100
|
+
* @param tag The tag's name, such as `v0.0.4`.
|
|
101
|
+
* @returns A promise of the commit's full id, `""` when the repository has
|
|
102
|
+
* no such tag, or a failed {@link StepResult}: when one of the three
|
|
103
|
+
* environment variables is missing or empty, naming it; when the tag points
|
|
104
|
+
* to something other than a commit, such as a tree; or when GitHub answers
|
|
105
|
+
* with another status, with the request, the status and GitHub's message,
|
|
106
|
+
* such as `GitHub answered GET repos/noldova-com/tools/git/ref/tags/v0.0.4
|
|
107
|
+
* with 403: Resource not accessible by integration`. It rejects with
|
|
108
|
+
* `JsonException`, from `@noldova/context.json`, for an answer that is not
|
|
109
|
+
* the JSON GitHub documents, with a `DOMException` named `TimeoutError`
|
|
110
|
+
* when GitHub doesn't answer within the timeout, and with the error `fetch`
|
|
111
|
+
* gives when GitHub can't be reached.
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* import { GitHubTags } from "@noldova/tools.pipelines.github";
|
|
115
|
+
*
|
|
116
|
+
* const commit = await new GitHubTags(process.env).readTagAsync("v0.0.4");
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
public readTagAsync(tag: string): Promise<string | StepResult>;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Creates a lightweight tag at a commit, unless the repository already has
|
|
123
|
+
* a tag of that name; it never moves a tag.
|
|
124
|
+
*
|
|
125
|
+
* @param tag The tag's name, such as `v0.0.4`.
|
|
126
|
+
* @param commit The commit's full id.
|
|
127
|
+
* @returns A promise of `true` when GitHub created the tag, or `false` when
|
|
128
|
+
* GitHub refuses it as unprocessable, status 422, and reading the tag then
|
|
129
|
+
* finds it, such as one another run made. Otherwise it is a failed
|
|
130
|
+
* {@link StepResult}, as {@link GitHubTags.readTagAsync} gives one: with the
|
|
131
|
+
* 422's message when reading finds no tag, and with the read's failure when
|
|
132
|
+
* the read fails. It rejects as {@link GitHubTags.readTagAsync} does.
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* import { GitHubTags } from "@noldova/tools.pipelines.github";
|
|
136
|
+
*
|
|
137
|
+
* const created = await new GitHubTags(process.env).createTagAsync("v0.0.4", "225059f4c1e6a3b2d8f7e9a0b1c2d3e4f5a6b7c8");
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
public createTagAsync(tag: string, commit: string): Promise<boolean | StepResult>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The `pipelines` command line a GitHub Actions workflow calls: it runs the
|
|
145
|
+
* source, archive, publish, nightly and tag steps of `@noldova/tools.pipelines`
|
|
146
|
+
* in the current directory, which is the clone the steps check and where a
|
|
147
|
+
* folder value is. The tag step reaches GitHub through {@link GitHubTags},
|
|
148
|
+
* with the process's environment.
|
|
149
|
+
*/
|
|
150
|
+
export declare class PipelinesProgram {
|
|
151
|
+
/**
|
|
152
|
+
* Creates the program.
|
|
153
|
+
*
|
|
154
|
+
* @param output Where each message goes, such as a {@link GitHubStepOutput}.
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { GitHubStepOutput, PipelinesProgram } from "@noldova/tools.pipelines.github";
|
|
158
|
+
*
|
|
159
|
+
* const program = new PipelinesProgram(new GitHubStepOutput(process.stdout, process.stderr));
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
public constructor(output: IStepOutput);
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Runs the step the first value names with the values after it.
|
|
166
|
+
*
|
|
167
|
+
* @param values The command line's values after the program, such as
|
|
168
|
+
* `["source", "0.0.4", "<commit>"]`.
|
|
169
|
+
* @returns A promise of the exit code: `0` after a step that succeeded,
|
|
170
|
+
* `1` after a step that failed, or when no step has the first value's name,
|
|
171
|
+
* after writing the usage line of every step.
|
|
172
|
+
* @throws `ProcessException`, from `@noldova/tools.pipelines`, when git,
|
|
173
|
+
* tar or npm can't start, and the other exceptions of the step that runs;
|
|
174
|
+
* a check that fails is a failed step, never an exception.
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* import { GitHubStepOutput, PipelinesProgram } from "@noldova/tools.pipelines.github";
|
|
178
|
+
*
|
|
179
|
+
* const program = new PipelinesProgram(new GitHubStepOutput(process.stdout, process.stderr));
|
|
180
|
+
* process.exitCode = await program.runAsync(["source", "0.0.4", "225059f4c1e6a3b2d8f7e9a0b1c2d3e4f5a6b7c8"]);
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
public runAsync(values: readonly string[]): Promise<number>;
|
|
184
|
+
}
|
package/api/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export { GitHubStepOutput } from "../services/github-step-output.js";
|
|
9
|
+
export { GitHubTags } from "../services/github-tags.js";
|
|
10
|
+
export { PipelinesProgram } from "../services/pipelines-program.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/api/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/api/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC"}
|
package/bin/pipelines.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright (c) Noldova.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import { GitHubStepOutput } from "../services/github-step-output.js";
|
|
10
|
+
import { PipelinesProgram } from "../services/pipelines-program.js";
|
|
11
|
+
process.exitCode = await new PipelinesProgram(new GitHubStepOutput(process.stdout, process.stderr)).runAsync(process.argv.slice(2));
|
|
12
|
+
//# sourceMappingURL=pipelines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipelines.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/bin/pipelines.ts"],"names":[],"mappings":";AACA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,gBAAgB,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { JsonReader } from "@noldova/context.json";
|
|
9
|
+
import { StepResult } from "@noldova/tools.pipelines";
|
|
10
|
+
import { Resources } from "../resources.js";
|
|
11
|
+
export class GitHubAnswer {
|
|
12
|
+
method;
|
|
13
|
+
resource;
|
|
14
|
+
status;
|
|
15
|
+
statusText;
|
|
16
|
+
contentType;
|
|
17
|
+
text;
|
|
18
|
+
constructor(method, resource, status, statusText, contentType, text) {
|
|
19
|
+
this.method = method;
|
|
20
|
+
this.resource = resource;
|
|
21
|
+
this.status = status;
|
|
22
|
+
this.statusText = statusText;
|
|
23
|
+
this.contentType = contentType;
|
|
24
|
+
this.text = text;
|
|
25
|
+
}
|
|
26
|
+
readBody() {
|
|
27
|
+
return JsonReader.parse(this.text, this.resource);
|
|
28
|
+
}
|
|
29
|
+
readMessage() {
|
|
30
|
+
const text = this.text.trim();
|
|
31
|
+
if (text.length === 0)
|
|
32
|
+
return this.statusText;
|
|
33
|
+
if (!Resources.jsonContentTypePattern.test(this.contentType) || !text.startsWith(Resources.jsonObjectStart))
|
|
34
|
+
return text;
|
|
35
|
+
return this.readBody().readOptionalString(Resources.messageField) ?? text;
|
|
36
|
+
}
|
|
37
|
+
toFailure() {
|
|
38
|
+
return StepResult.failed(Resources.formatApiFailed(this.method, this.resource, this.status, this.readMessage()));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=github-answer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-answer.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/models/github-answer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE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CAAC,CAAC;IACnH,CAAC;CACF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class GitHubConnection {
|
|
9
|
+
apiUrl;
|
|
10
|
+
repository;
|
|
11
|
+
token;
|
|
12
|
+
constructor(apiUrl, repository, token) {
|
|
13
|
+
this.apiUrl = apiUrl;
|
|
14
|
+
this.repository = repository;
|
|
15
|
+
this.token = token;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=github-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-connection.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/models/github-connection.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,gBAAgB;IACX,MAAM,CAAS;IACf,UAAU,CAAS;IACnB,KAAK,CAAS;IAE9B,YAAmB,MAAc,EAAE,UAAkB,EAAE,KAAa;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noldova/tools.pipelines.github",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "api/index.js",
|
|
6
|
+
"types": "api/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"pipelines": "bin/pipelines.js"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/noldova-com/tools.git",
|
|
14
|
+
"directory": "src/noldova.tools.pipelines.github"
|
|
15
|
+
},
|
|
16
|
+
"homepage": "https://github.com/noldova-com/tools#readme",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/noldova-com/tools/issues"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"registry": "https://registry.npmjs.org/"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@noldova/context.json": "0.0.3",
|
|
26
|
+
"@noldova/tools.pipelines": "0.0.1"
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "290258a729fbf6bd0784e883de9ce9f0f64e9784"
|
|
29
|
+
}
|
package/resources.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export class Resources {
|
|
9
|
+
static acceptHeader = "Accept";
|
|
10
|
+
static annotatedTagType = "tag";
|
|
11
|
+
static annotationEscapes = [["%", "%25"], ["\r", "%0D"], ["\n", "%0A"]];
|
|
12
|
+
static apiMediaType = "application/vnd.github+json";
|
|
13
|
+
static apiTimeoutMilliseconds = 60_000;
|
|
14
|
+
static apiUrlVariable = "GITHUB_API_URL";
|
|
15
|
+
static apiVersion = "2022-11-28";
|
|
16
|
+
static apiVersionHeader = "X-GitHub-Api-Version";
|
|
17
|
+
static authorizationHeader = "Authorization";
|
|
18
|
+
static commitType = "commit";
|
|
19
|
+
static contentTypeHeader = "Content-Type";
|
|
20
|
+
static createdStatus = 201;
|
|
21
|
+
static createMethod = "POST";
|
|
22
|
+
static foundStatus = 200;
|
|
23
|
+
static jsonContentType = "application/json";
|
|
24
|
+
static jsonContentTypePattern = /^application\/(?:[a-z0-9.-]+\+)?json\b/i;
|
|
25
|
+
static jsonObjectStart = "{";
|
|
26
|
+
static lineSeparator = "\n";
|
|
27
|
+
static messageField = "message";
|
|
28
|
+
static notFoundStatus = 404;
|
|
29
|
+
static objectField = "object";
|
|
30
|
+
static programName = "pipelines";
|
|
31
|
+
static readMethod = "GET";
|
|
32
|
+
static referencesPath = "git/refs";
|
|
33
|
+
static repositoryVariable = "GITHUB_REPOSITORY";
|
|
34
|
+
static shaField = "sha";
|
|
35
|
+
static tokenVariable = "GITHUB_TOKEN";
|
|
36
|
+
static typeField = "type";
|
|
37
|
+
static unprocessableStatus = 422;
|
|
38
|
+
static formatErrorAnnotation(message) {
|
|
39
|
+
const escaped = Resources.annotationEscapes.reduce((text, [character, escape]) => text.replaceAll(character, escape), message);
|
|
40
|
+
return `::error::${escaped}${Resources.lineSeparator}`;
|
|
41
|
+
}
|
|
42
|
+
static formatVariableMissing(name) {
|
|
43
|
+
return `The environment variable ${name} is not set; the tag step needs it to reach GitHub.`;
|
|
44
|
+
}
|
|
45
|
+
static formatResource(repository, path) {
|
|
46
|
+
return `repos/${repository}/${path}`;
|
|
47
|
+
}
|
|
48
|
+
static formatTagReferencePath(tag) {
|
|
49
|
+
return `git/ref/tags/${tag}`;
|
|
50
|
+
}
|
|
51
|
+
static formatTagObjectPath(sha) {
|
|
52
|
+
return `git/tags/${sha}`;
|
|
53
|
+
}
|
|
54
|
+
static formatTagReference(tag) {
|
|
55
|
+
return `refs/tags/${tag}`;
|
|
56
|
+
}
|
|
57
|
+
static formatAuthorization(token) {
|
|
58
|
+
return `Bearer ${token}`;
|
|
59
|
+
}
|
|
60
|
+
static formatApiFailed(method, resource, status, message) {
|
|
61
|
+
return `GitHub answered ${method} ${resource} with ${status}: ${message}`;
|
|
62
|
+
}
|
|
63
|
+
static formatTagTargetInvalid(tag, type) {
|
|
64
|
+
return `${tag} points to a ${type}, not a commit.`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=resources.js.map
|
package/resources.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../../src/noldova.tools.pipelines.github/src/resources.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,OAAO,SAAS;IACb,MAAM,CAAU,YAAY,GAAW,QAAQ,CAAC;IAChD,MAAM,CAAU,gBAAgB,GAAW,KAAK,CAAC;IACjD,MAAM,CAAU,iBAAiB,GAA2C,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACzH,MAAM,CAAU,YAAY,GAAW,6BAA6B,CAAC;IACrE,MAAM,CAAU,sBAAsB,GAAW,MAAM,CAAC;IACxD,MAAM,CAAU,cAAc,GAAW,gBAAgB,CAAC;IAC1D,MAAM,CAAU,UAAU,GAAW,YAAY,CAAC;IAClD,MAAM,CAAU,gBAAgB,GAAW,sBAAsB,CAAC;IAClE,MAAM,CAAU,mBAAmB,GAAW,eAAe,CAAC;IAC9D,MAAM,CAAU,UAAU,GAAW,QAAQ,CAAC;IAC9C,MAAM,CAAU,iBAAiB,GAAW,cAAc,CAAC;IAC3D,MAAM,CAAU,aAAa,GAAW,GAAG,CAAC;IAC5C,MAAM,CAAU,YAAY,GAAW,MAAM,CAAC;IAC9C,MAAM,CAAU,WAAW,GAAW,GAAG,CAAC;IAC1C,MAAM,CAAU,eAAe,GAAW,kBAAkB,CAAC;IAC7D,MAAM,CAAU,sBAAsB,GAAW,yCAAyC,CAAC;IAC3F,MAAM,CAAU,eAAe,GAAW,GAAG,CAAC;IAC9C,MAAM,CAAU,aAAa,GAAW,IAAI,CAAC;IAC7C,MAAM,CAAU,YAAY,GAAW,SAAS,CAAC;IACjD,MAAM,CAAU,cAAc,GAAW,GAAG,CAAC;IAC7C,MAAM,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AAE,CAAC;IAC3B,CAAC;IAEM,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,QAAgB,EAAE,MAAc,EAAE,OAAe;QAC7F,OAAO,mBAAmB,MAAM,IAAI,QAAQ,SAAS,MAAM,KAAK,OAAO,EAAE,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,sBAAsB,CAAC,GAAW,EAAE,IAAY;QAC5D,OAAO,GAAG,GAAG,gBAAgB,IAAI,iBAAiB,CAAC;IACrD,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { Resources } from "../resources.js";
|
|
9
|
+
export class GitHubStepOutput {
|
|
10
|
+
standardOutput;
|
|
11
|
+
standardError;
|
|
12
|
+
constructor(standardOutput, standardError) {
|
|
13
|
+
this.standardOutput = standardOutput;
|
|
14
|
+
this.standardError = standardError;
|
|
15
|
+
}
|
|
16
|
+
writeSuccess(message) {
|
|
17
|
+
if (message.length > 0)
|
|
18
|
+
this.standardOutput.write(`${message}${Resources.lineSeparator}`);
|
|
19
|
+
}
|
|
20
|
+
writeFailure(message) {
|
|
21
|
+
this.standardError.write(Resources.formatErrorAnnotation(message));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=github-step-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-step-output.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/github-step-output.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,gBAAgB;IACV,cAAc,CAAwB;IACtC,aAAa,CAAwB;IAEtD,YAAmB,cAAqC,EAAE,aAAoC;QAC5F,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,YAAY,CAAC,OAAe;QACjC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YACpB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,OAAO,GAAG,SAAS,CAAC,aAAa,EAAE,CAAC,CAAC;IACtE,CAAC;IAEM,YAAY,CAAC,OAAe;QACjC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;IACrE,CAAC;CACF"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { StepResult } from "@noldova/tools.pipelines";
|
|
9
|
+
import { GitHubAnswer } from "../models/github-answer.js";
|
|
10
|
+
import { GitHubConnection } from "../models/github-connection.js";
|
|
11
|
+
import { Resources } from "../resources.js";
|
|
12
|
+
export class GitHubTags {
|
|
13
|
+
environment;
|
|
14
|
+
timeoutMilliseconds;
|
|
15
|
+
constructor(environment, timeoutMilliseconds = Resources.apiTimeoutMilliseconds) {
|
|
16
|
+
this.environment = environment;
|
|
17
|
+
this.timeoutMilliseconds = timeoutMilliseconds;
|
|
18
|
+
}
|
|
19
|
+
async readTagAsync(tag) {
|
|
20
|
+
const connection = this.readConnection();
|
|
21
|
+
if (connection instanceof StepResult)
|
|
22
|
+
return connection;
|
|
23
|
+
const reference = await this.requestAsync(connection, Resources.readMethod, Resources.formatTagReferencePath(tag));
|
|
24
|
+
if (reference.status === Resources.notFoundStatus)
|
|
25
|
+
return "";
|
|
26
|
+
if (reference.status !== Resources.foundStatus)
|
|
27
|
+
return reference.toFailure();
|
|
28
|
+
let target = reference.readBody().readObject(Resources.objectField);
|
|
29
|
+
while (target.readString(Resources.typeField) === Resources.annotatedTagType) {
|
|
30
|
+
const tagObject = await this.requestAsync(connection, Resources.readMethod, Resources.formatTagObjectPath(target.readString(Resources.shaField)));
|
|
31
|
+
if (tagObject.status !== Resources.foundStatus)
|
|
32
|
+
return tagObject.toFailure();
|
|
33
|
+
target = tagObject.readBody().readObject(Resources.objectField);
|
|
34
|
+
}
|
|
35
|
+
const type = target.readString(Resources.typeField);
|
|
36
|
+
if (type !== Resources.commitType)
|
|
37
|
+
return StepResult.failed(Resources.formatTagTargetInvalid(tag, type));
|
|
38
|
+
return target.readString(Resources.shaField);
|
|
39
|
+
}
|
|
40
|
+
async createTagAsync(tag, commit) {
|
|
41
|
+
const connection = this.readConnection();
|
|
42
|
+
if (connection instanceof StepResult)
|
|
43
|
+
return connection;
|
|
44
|
+
const answer = await this.requestAsync(connection, Resources.createMethod, Resources.referencesPath, { ref: Resources.formatTagReference(tag), sha: commit });
|
|
45
|
+
if (answer.status === Resources.createdStatus)
|
|
46
|
+
return true;
|
|
47
|
+
if (answer.status !== Resources.unprocessableStatus)
|
|
48
|
+
return answer.toFailure();
|
|
49
|
+
const found = await this.readTagAsync(tag);
|
|
50
|
+
if (found instanceof StepResult)
|
|
51
|
+
return found;
|
|
52
|
+
return found.length > 0 ? false : answer.toFailure();
|
|
53
|
+
}
|
|
54
|
+
readConnection() {
|
|
55
|
+
const missing = [Resources.apiUrlVariable, Resources.repositoryVariable, Resources.tokenVariable].find(t => this.readVariable(t).length === 0);
|
|
56
|
+
if (missing !== undefined)
|
|
57
|
+
return StepResult.failed(Resources.formatVariableMissing(missing));
|
|
58
|
+
return new GitHubConnection(this.readVariable(Resources.apiUrlVariable), this.readVariable(Resources.repositoryVariable), this.readVariable(Resources.tokenVariable));
|
|
59
|
+
}
|
|
60
|
+
readVariable(name) {
|
|
61
|
+
return this.environment[name] ?? "";
|
|
62
|
+
}
|
|
63
|
+
async requestAsync(connection, method, path, body) {
|
|
64
|
+
const resource = Resources.formatResource(connection.repository, path);
|
|
65
|
+
const response = await fetch(`${connection.apiUrl}/${resource}`, {
|
|
66
|
+
method,
|
|
67
|
+
headers: {
|
|
68
|
+
[Resources.acceptHeader]: Resources.apiMediaType,
|
|
69
|
+
[Resources.authorizationHeader]: Resources.formatAuthorization(connection.token),
|
|
70
|
+
[Resources.apiVersionHeader]: Resources.apiVersion,
|
|
71
|
+
...(body === undefined ? {} : { [Resources.contentTypeHeader]: Resources.jsonContentType })
|
|
72
|
+
},
|
|
73
|
+
signal: AbortSignal.timeout(this.timeoutMilliseconds),
|
|
74
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) })
|
|
75
|
+
});
|
|
76
|
+
return new GitHubAnswer(method, resource, response.status, response.statusText, response.headers.get(Resources.contentTypeHeader) ?? "", await response.text());
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=github-tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-tags.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/github-tags.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAiB,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,UAAU;IACJ,WAAW,CAA+C;IAC1D,mBAAmB,CAAS;IAE7C,YAAmB,WAAyD,EAAE,mBAAmB,GAAW,SAAS,CAAC,sBAAsB;QAC1I,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,GAAW;QACnC,MAAM,UAAU,GAAG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MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAClK,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright (c) Noldova.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
import { ArchiveStep, CommandLine, Git, NightlyStep, Npm, ProcessRunner, PublishStep, SourceStep, TagStep, Tar } from "@noldova/tools.pipelines";
|
|
9
|
+
import { Resources } from "../resources.js";
|
|
10
|
+
import { GitHubTags } from "./github-tags.js";
|
|
11
|
+
export class PipelinesProgram {
|
|
12
|
+
output;
|
|
13
|
+
constructor(output) {
|
|
14
|
+
this.output = output;
|
|
15
|
+
}
|
|
16
|
+
async runAsync(values) {
|
|
17
|
+
const processRunner = new ProcessRunner();
|
|
18
|
+
const git = new Git(processRunner, process.cwd());
|
|
19
|
+
const npm = new Npm(processRunner, process.cwd());
|
|
20
|
+
const archiveStep = new ArchiveStep(git, new Tar(processRunner));
|
|
21
|
+
const steps = [new SourceStep(git), archiveStep, new PublishStep(archiveStep, npm), new NightlyStep(git, archiveStep, npm), new TagStep(new GitHubTags(process.env))];
|
|
22
|
+
return new CommandLine(Resources.programName, steps, this.output).runAsync(values);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=pipelines-program.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipelines-program.js","sourceRoot":"","sources":["../../../../src/noldova.tools.pipelines.github/src/services/pipelines-program.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAA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