@@ -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);
@@ -1417,10 +1421,11 @@ class DeleteArtifactRequest$Type extends runtime_5.MessageType {
14171421 { no: 2, name: "workflow_job_run_backend_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
14181422 { no: 3, name: "name", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
14191423 { no: 4, name: "run_id", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
1424+ { no: 5, name: "attempt_no", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
14201425 ]);
14211426 }
14221427 create(value) {
1423- const message = { runId: "", workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" };
1428+ const message = { runId: "", attemptNo: 0, workflowRunBackendId: "", workflowJobRunBackendId: "", name: "" };
14241429 globalThis.Object.defineProperty(message, runtime_4.MESSAGE_TYPE, { enumerable: false, value: this });
14251430 if (value !== undefined)
14261431 (0, runtime_3.reflectionMergePartial)(this, message, value);
@@ -2263,7 +2268,7 @@ exports.deleteArtifactPublic = deleteArtifactPublic;
22632268function deleteArtifactInternal(artifactName) {
22642269 return __awaiter(this, void 0, void 0, function* () {
22652270 const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
2266- const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
2271+ const { publicRunId, attemptNo, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
22672272 const listReq = {
22682273 runId: publicRunId,
22692274 workflowRunBackendId,
@@ -2281,6 +2286,7 @@ function deleteArtifactInternal(artifactName) {
22812286 }
22822287 const req = {
22832288 runId: publicRunId,
2289+ attemptNo: attemptNo,
22842290 workflowRunBackendId: artifact.workflowRunBackendId,
22852291 workflowJobRunBackendId: artifact.workflowJobRunBackendId,
22862292 name: artifact.name
@@ -2340,9 +2346,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23402346Object.defineProperty(exports, "__esModule", ({ value: true }));
23412347exports.downloadArtifactInternal = exports.downloadArtifactPublic = exports.streamExtractExternal = void 0;
23422348const 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));
23462349const github = __importStar(__nccwpck_require__(41962));
23472350const core = __importStar(__nccwpck_require__(42186));
23482351const httpClient = __importStar(__nccwpck_require__(96255));
@@ -2383,11 +2386,8 @@ function streamExtract(url, directory) {
23832386 return;
23842387 }
23852388 catch (error) {
2386- if (error.message.includes('Malformed extraction path')) {
2387- throw new Error(`Artifact download failed with unretryable error: ${error.message}`);
2388- }
23892389 retryCount++;
2390- core.debug (`Failed to download artifact after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`);
2390+ core.error (`Failed to download artifact after ${retryCount} retries due to ${error.message}. Retrying in 5 seconds...`);
23912391 // wait 5 seconds before retrying
23922392 yield new Promise(resolve => setTimeout(resolve, 5000));
23932393 }
@@ -2408,8 +2408,6 @@ function streamExtractExternal(url, directory) {
24082408 response.message.destroy(new Error(`Blob storage chunk did not respond in ${timeout}ms`));
24092409 };
24102410 const timer = setTimeout(timerFn, timeout);
2411- const createdDirectories = new Set();
2412- createdDirectories.add(directory);
24132411 response.message
24142412 .on('data', () => {
24152413 timer.refresh();
@@ -2419,50 +2417,11 @@ function streamExtractExternal(url, directory) {
24192417 clearTimeout(timer);
24202418 reject(error);
24212419 })
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* () {
2420+ .pipe(unzip_stream_1.default.Extract({ path: directory }))
2421+ .on('close', () => {
24632422 clearTimeout(timer);
24642423 resolve();
2465- }))
2424+ })
24662425 .on('error', (error) => {
24672426 reject(error);
24682427 });
@@ -2508,7 +2467,7 @@ function downloadArtifactInternal(artifactId, options) {
25082467 return __awaiter(this, void 0, void 0, function* () {
25092468 const downloadPath = yield resolveOrCreateDirectory(options === null || options === void 0 ? void 0 : options.path);
25102469 const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
2511- const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
2470+ const { publicRunId, attemptNo, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
25122471 const listReq = {
25132472 runId: publicRunId,
25142473 workflowRunBackendId,
@@ -2524,6 +2483,7 @@ function downloadArtifactInternal(artifactId, options) {
25242483 }
25252484 const signedReq = {
25262485 runId: artifacts[0].runId,
2486+ attemptNo: attemptNo,
25272487 workflowRunBackendId: artifacts[0].workflowRunBackendId,
25282488 workflowJobRunBackendId: artifacts[0].workflowJobRunBackendId,
25292489 name: artifacts[0].name
@@ -2653,7 +2613,7 @@ exports.getArtifactPublic = getArtifactPublic;
26532613function getArtifactInternal(artifactName) {
26542614 return __awaiter(this, void 0, void 0, function* () {
26552615 const artifactClient = (0, artifact_twirp_client_1.internalArtifactTwirpClient)();
2656- const { publicRunId, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
2616+ const { publicRunId, attemptNo, workflowRunBackendId, workflowJobRunBackendId } = (0, util_1.getBackendIdsFromToken)();
26572617 const req = {
26582618 runId: publicRunId,
26592619 workflowRunBackendId,
@@ -2990,7 +2950,6 @@ class ArtifactHttpClient {
29902950 catch (error) {
29912951 if (error instanceof SyntaxError) {
29922952 (0, core_1.debug)(`Raw Body: ${rawBody}`);
2993- throw error;
29942953 }
29952954 if (error instanceof errors_1.UsageError) {
29962955 throw error;
@@ -3149,8 +3108,9 @@ function isGhes() {
31493108 const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com');
31503109 const hostname = ghUrl.hostname.trimEnd().toUpperCase();
31513110 const isGitHubHost = hostname === 'GITHUB.COM';
3152- const isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST');
3153- return !isGitHubHost && !isGheHost;
3111+ const isGheHost = hostname.endsWith('.GHE.COM');
3112+ const isLocalHost = hostname.endsWith('.LOCALHOST');
3113+ return !isGitHubHost && !isGheHost && !isLocalHost;
31543114}
31553115exports.isGhes = isGhes;
31563116function getGitHubWorkspaceDir() {
@@ -3361,10 +3321,15 @@ function getBackendIdsFromToken() {
33613321 if (publicRunId == null) {
33623322 throw new Error("failed to get GITHUB_RUN_ID environment variable");
33633323 }
3324+ const attemptNo = process.env["GITHUB_RUN_ATTEMPT"];
3325+ if (attemptNo == null) {
3326+ throw new Error("failed to get GITHUB_RUN_ATTEMPT environment variable");
3327+ }
33643328 const ids = {
33653329 workflowRunBackendId: scopeParts[1],
33663330 workflowJobRunBackendId: scopeParts[2],
33673331 publicRunId: publicRunId,
3332+ attemptNo: Number(attemptNo),
33683333 };
33693334 core.debug(`Workflow Run Backend ID: ${ids.workflowRunBackendId}`);
33703335 core.debug(`Workflow Job Run Backend ID: ${ids.workflowJobRunBackendId}`);
@@ -3701,6 +3666,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
37013666 // create the artifact
37023667 const createArtifactReq = {
37033668 runId: backendIds.publicRunId,
3669+ attemptNo: backendIds.attemptNo,
37043670 workflowRunBackendId: backendIds.workflowRunBackendId,
37053671 workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
37063672 name,
@@ -3721,6 +3687,7 @@ function uploadArtifact(name, files, rootDirectory, options) {
37213687 // finalize the artifact
37223688 const finalizeArtifactReq = {
37233689 runId: backendIds.publicRunId,
3690+ attemptNo: backendIds.attemptNo,
37243691 workflowRunBackendId: backendIds.workflowRunBackendId,
37253692 workflowJobRunBackendId: backendIds.workflowJobRunBackendId,
37263693 name,
@@ -129897,7 +129864,7 @@ exports.unescape = unescape;
129897129864/***/ ((module) => {
129898129865
129899129866"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"}}');
129867+ 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"}}');
129901129868
129902129869/***/ }),
129903129870
0 commit comments