@git.zone/cli 9.0.0 → 9.1.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.
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  // Managed by @git.zone/cli from assets/templates/asset_binary_postinstall. Do not edit by hand.
3
3
 
4
- import { arch, platform } from 'node:os';
5
- import { existsSync } from 'node:fs';
4
+ import { arch, constants, platform } from 'node:os';
5
+ import { closeSync, constants as fsConstants, existsSync, openSync } from 'node:fs';
6
6
  import { dirname, join } from 'node:path';
7
7
  import { fileURLToPath } from 'node:url';
8
- import { spawnSync } from 'node:child_process';
8
+ import { spawn } from 'node:child_process';
9
9
 
10
10
  const __filename = fileURLToPath(import.meta.url);
11
11
  const __dirname = dirname(__filename);
@@ -29,9 +29,67 @@ if (!existsSync(binaryPath)) {
29
29
  process.exit(1);
30
30
  }
31
31
 
32
- const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
33
- if (result.error) {
34
- console.error(result.error.message);
35
- process.exit(1);
32
+ // Without a controlling terminal (setsid, docker run without -t, a detached spawn) no Ctrl+C can reach the
33
+ // binary through a terminal, so SIGINT is forwarded like SIGTERM. Opening /dev/tty only names an existing
34
+ // controlling terminal and cannot acquire one; ENXIO means there is none. O_NONBLOCK keeps a serial line
35
+ // without carrier from holding the open.
36
+ const hasNoTerminal = () => {
37
+ let fd;
38
+ try {
39
+ fd = openSync('/dev/tty', fsConstants.O_RDONLY | fsConstants.O_NONBLOCK);
40
+ return false;
41
+ } catch (error) {
42
+ return error.code === 'ENXIO';
43
+ } finally {
44
+ if (fd !== undefined) closeSync(fd);
45
+ }
46
+ };
47
+ const forwardInterrupt = platform() !== 'win32' && hasNoTerminal();
48
+
49
+ const child = spawn(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
50
+
51
+ // Pass termination requests on to the binary while it runs; the wrapper ends when the binary does.
52
+ // SIGTERM and SIGHUP usually reach the wrapper's pid alone (kill <pid>, kill -HUP $MAINPID), so they are forwarded.
53
+ // With a controlling terminal SIGINT is not: a terminal Ctrl+C goes to the whole foreground process group and
54
+ // reaches the binary directly, so forwarding would deliver it twice. The wrapper only ignores SIGINT until the
55
+ // binary ends, which also ignores a parent's child.kill('SIGINT') (Node names no sender): send SIGTERM, or spawn
56
+ // the wrapper detached. Windows has no POSIX signals: a console Ctrl+C reaches the binary directly, and
57
+ // child.kill() would terminate it outright, so the wrapper forwards nothing there.
58
+ // A signal sent to the whole process group (systemd's default KillMode=control-group, kill -TERM -<pgid>, and
59
+ // without a terminal also a group SIGINT such as tini -g or KillSignal=SIGINT) reaches the binary directly and
60
+ // once more through the wrapper: supervisors should run the native binary, or use KillMode=mixed with this wrapper.
61
+ const forwardedSignals = platform() === 'win32' ? [] : ['SIGTERM', 'SIGHUP', ...(forwardInterrupt ? ['SIGINT'] : [])];
62
+ const forwardSignal = (signal) => {
63
+ if (child.exitCode === null && child.signalCode === null) {
64
+ child.kill(signal);
65
+ }
66
+ };
67
+ const ignoreSignal = () => {};
68
+ for (const signal of forwardedSignals) {
69
+ process.on(signal, forwardSignal);
70
+ }
71
+ if (platform() !== 'win32' && !forwardInterrupt) {
72
+ process.on('SIGINT', ignoreSignal);
36
73
  }
37
- process.exit(result.status ?? 0);
74
+
75
+ child.on('error', (error) => {
76
+ console.error(error.message);
77
+ process.exit(1);
78
+ });
79
+
80
+ child.on('exit', (code, signal) => {
81
+ for (const forwardedSignal of forwardedSignals) {
82
+ process.removeListener(forwardedSignal, forwardSignal);
83
+ }
84
+ process.removeListener('SIGINT', ignoreSignal);
85
+ if (signal) {
86
+ // Die of the same signal, so callers see what ended the binary. Node ignores some signals
87
+ // (SIGPIPE) and starts its inspector on SIGUSR1; those end with the shell convention 128 + n.
88
+ if (signal !== 'SIGUSR1') {
89
+ process.removeAllListeners(signal);
90
+ process.kill(process.pid, signal);
91
+ }
92
+ process.exit(128 + (constants.signals[signal] ?? 0));
93
+ }
94
+ process.exit(code ?? 1);
95
+ });
@@ -2,25 +2,50 @@
2
2
  // Managed by @git.zone/cli from assets/templates/asset_binary_postinstall. Do not edit by hand.
3
3
 
4
4
  import { arch, platform } from 'node:os';
5
- import { chmodSync, existsSync, mkdirSync, unlinkSync } from 'node:fs';
6
- import { dirname, join } from 'node:path';
5
+ import { createHash } from 'node:crypto';
6
+ import { chmodSync, createWriteStream, existsSync, mkdirSync, readFileSync, renameSync, rmSync } from 'node:fs';
7
+ import { dirname, join, resolve, sep } from 'node:path';
7
8
  import { fileURLToPath } from 'node:url';
8
9
  import https from 'node:https';
9
- import { pipeline } from 'node:stream';
10
- import { createWriteStream } from 'node:fs';
11
10
  import process from 'node:process';
12
11
 
13
12
  const __filename = fileURLToPath(import.meta.url);
14
13
  const __dirname = dirname(__filename);
15
14
 
16
15
  const REPO_BASE = '{{{repository.baseUrl}}}';
17
- const FALLBACK_BRANCH = '{{repository.branch}}';
18
- const VERSION = process.env.npm_package_version || '{{versionFallback}}';
16
+ const PACKAGE_ROOT = resolve(__dirname, '..');
17
+ const VERSION = JSON.parse(readFileSync(join(PACKAGE_ROOT, 'package.json'), 'utf8')).version;
18
+ const RELEASE_BASE = `${REPO_BASE}/releases/download/v${VERSION}`;
19
+ /** A SemVer 2.0 version; the release tag is it with a leading v. Nothing else goes into a download URL. */
20
+ const VERSION_PATTERN = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$/;
21
+ const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
22
+ const MAX_REDIRECTS = 10;
23
+ /** Connecting and every silence while transferring. */
24
+ const IDLE_TIMEOUT_MS = 30_000;
25
+ /** The whole transfer of one file, redirects included. */
26
+ const DEADLINE_MS = 15 * 60_000;
27
+ const MAX_CHECKSUMS_BYTES = 1024 * 1024;
19
28
  const BINARY_MAP = new Map([
20
29
  {{#each binary.targets}}
21
30
  ['{{nodeKey}}', '{{name}}'],
22
31
  {{/each}}
23
32
  ]);
33
+ /** The third-party notice files each executable's release ships; they are installed beside it. */
34
+ const NOTICE_FILES = new Map([
35
+ {{#each binary.targets}}
36
+ ['{{name}}', [{{#each noticeFiles}}{{#unless @first}}, {{/unless}}'{{this}}'{{/each}}]],
37
+ {{/each}}
38
+ ]);
39
+
40
+ /**
41
+ * npm, pnpm, Yarn and Bun place every installed package, local or global, inside a
42
+ * node_modules directory. Outside one, this is the project's own checkout (development
43
+ * or a release build), whose binaries the project builds itself and whose version is
44
+ * not released yet.
45
+ */
46
+ function isInstalledAsDependency() {
47
+ return PACKAGE_ROOT.split(sep).includes('node_modules');
48
+ }
24
49
 
25
50
  function getBinaryInfo() {
26
51
  const key = `${platform()}:${arch()}`;
@@ -31,41 +56,125 @@ function getBinaryInfo() {
31
56
  return { supported: true, key, binaryName, platform: platform(), arch: arch() };
32
57
  }
33
58
 
34
- function downloadFile(url, destination) {
35
- return new Promise((resolve, reject) => {
36
- const download = (nextUrl, redirectCount = 0) => {
37
- if (redirectCount > 5) {
38
- reject(new Error('Too many redirects'));
59
+ /**
60
+ * GETs an HTTPS URL, following redirects, and passes the 200 response to `consume`. Fails on any other
61
+ * status, a non-HTTPS redirect, more than MAX_REDIRECTS hops, IDLE_TIMEOUT_MS of silence or DEADLINE_MS overall.
62
+ */
63
+ function fetchHttps(url, consume) {
64
+ return new Promise((resolvePromise, rejectPromise) => {
65
+ const chain = [];
66
+ let request;
67
+ let settled = false;
68
+ const finish = (error, value) => {
69
+ if (settled) return;
70
+ settled = true;
71
+ clearTimeout(deadline);
72
+ if (error) {
73
+ request?.destroy();
74
+ rejectPromise(error);
75
+ } else {
76
+ resolvePromise(value);
77
+ }
78
+ };
79
+ const deadline = setTimeout(
80
+ () => finish(new Error(`no complete answer within ${DEADLINE_MS / 60_000} minutes from ${chain.join(' -> ')}`)),
81
+ DEADLINE_MS,
82
+ );
83
+ const get = (target) => {
84
+ chain.push(target);
85
+ if (chain.length > MAX_REDIRECTS + 1) {
86
+ finish(new Error(`more than ${MAX_REDIRECTS} redirects: ${chain.join(' -> ')}`));
39
87
  return;
40
88
  }
41
-
42
- console.log(`Downloading from: ${nextUrl}`);
43
- https.get(nextUrl, (response) => {
44
- if (response.statusCode === 301 || response.statusCode === 302) {
45
- download(response.headers.location, redirectCount + 1);
89
+ if (new URL(target).protocol !== 'https:') {
90
+ finish(new Error(`refusing a non-HTTPS URL: ${chain.join(' -> ')}`));
91
+ return;
92
+ }
93
+ const current = https.get(target, { timeout: IDLE_TIMEOUT_MS }, (response) => {
94
+ const location = response.headers.location;
95
+ if (REDIRECT_STATUSES.has(response.statusCode) && location) {
96
+ response.resume();
97
+ let next;
98
+ try {
99
+ next = new URL(location, target).href;
100
+ } catch {
101
+ finish(new Error(`invalid redirect location ${JSON.stringify(location)} from ${target}`));
102
+ return;
103
+ }
104
+ get(next);
46
105
  return;
47
106
  }
48
107
  if (response.statusCode !== 200) {
49
- reject(new Error(`Failed to download: ${response.statusCode} ${response.statusMessage}`));
108
+ response.resume();
109
+ finish(new Error(`HTTP ${response.statusCode} ${response.statusMessage ?? ''}`.trim() + ` from ${target}`));
50
110
  return;
51
111
  }
52
-
53
- const file = createWriteStream(destination);
54
- pipeline(response, file, (error) => {
55
- if (error) {
56
- reject(error);
57
- } else {
58
- resolve();
59
- }
60
- });
61
- }).on('error', reject);
112
+ consume(response).then((value) => finish(undefined, value), (error) => finish(error));
113
+ });
114
+ request = current;
115
+ current.on('timeout', () => {
116
+ current.destroy(new Error(`no data for ${IDLE_TIMEOUT_MS / 1000} s from ${target}`));
117
+ });
118
+ // A redirect's finished request no longer decides the outcome.
119
+ current.on('error', (error) => {
120
+ if (request === current) finish(error);
121
+ });
62
122
  };
123
+ get(url);
124
+ });
125
+ }
63
126
 
64
- download(url);
127
+ let releaseSums;
128
+ /** The release's SHA256SUMS.txt, fetched once. */
129
+ function fetchReleaseSums() {
130
+ releaseSums ??= fetchHttps(`${RELEASE_BASE}/SHA256SUMS.txt`, async (response) => {
131
+ let text = '';
132
+ for await (const chunk of response) {
133
+ text += chunk;
134
+ if (text.length > MAX_CHECKSUMS_BYTES) throw new Error('SHA256SUMS.txt exceeds 1 MiB');
135
+ }
136
+ return text;
65
137
  });
138
+ return releaseSums;
139
+ }
140
+
141
+ /** The SHA-256 SHA256SUMS.txt of the release lists for `name`. */
142
+ async function expectedDigest(name) {
143
+ const sums = await fetchReleaseSums();
144
+ for (const line of sums.split(/\r?\n/)) {
145
+ const match = /^([0-9a-fA-F]{64})\s+\*?(.+?)\s*$/.exec(line);
146
+ if (match && match[2] === name) return match[1].toLowerCase();
147
+ }
148
+ throw new Error(`SHA256SUMS.txt of v${VERSION} has no entry for ${name}`);
149
+ }
150
+
151
+ /** Downloads `url` to `partial` and fails unless its SHA-256 is `digest`. */
152
+ async function downloadVerified(url, partial, digest) {
153
+ const actual = await fetchHttps(url, (response) => new Promise((resolveDigest, rejectDigest) => {
154
+ const hash = createHash('sha256');
155
+ const file = createWriteStream(partial, { mode: 0o600 });
156
+ response.on('data', (chunk) => hash.update(chunk));
157
+ response.on('error', rejectDigest);
158
+ file.on('error', rejectDigest);
159
+ file.on('finish', () => resolveDigest(hash.digest('hex')));
160
+ response.pipe(file);
161
+ }));
162
+ if (actual !== digest) {
163
+ throw new Error(`checksum mismatch: SHA256SUMS.txt lists ${digest}, the download is ${actual}`);
164
+ }
66
165
  }
67
166
 
68
167
  async function main() {
168
+ if (!isInstalledAsDependency()) {
169
+ console.log('{{displayName}}: skipping the binary download in the project\'s own install (not inside node_modules).');
170
+ return;
171
+ }
172
+
173
+ if (typeof VERSION !== 'string' || !VERSION_PATTERN.test(VERSION)) {
174
+ console.error(`Error: the version ${JSON.stringify(VERSION)} in package.json is not a SemVer version; refusing to build a release URL from it`);
175
+ process.exit(1);
176
+ }
177
+
69
178
  console.log('===========================================');
70
179
  console.log(' {{displayName}} - Binary Installation');
71
180
  console.log('===========================================');
@@ -84,29 +193,46 @@ async function main() {
84
193
  }
85
194
 
86
195
  const binaryPath = join(binariesDir, binaryInfo.binaryName);
87
- if (existsSync(binaryPath)) {
88
- console.log('Binary already exists, skipping download');
196
+ // The executable and its third-party notices travel together: a missing notice file is fetched
197
+ // even when the executable is already in place.
198
+ const releaseFiles = [binaryInfo.binaryName, ...(NOTICE_FILES.get(binaryInfo.binaryName) ?? [])];
199
+ const missingFiles = releaseFiles.filter((name) => !existsSync(join(binariesDir, name)));
200
+ if (missingFiles.length === 0) {
201
+ console.log('Binary and notices already exist, skipping download');
89
202
  } else {
90
- const releaseUrl = `${REPO_BASE}/releases/download/v${VERSION}/${binaryInfo.binaryName}`;
91
- const fallbackUrl = `${REPO_BASE}/raw/branch/${FALLBACK_BRANCH}/{{{npmWrapper.binariesDir}}}/${binaryInfo.binaryName}`;
92
-
203
+ if (!missingFiles.includes(binaryInfo.binaryName)) {
204
+ console.log('Binary already exists, downloading its missing notice files');
205
+ }
206
+ const partials = new Map(missingFiles.map((name) => [name, join(binariesDir, `${name}.download-${process.pid}`)]));
207
+ let failedUrl = `${RELEASE_BASE}/SHA256SUMS.txt`;
93
208
  try {
94
- await downloadFile(releaseUrl, binaryPath);
95
- } catch (error) {
96
- console.log(`Release download failed: ${error.message}`);
97
- console.log('Trying fallback URL...');
98
- try {
99
- await downloadFile(fallbackUrl, binaryPath);
100
- } catch (fallbackError) {
101
- if (existsSync(binaryPath)) {
102
- unlinkSync(binaryPath);
209
+ // Every file needs its checksum entry before anything downloads.
210
+ const digests = new Map();
211
+ for (const name of missingFiles) {
212
+ digests.set(name, await expectedDigest(name));
213
+ }
214
+ for (const name of missingFiles) {
215
+ const releaseUrl = `${RELEASE_BASE}/${name}`;
216
+ failedUrl = releaseUrl;
217
+ console.log(`Downloading from: ${releaseUrl}`);
218
+ await downloadVerified(releaseUrl, partials.get(name), digests.get(name));
219
+ console.log(`Checksum verified: ${name}`);
220
+ }
221
+ // Only a complete, verified set moves into place, the executable last.
222
+ for (const name of [...missingFiles].reverse()) {
223
+ if (name !== binaryInfo.binaryName) {
224
+ chmodSync(partials.get(name), 0o644);
103
225
  }
104
- console.error('Error: Failed to download binary');
105
- console.error(` Primary URL: ${releaseUrl}`);
106
- console.error(` Fallback URL: ${fallbackUrl}`);
107
- console.error(` Cause: ${fallbackError.message}`);
108
- process.exit(1);
226
+ renameSync(partials.get(name), join(binariesDir, name));
227
+ }
228
+ } catch (error) {
229
+ for (const partial of partials.values()) {
230
+ rmSync(partial, { force: true });
109
231
  }
232
+ console.error(`Error: Failed to install the {{displayName}} ${VERSION} binary for ${binaryInfo.key}`);
233
+ console.error(` URL: ${failedUrl}`);
234
+ console.error(` Cause: ${error.message}`);
235
+ process.exit(1);
110
236
  }
111
237
  }
112
238
 
@@ -49,6 +49,30 @@ jobs:
49
49
  - name: Build binary artifacts
50
50
  run: {{{releaseWorkflow.compileCommand}}}
51
51
 
52
+ {{#if releaseWorkflow.hasExtraAssets}}
53
+ - name: Stage extra release assets
54
+ run: |
55
+ set -euo pipefail
56
+ # Every extra is checked before any is staged, and the release is created only after this step,
57
+ # so a missing extra fails the job with no release and no upload.
58
+ WORKSPACE=$(realpath "$GITHUB_WORKSPACE")
59
+ for asset in{{#each releaseWorkflow.extraAssets}} "{{path}}"{{/each}}; do
60
+ if [ ! -f "$asset" ]; then
61
+ echo "ERROR: extra release asset $asset is not a regular file in the checkout" >&2
62
+ exit 1
63
+ fi
64
+ RESOLVED=$(realpath "$asset")
65
+ case "$RESOLVED" in
66
+ "$WORKSPACE"/*) ;;
67
+ *) echo "ERROR: extra release asset $asset resolves to $RESOLVED, outside the checkout" >&2; exit 1 ;;
68
+ esac
69
+ done
70
+ {{#each releaseWorkflow.extraAssets}}
71
+ install -m 0644 "{{path}}" "{{../releaseWorkflow.binaryOutDir}}/{{name}}"
72
+ {{/each}}
73
+ echo "Extra release assets staged:{{#each releaseWorkflow.extraAssets}} {{name}}{{/each}}"
74
+
75
+ {{/if}}
52
76
  {{#if releaseWorkflow.includeInstallerAsset}}
53
77
  - name: Stage installer asset
54
78
  run: |
@@ -72,10 +96,10 @@ jobs:
72
96
  {{/if}}
73
97
  - name: Extract release notes
74
98
  run: |
99
+ set -euo pipefail
75
100
  VERSION="${-{ steps.version.outputs.version }-}"
76
- if [ -f changelog.md ]; then
77
- awk "/## $VERSION/,/## /" changelog.md | sed '$d' > /tmp/release_notes.md || true
78
- fi
101
+ # The changelog section `## <date> - <version>`; generic notes only when it has none.
102
+ node scripts/gitzone-binary-release.mjs notes "${-{ steps.version.outputs.version_number }-}" changelog.md > /tmp/release_notes.md
79
103
  if [ ! -s /tmp/release_notes.md ]; then
80
104
  cat > /tmp/release_notes.md << EOF
81
105
  ## {{displayName}} $VERSION
@@ -142,36 +166,50 @@ jobs:
142
166
  curl --fail-with-body -sS \
143
167
  -H "Authorization: token $GITEA_TOKEN" \
144
168
  "$API/releases/$RELEASE_ID/assets" > /tmp/release_assets.json
145
- # Gitea keeps every upload as its own attachment, so a re-run first
146
- # deletes the same-named assets of an earlier attempt.
147
- upload_asset() {
148
- artifact="$1"
149
- filename=$(basename "$artifact")
150
- for attachment_id in $(jq -r --arg name "$filename" '.[] | select(.name == $name) | .id' /tmp/release_assets.json); do
151
- echo "Replacing existing asset $filename ($attachment_id)..."
152
- curl --fail-with-body -sS -X DELETE \
153
- -H "Authorization: token $GITEA_TOKEN" \
154
- "$API/releases/$RELEASE_ID/assets/$attachment_id" > /dev/null
155
- done
156
- echo "Uploading $filename..."
157
- curl --fail-with-body -sS -X POST \
158
- -H "Authorization: token $GITEA_TOKEN" \
159
- -H "Content-Type: application/octet-stream" \
160
- --data-binary "@$artifact" \
161
- "$API/releases/$RELEASE_ID/assets?name=$filename" > /dev/null
162
- }
169
+ ARTIFACTS=()
163
170
  for filename in{{#each releaseWorkflow.releaseFileNames}} "{{{this}}}"{{/each}} SHA256SUMS.txt; do
164
171
  artifact="{{releaseWorkflow.binaryOutDir}}/$filename"
165
172
  [ -f "$artifact" ] || { echo "ERROR: release asset $artifact was not built" >&2; exit 1; }
166
- upload_asset "$artifact"
173
+ ARTIFACTS+=("$artifact")
167
174
  done
168
175
  {{#if releaseWorkflow.packNpmArtifact}}
169
176
  for artifact in dist/package/*.tgz; do
170
177
  [ -f "$artifact" ] || { echo "ERROR: no npm artifact in dist/package" >&2; exit 1; }
171
- upload_asset "$artifact"
178
+ ARTIFACTS+=("$artifact")
172
179
  done
173
180
  {{/if}}
181
+ # A published asset is never replaced: any same-named asset on the release stops the job before
182
+ # anything uploads. Delete it in Gitea first when a run must upload it again.
183
+ EXISTING=0
184
+ for artifact in "${ARTIFACTS[@]}"; do
185
+ filename=$(basename "$artifact")
186
+ if jq -e --arg name "$filename" 'any(.[]; .name == $name)' /tmp/release_assets.json > /dev/null; then
187
+ echo "ERROR: release ${-{ steps.version.outputs.version }-} already has an asset named $filename; refusing to replace it" >&2
188
+ EXISTING=1
189
+ fi
190
+ done
191
+ [ "$EXISTING" -eq 0 ] || exit 1
192
+ for artifact in "${ARTIFACTS[@]}"; do
193
+ filename=$(basename "$artifact")
194
+ echo "Uploading $filename..."
195
+ curl --fail-with-body -sS -X POST \
196
+ -H "Authorization: token $GITEA_TOKEN" \
197
+ -H "Content-Type: application/octet-stream" \
198
+ --data-binary "@$artifact" \
199
+ "$API/releases/$RELEASE_ID/assets?name=$filename" > /dev/null
200
+ done
201
+
202
+ {{#if releaseWorkflow.keepReleases}}
203
+ - name: Delete releases older than the newest {{releaseWorkflow.keepReleases}}
204
+ env:
205
+ GITEA_TOKEN: ${-{ secrets.GITHUB_TOKEN }-}
206
+ GITEA_API: https://{{repository.host}}/api/v1/repos/{{repository.path}}
207
+ run: |
208
+ set -euo pipefail
209
+ # Deletes old releases and their assets; their tags stay.
210
+ node scripts/gitzone-binary-release.mjs prune {{releaseWorkflow.keepReleases}} "${-{ steps.version.outputs.version }-}"
174
211
 
212
+ {{/if}}
175
213
  - name: Release summary
176
214
  run: |
177
215
  echo "Release ${-{ steps.version.outputs.version }-} complete"
@@ -0,0 +1,29 @@
1
+ // Types for gitzone-binary-release.mjs, which the CLI tests import. Not rendered into projects.
2
+
3
+ export interface IGiteaReleaseEntry {
4
+ id: number;
5
+ tag_name: string;
6
+ draft: boolean;
7
+ created_at: string;
8
+ [key: string]: unknown;
9
+ }
10
+
11
+ export declare function extractReleaseNotes(changelog: string, version: string): string | null;
12
+
13
+ export declare function selectReleasesToDelete(
14
+ releases: IGiteaReleaseEntry[],
15
+ options: { keep: number | string; currentTag: string },
16
+ ): IGiteaReleaseEntry[];
17
+
18
+ export interface IGiteaReleaseApiOptions {
19
+ /** https://<host>/api/v1/repos/<owner>/<repo> */
20
+ api: string;
21
+ token: string;
22
+ fetch?: typeof globalThis.fetch;
23
+ }
24
+
25
+ export declare function listReleases(options: IGiteaReleaseApiOptions): Promise<IGiteaReleaseEntry[]>;
26
+
27
+ export declare function pruneReleases(
28
+ options: IGiteaReleaseApiOptions & { keep: number | string; currentTag: string; log?: (message: string) => void },
29
+ ): Promise<IGiteaReleaseEntry[]>;