Skip to content

Commit f263902

Browse files
authored
Add .exe on windows (#83)
1 parent 14421f5 commit f263902

File tree

5 files changed

+204
-14
lines changed

5 files changed

+204
-14
lines changed

dist/main/index.js

Lines changed: 101 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
393393
};
394394
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
395395
if (!response.ok) {
396-
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
396+
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
397397
return undefined;
398398
}
399399
core.info(`Cache hit for: ${request.key}`);
@@ -585,12 +585,20 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
585585
key,
586586
version
587587
};
588-
const response = yield twirpClient.CreateCacheEntry(request);
589-
if (!response.ok) {
588+
let signedUploadUrl;
589+
try {
590+
const response = yield twirpClient.CreateCacheEntry(request);
591+
if (!response.ok) {
592+
throw new Error('Response was not ok');
593+
}
594+
signedUploadUrl = response.signedUploadUrl;
595+
}
596+
catch (error) {
597+
core.debug(`Failed to reserve cache: ${error}`);
590598
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
591599
}
592600
core.debug(`Attempting to upload cache located at: ${archivePath}`);
593-
yield cacheHttpClient.saveCache(cacheId, archivePath, response.signedUploadUrl, options);
601+
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
594602
const finalizeRequest = {
595603
key,
596604
version,
@@ -2369,6 +2377,7 @@ const cacheUtils_1 = __nccwpck_require__(680);
23692377
const auth_1 = __nccwpck_require__(4552);
23702378
const http_client_1 = __nccwpck_require__(4844);
23712379
const cache_twirp_client_1 = __nccwpck_require__(1486);
2380+
const util_1 = __nccwpck_require__(7564);
23722381
/**
23732382
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
23742383
*
@@ -2428,6 +2437,7 @@ class CacheServiceClient {
24282437
(0, core_1.debug)(`[Response] - ${response.message.statusCode}`);
24292438
(0, core_1.debug)(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`);
24302439
const body = JSON.parse(rawBody);
2440+
(0, util_1.maskSecretUrls)(body);
24312441
(0, core_1.debug)(`Body: ${JSON.stringify(body, null, 2)}`);
24322442
if (this.isSuccessStatusCode(statusCode)) {
24332443
return { response, body };
@@ -2609,6 +2619,87 @@ exports.getUserAgentString = getUserAgentString;
26092619

26102620
/***/ }),
26112621

2622+
/***/ 7564:
2623+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2624+
2625+
"use strict";
2626+
2627+
Object.defineProperty(exports, "__esModule", ({ value: true }));
2628+
exports.maskSecretUrls = exports.maskSigUrl = void 0;
2629+
const core_1 = __nccwpck_require__(7484);
2630+
/**
2631+
* Masks the `sig` parameter in a URL and sets it as a secret.
2632+
*
2633+
* @param url - The URL containing the signature parameter to mask
2634+
* @remarks
2635+
* This function attempts to parse the provided URL and identify the 'sig' query parameter.
2636+
* If found, it registers both the raw and URL-encoded signature values as secrets using
2637+
* the Actions `setSecret` API, which prevents them from being displayed in logs.
2638+
*
2639+
* The function handles errors gracefully if URL parsing fails, logging them as debug messages.
2640+
*
2641+
* @example
2642+
* ```typescript
2643+
* // Mask a signature in an Azure SAS token URL
2644+
* maskSigUrl('https://example.blob.core.windows.net/container/file.txt?sig=abc123&se=2023-01-01');
2645+
* ```
2646+
*/
2647+
function maskSigUrl(url) {
2648+
if (!url)
2649+
return;
2650+
try {
2651+
const parsedUrl = new URL(url);
2652+
const signature = parsedUrl.searchParams.get('sig');
2653+
if (signature) {
2654+
(0, core_1.setSecret)(signature);
2655+
(0, core_1.setSecret)(encodeURIComponent(signature));
2656+
}
2657+
}
2658+
catch (error) {
2659+
(0, core_1.debug)(`Failed to parse URL: ${url} ${error instanceof Error ? error.message : String(error)}`);
2660+
}
2661+
}
2662+
exports.maskSigUrl = maskSigUrl;
2663+
/**
2664+
* Masks sensitive information in URLs containing signature parameters.
2665+
* Currently supports masking 'sig' parameters in the 'signed_upload_url'
2666+
* and 'signed_download_url' properties of the provided object.
2667+
*
2668+
* @param body - The object should contain a signature
2669+
* @remarks
2670+
* This function extracts URLs from the object properties and calls maskSigUrl
2671+
* on each one to redact sensitive signature information. The function doesn't
2672+
* modify the original object; it only marks the signatures as secrets for
2673+
* logging purposes.
2674+
*
2675+
* @example
2676+
* ```typescript
2677+
* const responseBody = {
2678+
* signed_upload_url: 'https://blob.core.windows.net/?sig=abc123',
2679+
* signed_download_url: 'https://blob.core/windows.net/?sig=def456'
2680+
* };
2681+
* maskSecretUrls(responseBody);
2682+
* ```
2683+
*/
2684+
function maskSecretUrls(body) {
2685+
if (typeof body !== 'object' || body === null) {
2686+
(0, core_1.debug)('body is not an object or is null');
2687+
return;
2688+
}
2689+
if ('signed_upload_url' in body &&
2690+
typeof body.signed_upload_url === 'string') {
2691+
maskSigUrl(body.signed_upload_url);
2692+
}
2693+
if ('signed_download_url' in body &&
2694+
typeof body.signed_download_url === 'string') {
2695+
maskSigUrl(body.signed_download_url);
2696+
}
2697+
}
2698+
exports.maskSecretUrls = maskSecretUrls;
2699+
//# sourceMappingURL=util.js.map
2700+
2701+
/***/ }),
2702+
26122703
/***/ 5321:
26132704
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
26142705

