@@ -847,10 +847,11 @@ class CreateArtifactRequest$Type extends runtime_5.MessageType {
847
847
{ no: 4, name: "expires_at", kind: "message", T: () => timestamp_1.Timestamp },
848
848
{ no: 5, name: "version", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
849
849
{ no: 6, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
850
+ { no: 7, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
850
851
]);
851
852
}
852
853
create(value) {
853
- const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 };
854
+ const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", name: "", version: 0 };
854
855
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
855
856
if (value !== undefined)
856
857
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -980,10 +981,11 @@ class FinalizeArtifactRequest$Type extends runtime_5.MessageType {
980
981
{ no: 6, name: "etag", kind: "scalar", T: 9 },
981
982
{ no: 6, name: "upload_id", kind: "scalar", T: 9 },
982
983
{ no: 8, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
984
+ { no: 9, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
983
985
]);
984
986
}
985
987
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: "" };
987
989
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
988
990
if (value !== undefined)
989
991
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -1228,10 +1230,11 @@ class ListArtifactsResponse_MonolithArtifact$Type extends runtime_5.MessageType
1228
1230
{ no: 5, name: "size", kind: "scalar", T: 3 /*ScalarType.INT64*/ },
1229
1231
{ no: 6, name: "created_at", kind: "message", T: () => timestamp_1.Timestamp },
1230
1232
{ no: 7, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1233
+ { no: 8, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
1231
1234
]);
1232
1235
}
1233
1236
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" };
1235
1238
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
1236
1239
if (value !== undefined)
1237
1240
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -1308,10 +1311,11 @@ class GetSignedArtifactURLRequest$Type extends runtime_5.MessageType {
1308
1311
{ no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1309
1312
{ no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1310
1313
{ no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1314
+ { no: 5, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
1311
1315
]);
1312
1316
}
1313
1317
create(value) {
1314
- const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" };
1318
+ const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" };
1315
1319
globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
1316
1320
if (value !== undefined)
1317
1321
(0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -2263,7 +2267,7 @@ exports.deleteArtifactPublic = deleteArtifactPublic;
2263
2267
function deleteArtifactInternal(artifactName) {
2264
2268
return __awaiter(this, void 0, void 0, function* () {
2265
2269
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)();
2267
2271
const listReq = {
2268
2272
runId: publicRunId,
2269
2273
workflowRunBackendId,
@@ -2340,9 +2344,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
2340
2344
Object.defineProperty(exports, "__esModule", ({ value: true }));
2341
2345
exports.downloadArtifactInternal = exports.downloadArtifactPublic = exports.streamExtractExternal = void 0;
2342
2346
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));
2346
2347
const github = __importStar(__nccwpck_require__(41962));
2347
2348
const core = __importStar(__nccwpck_require__(42186));
2348
2349
const httpClient = __importStar(__nccwpck_require__(96255));
@@ -2383,11 +2384,8 @@ function streamExtract(url, directory) {
2383
2384
return;
2384
2385
}
2385
2386
catch (error) {
2386
- if (error.message.includes('Malformed extraction path')) {
2387
- throw new Error(`Artifact download failed with unretryable error: ${error.message}`);
2388
- }
2389
2387
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...`);
2391
2389
// wait 5 seconds before retrying
2392
2390
yield new Promise(resolve => setTimeout(resolve, 5000));
2393
2391
}
@@ -2408,8 +2406,6 @@ function streamExtractExternal(url, directory) {
2408
2406
response.message.destroy(new Error(`Blob storage chunk did not respond in ${timeout}ms`));
2409
2407
};
2410
2408
const timer = setTimeout(timerFn, timeout);
2411
- const createdDirectories = new Set();
2412
- createdDirectories.add(directory);
2413
2409
response.message
2414
2410
.on('data', () => {
2415
2411
timer.refresh();
@@ -2419,50 +2415,11 @@ function streamExtractExternal(url, directory) {
2419
2415
clearTimeout(timer);
2420
2416
reject(error);
2421
2417
})
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', () => {
2463
2420
clearTimeout(timer);
2464
2421
resolve();
2465
- }))
2422
+ })
2466
2423
.on('error', (error) => {
2467
2424
reject(error);
2468
2425
});
@@ -2508,7 +2465,7 @@ function downloadArtifactInternal(artifactId, options) {
2508
2465
return __awaiter(this, void 0, void 0, function* () {
2509
2466
const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path);
2510
2467
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)();
2512
2469
const listReq = {
2513
2470
runId: publicRunId,
2514
2471
workflowRunBackendId,
@@ -2524,6 +2481,7 @@ function downloadArtifactInternal(artifactId, options) {
2524
2481
}
2525
2482
const signedReq = {
2526
2483
runId: artifacts[0].runId,
2484
+ attemptNo: attemptNo,
2527
2485
workflowRunBackendId: artifacts[0].workflowRunBackendId,
2528
2486
workflowJobRunBackendId: artifacts[0].workflowJobRunBackendId,
2529
2487
name: artifacts[0].name
@@ -2653,7 +2611,7 @@ exports.getArtifactPublic = getArtifactPublic;
2653
2611
function getArtifactInternal(artifactName) {
2654
2612
return __awaiter(this, void 0, void 0, function* () {
2655
2613
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)();
2657
2615
const req = {
2658
2616
runId: publicRunId,
2659
2617
workflowRunBackendId,
@@ -2990,7 +2948,6 @@ class ArtifactHttpClient {
2990
2948
catch (error) {
2991
2949
if (error instanceof SyntaxError) {
2992
2950
(0, core_1.debug)(`Raw Body: ${rawBody}`);
2993
- throw error;
2994
2951
}
2995
2952
if (error instanceof errors_1.UsageError) {
2996
2953
throw error;
@@ -3149,8 +3106,9 @@ function isGhes() {
3149
3106
const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
3150
3107
const hostname = ghUrl.hostname.trimEnd().toUpperCase();
3151
3108
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;
3154
3112
}
3155
3113
exports.isGhes = isGhes;
3156
3114
function getGitHubWorkspaceDir() {
@@ -3361,10 +3319,15 @@ function getBackendIdsFromToken() {
3361
3319
if (publicRunId == null) {
3362
3320
throw new Error("failed to get GITHUB_RUN_ID environment variable");
3363
3321
}
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
+ }
3364
3326
const ids = {
3365
3327
workflowRunBackendId: scopeParts[1],
3366
3328
workflowJobRunBackendId: scopeParts[2],
3367
3329
publicRunId: publicRunId,
3330
+ attemptNo: Number(attemptNo),
3368
3331
};
3369
3332
core.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`);
3370
3333
core.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`);
@@ -3701,6 +3664,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
3701
3664
// create the artifact
3702
3665
const createArtifactReq = {
3703
3666
runId: backendIds.publicRunId,
3667
+ attemptNo: backendIds.attemptNo,
3704
3668
workflowRunBackendId: backendIds.workflowRunBackendId,
3705
3669
workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
3706
3670
name,
@@ -3721,6 +3685,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
3721
3685
// finalize the artifact
3722
3686
const finalizeArtifactReq = {
3723
3687
runId: backendIds.publicRunId,
3688
+ attemptNo: backendIds.attemptNo,
3724
3689
workflowRunBackendId: backendIds.workflowRunBackendId,
3725
3690
workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
3726
3691
name,
@@ -129897,7 +129862,7 @@ exports.unescape = unescape;
129897
129862
/***/ ((module) => {
129898
129863
129899
129864
"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"}}');
129901
129866
129902
129867
/***/ }),
129903
129868
0 commit comments