Skip to content

Commit 757d793

Browse files
Update actions-toolkit.
1 parent bdeb001 commit 757d793

File tree

3 files changed

+55
-125
lines changed

3 files changed

+55
-125
lines changed

actions-toolkit

Submodule actions-toolkit updated 52 files

dist/merge/index.js

+27-62
Original file line numberDiff line numberDiff line change
@@ -847,10 +847,11 @@ class CreateArtifactRequest$Type extends runtime_5.MessageType {
847847
{ no: 4, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp },
848848
{ no: 5, name: "version", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
849849
{ no: 6, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
850+
{ no: 7, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
850851
]);
851852
}
852853
create(value) {
853-
const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 };
854+
const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 };
854855
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
855856
if (value !== undefined)
856857
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -980,10 +981,11 @@ class FinalizeArtifactRequest$Type extends runtime_5.MessageType {
980981
{ no: 6, name: "etag", kind: "scalar", T: 9 },
981982
{ no: 6, name: "upload_id", kind: "scalar", T: 9 },
982983
{ no: 8, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
984+
{ no: 9, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
983985
]);
984986
}
985987
create(value) {
986-
const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", size: "0", etag: "", uploadId: "" };
988+
const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", size: "0", etag: "", uploadId: "" };
987989
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
988990
if (value !== undefined)
989991
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -1228,10 +1230,11 @@ class ListArtifactsResponse_MonolithArtifact$Type extends runtime_5.MessageType
12281230
{ no: 5, name: "size", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
12291231
{ no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp },
12301232
{ no: 7, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1233+
{ no: 8, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
12311234
]);
12321235
}
12331236
create(value) {
1234-
const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", databaseId: "0", name: "", size: "0" };
1237+
const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", databaseId: "0", name: "", size: "0" };
12351238
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
12361239
if (value !== undefined)
12371240
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -1308,10 +1311,11 @@ class GetSignedArtifactURLRequest$Type extends runtime_5.MessageType {
13081311
{ no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
13091312
{ no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
13101313
{ no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1314+
{ no: 5, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
13111315
]);
13121316
}
13131317
create(value) {
1314-
const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" };
1318+
const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" };
13151319
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
13161320
if (value !== undefined)
13171321
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -2263,7 +2267,7 @@ exports.deleteArtifactPublic = deleteArtifactPublic;
22632267
function deleteArtifactInternal(artifactName) {
22642268
return __awaiter(this, void 0, void 0, function* () {
22652269
const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
2266-
const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
2270+
const { publicRunId, attemptNo, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
22672271
const listReq = {
22682272
runId: publicRunId,
22692273
workflowRunBackendId,
@@ -2340,9 +2344,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23402344
Object.defineProperty(exports, "__esModule", ({ value: true }));
23412345
exports.downloadArtifactInternal = exports.downloadArtifactPublic = exports.streamExtractExternal = void 0;
23422346
const promises_1 = __importDefault(__nccwpck_require__(73292));
2343-
const stream = __importStar(__nccwpck_require__(12781));
2344-
const fs_1 = __nccwpck_require__(57147);
2345-
const path = __importStar(__nccwpck_require__(71017));
23462347
const github = __importStar(__nccwpck_require__(41962));
23472348
const core = __importStar(__nccwpck_require__(42186));
23482349
const httpClient = __importStar(__nccwpck_require__(96255));
@@ -2383,11 +2384,8 @@ function streamExtract(url, directory) {
23832384
return;
23842385
}
23852386
catch (error) {
2386-
if (error.message.includes('Malformed extraction path')) {
2387-
throw new Error(`Artifact download failed with unretryable error: ${error.message}`);
2388-
}
23892387
retryCount++;
2390-
core.debug(`Failed to download artifact after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`);
2388+
core.error(`Failed to download artifact after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`);
23912389
// wait 5 seconds before retrying
23922390
yield new Promise(resolve => setTimeout(resolve, 5000));
23932391
}
@@ -2408,8 +2406,6 @@ function streamExtractExternal(url, directory) {
24082406
response.message.destroy(new Error(`Blob storage chunk did not respond in ${timeout}ms`));
24092407
};
24102408
const timer = setTimeout(timerFn, timeout);
2411-
const createdDirectories = new Set();
2412-
createdDirectories.add(directory);
24132409
response.message
24142410
.on('data', () => {
24152411
timer.refresh();
@@ -2419,50 +2415,11 @@ function streamExtractExternal(url, directory) {
24192415
clearTimeout(timer);
24202416
reject(error);
24212417
})
2422-
.pipe(unzip_stream_1.default.Parse())
2423-
.pipe(new stream.Transform({
2424-
objectMode: true,
2425-
transform: (entry, _, callback) => __awaiter(this, void 0, void 0, function* () {
2426-
const fullPath = path.normalize(path.join(directory, entry.path));
2427-
if (!directory.endsWith(path.sep)) {
2428-
directory += path.sep;
2429-
}
2430-
if (!fullPath.startsWith(directory)) {
2431-
reject(new Error(`Malformed extraction path: ${fullPath}`));
2432-
}
2433-
core.debug(`Extracting artifact entry: ${fullPath}`);
2434-
if (entry.type === 'Directory') {
2435-
if (!createdDirectories.has(fullPath)) {
2436-
createdDirectories.add(fullPath);
2437-
yield resolveOrCreateDirectory(fullPath).then(() => {
2438-
entry.autodrain();
2439-
callback();
2440-
});
2441-
}
2442-
else {
2443-
entry.autodrain();
2444-
callback();
2445-
}
2446-
}
2447-
else {
2448-
if (!createdDirectories.has(path.dirname(fullPath))) {
2449-
createdDirectories.add(path.dirname(fullPath));
2450-
yield resolveOrCreateDirectory(path.dirname(fullPath)).then(() => {
2451-
entry.autodrain();
2452-
callback();
2453-
});
2454-
}
2455-
const writeStream = (0, fs_1.createWriteStream)(fullPath);
2456-
writeStream.on('finish', callback);
2457-
writeStream.on('error', reject);
2458-
entry.pipe(writeStream);
2459-
}
2460-
})
2461-
}))
2462-
.on('finish', () => __awaiter(this, void 0, void 0, function* () {
2418+
.pipe(unzip_stream_1.default.Extract({ path: directory }))
2419+
.on('close', () => {
24632420
clearTimeout(timer);
24642421
resolve();
2465-
}))
2422+
})
24662423
.on('error', (error) => {
24672424
reject(error);
24682425
});
@@ -2508,7 +2465,7 @@ function downloadArtifactInternal(artifactId, options) {
25082465
return __awaiter(this, void 0, void 0, function* () {
25092466
const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path);
25102467
const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
2511-
const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
2468+
const { publicRunId, attemptNo, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
25122469
const listReq = {
25132470
runId: publicRunId,
25142471
workflowRunBackendId,
@@ -2524,6 +2481,7 @@ function downloadArtifactInternal(artifactId, options) {
25242481
}
25252482
const signedReq = {
25262483
runId: artifacts[0].runId,
2484+
attemptNo: attemptNo,
25272485
workflowRunBackendId: artifacts[0].workflowRunBackendId,
25282486
workflowJobRunBackendId: artifacts[0].workflowJobRunBackendId,
25292487
name: artifacts[0].name
@@ -2653,7 +2611,7 @@ exports.getArtifactPublic = getArtifactPublic;
26532611
function getArtifactInternal(artifactName) {
26542612
return __awaiter(this, void 0, void 0, function* () {
26552613
const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
2656-
const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
2614+
const { publicRunId, attemptNo, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
26572615
const req = {
26582616
runId: publicRunId,
26592617
workflowRunBackendId,
@@ -2990,7 +2948,6 @@ class ArtifactHttpClient {
29902948
catch (error) {
29912949
if (error instanceof SyntaxError) {
29922950
(0, core_1.debug)(`Raw Body: ${rawBody}`);
2993-
throw error;
29942951
}
29952952
if (error instanceof errors_1.UsageError) {
29962953
throw error;
@@ -3149,8 +3106,9 @@ function isGhes() {
31493106
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
31503107
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
31513108
const isGitHubHost = hostname === 'GITHUB.COM';
3152-
const isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST');
3153-
return !isGitHubHost && !isGheHost;
3109+
const isGheHost = hostname.endsWith('.GHE.COM');
3110+
const isLocalHost = hostname.endsWith('.LOCALHOST');
3111+
return !isGitHubHost && !isGheHost && !isLocalHost;
31543112
}
31553113
exports.isGhes = isGhes;
31563114
function getGitHubWorkspaceDir() {
@@ -3361,10 +3319,15 @@ function getBackendIdsFromToken() {
33613319
if (publicRunId == null) {
33623320
throw new Error("failed to get GITHUB_RUN_ID environment variable");
33633321
}
3322+
const attemptNo = process.env["GITHUB_RUN_ATTEMPT"];
3323+
if (attemptNo == null) {
3324+
throw new Error("failed to get GITHUB_RUN_ATTEMPT environment variable");
3325+
}
33643326
const ids = {
33653327
workflowRunBackendId: scopeParts[1],
33663328
workflowJobRunBackendId: scopeParts[2],
33673329
publicRunId: publicRunId,
3330+
attemptNo: Number(attemptNo),
33683331
};
33693332
core.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`);
33703333
core.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`);
@@ -3701,6 +3664,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
37013664
// create the artifact
37023665
const createArtifactReq = {
37033666
runId: backendIds.publicRunId,
3667+
attemptNo: backendIds.attemptNo,
37043668
workflowRunBackendId: backendIds.workflowRunBackendId,
37053669
workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
37063670
name,
@@ -3721,6 +3685,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
37213685
// finalize the artifact
37223686
const finalizeArtifactReq = {
37233687
runId: backendIds.publicRunId,
3688+
attemptNo: backendIds.attemptNo,
37243689
workflowRunBackendId: backendIds.workflowRunBackendId,
37253690
workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
37263691
name,
@@ -129897,7 +129862,7 @@ exports.unescape = unescape;
129897129862
/***/ ((module) => {
129898129863

129899129864
"use strict";
129900-
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.2","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^5.3.1","crypto":"^1.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
129865+
module.exports = JSON.parse('{"name":"@actions/artifact","version":"2.1.8","preview":true,"description":"Actions artifact lib","keywords":["github","actions","artifact"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/artifact","license":"MIT","main":"lib/artifact.js","types":"lib/artifact.d.ts","directories":{"lib":"lib","test":"__tests__"},"files":["lib","!.DS_Store"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/actions/toolkit.git","directory":"packages/artifact"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"cd ../../ && npm run test ./packages/artifact","bootstrap":"cd ../../ && npm run bootstrap","tsc-run":"tsc","tsc":"npm run bootstrap && npm run tsc-run","gen:docs":"typedoc --plugin typedoc-plugin-markdown --out docs/generated src/artifact.ts --githubPages false --readme none"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.10.0","@actions/github":"^5.1.1","@actions/http-client":"^2.1.0","@azure/storage-blob":"^12.15.0","@octokit/core":"^3.5.1","@octokit/plugin-request-log":"^1.0.4","@octokit/plugin-retry":"^3.0.9","@octokit/request-error":"^5.0.0","@protobuf-ts/plugin":"^2.2.3-alpha.1","archiver":"^7.0.1","crypto":"^1.0.1","jwt-decode":"^3.1.2","twirp-ts":"^2.5.0","unzip-stream":"^0.3.1"},"devDependencies":{"@types/archiver":"^5.3.2","@types/unzip-stream":"^0.3.4","typedoc":"^0.25.4","typedoc-plugin-markdown":"^3.17.1","typescript":"^5.2.2"}}');
129901129866

129902129867
/***/ }),
129903129868

0 commit comments

Comments
 (0)