@@ -103122,7 +103213,7 @@ exports.visitAsync = visitAsync;
103122103213
/***/ ((module) => {
103123103214

103124103215
"use strict";
103125-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.1","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.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/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
103216+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.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/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
103126103217

103127103218
/***/ }),
103128103219

@@ -103279,7 +103370,11 @@ async function downloadBazelisk() {
103279103370

103280103371
core.debug('Adding to the cache...');
103281103372
fs.chmodSync(downloadPath, '755');
103282-
const cachePath = await tc.cacheFile(downloadPath, 'bazel', 'bazelisk', version)
103373+
let bazel_name = "bazel";
103374+
if (platform == 'windows') {
103375+
bazel_name = `${bazel_name}.exe`
103376+
}
103377+
const cachePath = await tc.cacheFile(downloadPath, bazel_name, 'bazelisk', version)
103283103378
core.debug(`Successfully cached bazelisk to ${cachePath}`)
103284103379

103285103380
return cachePath

dist/main/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/post/index.js

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ function restoreCacheV2(paths, primaryKey, restoreKeys, options, enableCrossOsAr
393393
};
394394
const response = yield twirpClient.GetCacheEntryDownloadURL(request);
395395
if (!response.ok) {
396-
core.debug(`Cache not found for keys: ${keys.join(', ')}`);
396+
core.debug(`Cache not found for version ${request.version} of keys: ${keys.join(', ')}`);
397397
return undefined;
398398
}
399399
core.info(`Cache hit for: ${request.key}`);
@@ -585,12 +585,20 @@ function saveCacheV2(paths, key, options, enableCrossOsArchive = false) {
585585
key,
586586
version
587587
};
588-
const response = yield twirpClient.CreateCacheEntry(request);
589-
if (!response.ok) {
588+
let signedUploadUrl;
589+
try {
590+
const response = yield twirpClient.CreateCacheEntry(request);
591+
if (!response.ok) {
592+
throw new Error('Response was not ok');
593+
}
594+
signedUploadUrl = response.signedUploadUrl;
595+
}
596+
catch (error) {
597+
core.debug(`Failed to reserve cache: ${error}`);
590598
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache.`);
591599
}
592600
core.debug(`Attempting to upload cache located at: ${archivePath}`);
593-
yield cacheHttpClient.saveCache(cacheId, archivePath, response.signedUploadUrl, options);
601+
yield cacheHttpClient.saveCache(cacheId, archivePath, signedUploadUrl, options);
594602
const finalizeRequest = {
595603
key,
596604
version,
@@ -2369,6 +2377,7 @@ const cacheUtils_1 = __nccwpck_require__(680);
23692377
const auth_1 = __nccwpck_require__(4552);
23702378
const http_client_1 = __nccwpck_require__(4844);
23712379
const cache_twirp_client_1 = __nccwpck_require__(1486);
2380+
const util_1 = __nccwpck_require__(7564);
23722381
/**
23732382
* This class is a wrapper around the CacheServiceClientJSON class generated by Twirp.
23742383
*
@@ -2428,6 +2437,7 @@ class CacheServiceClient {
24282437
(0, core_1.debug)(`[Response] - ${response.message.statusCode}`);
24292438
(0, core_1.debug)(`Headers: ${JSON.stringify(response.message.headers, null, 2)}`);
24302439
const body = JSON.parse(rawBody);
2440+
(0, util_1.maskSecretUrls)(body);
24312441
(0, core_1.debug)(`Body: ${JSON.stringify(body, null, 2)}`);
24322442
if (this.isSuccessStatusCode(statusCode)) {
24332443
return { response, body };
@@ -2609,6 +2619,87 @@ exports.getUserAgentString = getUserAgentString;
26092619

26102620
/***/ }),
26112621

2622+
/***/ 7564:
2623+
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
2624+
2625+
"use strict";
2626+
2627+
Object.defineProperty(exports, "__esModule", ({ value: true }));
2628+
exports.maskSecretUrls = exports.maskSigUrl = void 0;
2629+
const core_1 = __nccwpck_require__(7484);
2630+
/**
2631+
* Masks the `sig` parameter in a URL and sets it as a secret.
2632+
*
2633+
* @param url - The URL containing the signature parameter to mask
2634+
* @remarks
2635+
* This function attempts to parse the provided URL and identify the 'sig' query parameter.
2636+
* If found, it registers both the raw and URL-encoded signature values as secrets using
2637+
* the Actions `setSecret` API, which prevents them from being displayed in logs.
2638+
*
2639+
* The function handles errors gracefully if URL parsing fails, logging them as debug messages.
2640+
*
2641+
* @example
2642+
* ```typescript
2643+
* // Mask a signature in an Azure SAS token URL
2644+
* maskSigUrl('https://example.blob.core.windows.net/container/file.txt?sig=abc123&se=2023-01-01');
2645+
* ```
2646+
*/
2647+
function maskSigUrl(url) {
2648+
if (!url)
2649+
return;
2650+
try {
2651+
const parsedUrl = new URL(url);
2652+
const signature = parsedUrl.searchParams.get('sig');
2653+
if (signature) {
2654+
(0, core_1.setSecret)(signature);
2655+
(0, core_1.setSecret)(encodeURIComponent(signature));
2656+
}
2657+
}
2658+
catch (error) {
2659+
(0, core_1.debug)(`Failed to parse URL: ${url} ${error instanceof Error ? error.message : String(error)}`);
2660+
}
2661+
}
2662+
exports.maskSigUrl = maskSigUrl;
2663+
/**
2664+
* Masks sensitive information in URLs containing signature parameters.
2665+
* Currently supports masking 'sig' parameters in the 'signed_upload_url'
2666+
* and 'signed_download_url' properties of the provided object.
2667+
*
2668+
* @param body - The object should contain a signature
2669+
* @remarks
2670+
* This function extracts URLs from the object properties and calls maskSigUrl
2671+
* on each one to redact sensitive signature information. The function doesn't
2672+
* modify the original object; it only marks the signatures as secrets for
2673+
* logging purposes.
2674+
*
2675+
* @example
2676+
* ```typescript
2677+
* const responseBody = {
2678+
* signed_upload_url: 'https://blob.core.windows.net/?sig=abc123',
2679+
* signed_download_url: 'https://blob.core/windows.net/?sig=def456'
2680+
* };
2681+
* maskSecretUrls(responseBody);
2682+
* ```
2683+
*/
2684+
function maskSecretUrls(body) {
2685+
if (typeof body !== 'object' || body === null) {
2686+
(0, core_1.debug)('body is not an object or is null');
2687+
return;
2688+
}
2689+
if ('signed_upload_url' in body &&
2690+
typeof body.signed_upload_url === 'string') {
2691+
maskSigUrl(body.signed_upload_url);
2692+
}
2693+
if ('signed_download_url' in body &&
2694+
typeof body.signed_download_url === 'string') {
2695+
maskSigUrl(body.signed_download_url);
2696+
}
2697+
}
2698+
exports.maskSecretUrls = maskSecretUrls;
2699+
//# sourceMappingURL=util.js.map
2700+
2701+
/***/ }),
2702+
26122703
/***/ 5321:
26132704
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
26142705

@@ -102269,7 +102360,7 @@ exports.visitAsync = visitAsync;
102269102360
/***/ ((module) => {
102270102361

102271102362
"use strict";
102272-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.1","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.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/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
102363+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@actions/cache","version":"4.0.3","preview":true,"description":"Actions cache lib","keywords":["github","actions","cache"],"homepage":"https://github.com/actions/toolkit/tree/main/packages/cache","license":"MIT","main":"lib/cache.js","types":"lib/cache.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/cache"},"scripts":{"audit-moderate":"npm install && npm audit --json --audit-level=moderate > audit.json","test":"echo \\"Error: run tests from root\\" && exit 1","tsc":"tsc"},"bugs":{"url":"https://github.com/actions/toolkit/issues"},"dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.0.1","@actions/glob":"^0.1.0","@actions/http-client":"^2.1.1","@actions/io":"^1.0.1","@azure/abort-controller":"^1.1.0","@azure/ms-rest-js":"^2.6.0","@azure/storage-blob":"^12.13.0","@protobuf-ts/plugin":"^2.9.4","semver":"^6.3.1"},"devDependencies":{"@types/node":"^22.13.9","@types/semver":"^6.0.0","typescript":"^5.2.2"}}');
102273102364

102274102365
/***/ }),
102275102366

dist/post/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ async function downloadBazelisk() {
9696

9797
core.debug('Adding to the cache...');
9898
fs.chmodSync(downloadPath, '755');
99-
const cachePath = await tc.cacheFile(downloadPath, 'bazel', 'bazelisk', version)
99+
let bazel_name = "bazel";
100+
if (platform == 'windows') {
101+
bazel_name = `${bazel_name}.exe`
102+
}
103+
const cachePath = await tc.cacheFile(downloadPath, bazel_name, 'bazelisk', version)
100104
core.debug(`Successfully cached bazelisk to ${cachePath}`)
101105

102106
return cachePath

0 commit comments

Comments
 (0)