Skip to content

Commit f01fae9

Browse files
Release: v2.0.0 (#355)
## What's Changed * Update to Node 24, default to skipping the cache by @sethvargo in #350 * Bump actions-utils version by @sethvargo in #352 **Full Changelog**: v1.2.2...v2.0.0
1 parent 92b89ba commit f01fae9

13 files changed

+151
-54
lines changed

dist/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export declare function isAuthenticated(): Promise<boolean>;
7070
* specification is installed.
7171
* @returns The path of the installed tool.
7272
*/
73-
export declare function installGcloudSDK(version: string, skipToolCache?: boolean): Promise<string>;
73+
export declare function installGcloudSDK(version: string, useToolCache?: boolean): Promise<string>;
7474
/**
7575
* computeGcloudVersion computes the appropriate gcloud version for the given
7676
* string. If the string is the empty string or the special value "latest", it

dist/index.js

Lines changed: 136 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5755,6 +5755,118 @@ function coerce (version, options) {
57555755
/******/ "use strict";
57565756
/******/ var __webpack_modules__ = ({
57575757

5758+
/***/ 7258:
5759+
/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) {
5760+
5761+
5762+
/*
5763+
* Copyright 2024 Google LLC
5764+
*
5765+
* Licensed under the Apache License, Version 2.0 (the "License");
5766+
* you may not use this file except in compliance with the License.
5767+
* You may obtain a copy of the License at
5768+
*
5769+
* http://www.apache.org/licenses/LICENSE-2.0
5770+
*
5771+
* Unless required by applicable law or agreed to in writing, software
5772+
* distributed under the License is distributed on an "AS IS" BASIS,
5773+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5774+
* See the License for the specific language governing permissions and
5775+
* limitations under the License.
5776+
*/
5777+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
5778+
if (k2 === undefined) k2 = k;
5779+
var desc = Object.getOwnPropertyDescriptor(m, k);
5780+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5781+
desc = { enumerable: true, get: function() { return m[k]; } };
5782+
}
5783+
Object.defineProperty(o, k2, desc);
5784+
}) : (function(o, m, k, k2) {
5785+
if (k2 === undefined) k2 = k;
5786+
o[k2] = m[k];
5787+
}));
5788+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
5789+
Object.defineProperty(o, "default", { enumerable: true, value: v });
5790+
}) : function(o, v) {
5791+
o["default"] = v;
5792+
});
5793+
var __importStar = (this && this.__importStar) || (function () {
5794+
var ownKeys = function(o) {
5795+
ownKeys = Object.getOwnPropertyNames || function (o) {
5796+
var ar = [];
5797+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
5798+
return ar;
5799+
};
5800+
return ownKeys(o);
5801+
};
5802+
return function (mod) {
5803+
if (mod && mod.__esModule) return mod;
5804+
var result = {};
5805+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
5806+
__setModuleDefault(result, mod);
5807+
return result;
5808+
};
5809+
})();
5810+
Object.defineProperty(exports, "__esModule", ({ value: true }));
5811+
exports.actionsGenReadme = actionsGenReadme;
5812+
const promises_1 = __nccwpck_require2_(1943);
5813+
const YAML = __importStar(__nccwpck_require2_(8815));
5814+
/**
5815+
* actionsGenReadme parses the action.yml file and auto-generates README.md
5816+
* inputs and outputs in a consistent format.
5817+
*/
5818+
async function actionsGenReadme(dir = '') {
5819+
// For testing
5820+
if (dir) {
5821+
process.chdir(dir);
5822+
}
5823+
const readmeContents = (await (0, promises_1.readFile)('README.md', 'utf8')).split('\n');
5824+
const actionContents = await (0, promises_1.readFile)('action.yml', 'utf8');
5825+
const action = YAML.parse(actionContents);
5826+
const actionInputs = Object.entries(action.inputs || {});
5827+
if (actionInputs.length === 0)
5828+
console.warn(`action.yml inputs are empty`);
5829+
const inputs = [];
5830+
for (const [input, opts] of actionInputs) {
5831+
const required = opts.required ? 'Required' : 'Optional';
5832+
const description = (opts.description || '')
5833+
.split('\n')
5834+
.map((line) => (line.trim() === '' ? '' : ` ${line}`))
5835+
.join('\n')
5836+
.trim();
5837+
if (description === '') {
5838+
throw new Error(`Input "${input}" is missing a description`);
5839+
}
5840+
const def = opts.default ? `, default: \`${opts.default}\`` : '';
5841+
inputs.push(`- <a name="__input_${input}"></a><a href="#user-content-__input_${input}"><code>${input}</code></a>: _(${required}${def})_ ${description}\n`);
5842+
}
5843+
const startInputs = readmeContents.indexOf('<!-- BEGIN_AUTOGEN_INPUTS -->');
5844+
const endInputs = readmeContents.indexOf('<!-- END_AUTOGEN_INPUTS -->');
5845+
readmeContents.splice(startInputs + 1, endInputs - startInputs - 1, '', ...inputs, '');
5846+
const actionOutputs = Object.entries(action.outputs || {});
5847+
if (actionOutputs.length === 0)
5848+
console.warn(`action.yml outputs are empty`);
5849+
const outputs = [];
5850+
for (const [output, opts] of actionOutputs) {
5851+
const description = (opts?.description || '')
5852+
.split('\n')
5853+
.map((line) => (line.trim() === '' ? '' : ` ${line}`))
5854+
.join('\n')
5855+
.trim();
5856+
if (description === '') {
5857+
throw new Error(`Output "${output}" is missing a description`);
5858+
}
5859+
outputs.push(`- <a name="__output_${output}"></a><a href="#user-content-__output_${output}"><code>${output}</code></a>: ${description}\n`);
5860+
}
5861+
const startOutputs = readmeContents.indexOf('<!-- BEGIN_AUTOGEN_OUTPUTS -->');
5862+
const endOutputs = readmeContents.indexOf('<!-- END_AUTOGEN_OUTPUTS -->');
5863+
readmeContents.splice(startOutputs + 1, endOutputs - startOutputs - 1, '', ...outputs, '');
5864+
await (0, promises_1.writeFile)('README.md', readmeContents.join('\n'), 'utf8');
5865+
}
5866+
5867+
5868+
/***/ }),
5869+
57585870
/***/ 9081:
57595871
/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => {
57605872

@@ -6406,7 +6518,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
64066518
exports.forceRemove = forceRemove;
64076519
exports.isEmptyDir = isEmptyDir;
64086520
exports.writeSecureFile = writeSecureFile;
6409-
exports.removeFile = removeFile;
64106521
const fs_1 = __nccwpck_require2_(9896);
64116522
const errors_1 = __nccwpck_require2_(3916);
64126523
/**
@@ -6461,29 +6572,6 @@ async function writeSecureFile(outputPath, data, options) {
64616572
await fs_1.promises.writeFile(outputPath, data, opts);
64626573
return outputPath;
64636574
}
6464-
/**
6465-
* removeFile removes the file at the given path. If the file does not exist, it
6466-
* does nothing.
6467-
*
6468-
* @param filePath Path of the file on disk to delete.
6469-
*
6470-
* @returns A boolean, true if the file was deleted, false otherwise.
6471-
*
6472-
* @deprecated Use #forceRemove instead.
6473-
*/
6474-
async function removeFile(filePath) {
6475-
try {
6476-
await fs_1.promises.unlink(filePath);
6477-
return true;
6478-
}
6479-
catch (err) {
6480-
if ((0, errors_1.isNotFoundError)(err)) {
6481-
return false;
6482-
}
6483-
const msg = (0, errors_1.errorMessage)(err);
6484-
throw new Error(`Failed to remove "${filePath}": ${msg}`);
6485-
}
6486-
}
64876575

64886576

64896577
/***/ }),
@@ -6608,6 +6696,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
66086696
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
66096697
};
66106698
Object.defineProperty(exports, "__esModule", ({ value: true }));
6699+
__exportStar(__nccwpck_require2_(7258), exports);
66116700
__exportStar(__nccwpck_require2_(9081), exports);
66126701
__exportStar(__nccwpck_require2_(3214), exports);
66136702
__exportStar(__nccwpck_require2_(731), exports);
@@ -7630,6 +7719,13 @@ module.exports = __nccwpck_require__(9896);
76307719

76317720
/***/ }),
76327721

7722+
/***/ 1943:
7723+
/***/ ((module) => {
7724+
7725+
module.exports = __nccwpck_require__(1943);
7726+
7727+
/***/ }),
7728+
76337729
/***/ 4589:
76347730
/***/ ((module) => {
76357731

@@ -41738,7 +41834,7 @@ async function isAuthenticated() {
4173841834
* specification is installed.
4173941835
* @returns The path of the installed tool.
4174041836
*/
41741-
async function installGcloudSDK(version, skipToolCache) {
41837+
async function installGcloudSDK(version, useToolCache = false) {
4174241838
// Retrieve the release corresponding to the specified version and OS
4174341839
const osPlat = os.platform();
4174441840
const osArch = os.arch();
@@ -41752,24 +41848,25 @@ async function installGcloudSDK(version, skipToolCache) {
4175241848
throw new Error(`Failed to download release, url: ${url}`);
4175341849
}
4175441850
// Either cache the tool or just add it directly to the path.
41755-
if (skipToolCache) {
41756-
// Caching the tool on disk takes a really long time, and it's not clear
41757-
// whether it's even valuable since it's ONLY cached on disk on the runner.
41758-
// For GitHub-managed runners, that is useless since they are ephemeral.
41759-
//
41760-
// See https://github.com/google-github-actions/setup-gcloud/issues/701 for
41761-
// discussion, but it's actually faster to skip the caching and just add the
41762-
// tool directly to the path.
41763-
const toolRoot = path.join(extPath, 'google-cloud-sdk');
41764-
core.addPath(path.join(toolRoot, 'bin'));
41765-
return toolRoot;
41766-
}
41767-
else {
41851+
//
41852+
// Caching the tool on disk takes a really long time, and it's not clear
41853+
// whether it's even valuable since it's ONLY cached on disk on the runner.
41854+
// For GitHub-managed runners, that is useless since they are ephemeral.
41855+
//
41856+
// See https://github.com/google-github-actions/setup-gcloud/issues/701 for
41857+
// discussion, but it's actually faster to skip the caching and just add the
41858+
// tool directly to the path.
41859+
if (useToolCache) {
4176841860
const toolRoot = path.join(extPath, 'google-cloud-sdk');
4176941861
const cachedToolRoot = await toolCache.cacheDir(toolRoot, 'gcloud', resolvedVersion, osArch);
4177041862
core.addPath(path.join(cachedToolRoot, 'bin'));
4177141863
return cachedToolRoot;
4177241864
}
41865+
else {
41866+
const toolRoot = path.join(extPath, 'google-cloud-sdk');
41867+
core.addPath(path.join(toolRoot, 'bin'));
41868+
return toolRoot;
41869+
}
4177341870
}
4177441871
/**
4177541872
* computeGcloudVersion computes the appropriate gcloud version for the given
@@ -43928,7 +44025,7 @@ module.exports = parseParams
4392844025
/***/ ((module) => {
4392944026

4393044027
"use strict";
43931-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@google-github-actions/setup-cloud-sdk","version":"1.2.2","description":"Utilities to download, install, and interact with the Cloud SDK for GitHub Actions","module":"dist/index.js","main":"dist/index.js","types":"dist/index.d.js","engines":{"node":">= 20.x","npm":">= 10.x"},"scripts":{"build":"rm -rf dist/ && ncc build --source-map --no-source-map-register src/index.ts","lint":"eslint .","format":"eslint --fix","docs":"rm -rf docs/ && typedoc --plugin typedoc-plugin-markdown","test":"node --require ts-node/register --test-reporter spec --test tests/download-util.test.ts tests/format-url.test.ts tests/index.test.ts"},"files":["dist/**/*"],"repository":{"type":"git","url":"git+https://github.com/google-github-actions/setup-cloud-sdk.git"},"keywords":["Cloud SDK","google cloud","gcloud"],"author":"Google LLC","license":"Apache-2.0","dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.1.1","@actions/http-client":"^2.2.3","@actions/tool-cache":"^2.0.2","@google-github-actions/actions-utils":"^0.8.9","semver":"^7.7.2"},"devDependencies":{"@eslint/eslintrc":"^3.3.1","@eslint/js":"^9.34.0","@types/node":"^24.3.0","@types/semver":"^7.7.0","@typescript-eslint/eslint-plugin":"^8.40.0","@vercel/ncc":"^0.38.3","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","eslint":"^9.34.0","prettier":"^3.6.2","ts-node":"^10.9.2","typedoc-plugin-markdown":"^4.8.1","typedoc":"^0.28.10","typescript-eslint":"^8.40.0","typescript":"^5.9.2"}}');
44028+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@google-github-actions/setup-cloud-sdk","version":"2.0.0","description":"Utilities to download, install, and interact with the Cloud SDK for GitHub Actions","module":"dist/index.js","main":"dist/index.js","types":"dist/index.d.js","engines":{"node":">= 24.x","npm":">= 11.x"},"scripts":{"build":"rm -rf dist/ && ncc build --source-map --no-source-map-register src/index.ts","lint":"eslint .","format":"eslint --fix","docs":"rm -rf docs/ && typedoc --plugin typedoc-plugin-markdown","test":"node --require ts-node/register --test-reporter spec --test tests/**/*.test.ts"},"files":["dist/**/*"],"repository":{"type":"git","url":"git+https://github.com/google-github-actions/setup-cloud-sdk.git"},"keywords":["Cloud SDK","google cloud","gcloud"],"author":"Google LLC","license":"Apache-2.0","dependencies":{"@actions/core":"^1.11.1","@actions/exec":"^1.1.1","@actions/http-client":"^2.2.3","@actions/tool-cache":"^2.0.2","@google-github-actions/actions-utils":"^1.0.1","semver":"^7.7.2"},"devDependencies":{"@eslint/eslintrc":"^3.3.1","@eslint/js":"^9.34.0","@types/node":"^24.3.0","@types/semver":"^7.7.0","@typescript-eslint/eslint-plugin":"^8.40.0","@vercel/ncc":"^0.38.3","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","eslint":"^9.34.0","prettier":"^3.6.2","ts-node":"^10.9.2","typedoc-plugin-markdown":"^4.8.1","typedoc":"^0.28.10","typescript-eslint":"^8.40.0","typescript":"^5.9.2"}}');
4393244029

4393344030
/***/ })
4393444031

dist/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.

docs/index/functions/authenticateGcloudSDK.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **authenticateGcloudSDK**(`filepath`): `Promise`\<`void`\>
1010
11-
Defined in: [index.ts:235](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L235)
11+
Defined in: [index.ts:239](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L239)
1212

1313
Authenticates the gcloud tool using the provided credentials file.
1414

docs/index/functions/bestVersion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **bestVersion**(`spec`): `Promise`\<`string`\>
1010
11-
Defined in: [index.ts:282](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L282)
11+
Defined in: [index.ts:286](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L286)
1212

1313
bestVersion takes a version constraint and gets the latest available version
1414
that satisfies the constraint.

docs/index/functions/computeBestVersion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **computeBestVersion**(`spec`, `versions`): `string`
1010
11-
Defined in: [index.ts:321](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L321)
11+
Defined in: [index.ts:325](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L325)
1212

1313
computeBestVersion computes the latest available version that still satisfies
1414
the spec. This is a helper function and is only exported for testing.

docs/index/functions/computeGcloudVersion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **computeGcloudVersion**(`version?`): `Promise`\<`string`\>
1010
11-
Defined in: [index.ts:222](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L222)
11+
Defined in: [index.ts:226](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L226)
1212

1313
computeGcloudVersion computes the appropriate gcloud version for the given
1414
string. If the string is the empty string or the special value "latest", it

docs/index/functions/getLatestGcloudSDKVersion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **getLatestGcloudSDKVersion**(): `Promise`\<`string`\>
1010
11-
Defined in: [index.ts:271](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L271)
11+
Defined in: [index.ts:275](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L275)
1212

1313
getLatestGcloudSDKVersion fetches the latest version number from the API.
1414

docs/index/functions/installComponent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> **installComponent**(`component`): `Promise`\<`void`\>
1010
11-
Defined in: [index.ts:255](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L255)
11+
Defined in: [index.ts:259](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L259)
1212

1313
Install a Cloud SDK component.
1414

docs/index/functions/installGcloudSDK.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
# Function: installGcloudSDK()
88

9-
> **installGcloudSDK**(`version`, `skipToolCache?`): `Promise`\<`string`\>
9+
> **installGcloudSDK**(`version`, `useToolCache`): `Promise`\<`string`\>
1010
1111
Defined in: [index.ts:168](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L168)
1212

@@ -22,9 +22,9 @@ The version or version specification to install. If a
2222
specification is given, the most recent version that still matches the
2323
specification is installed.
2424

25-
### skipToolCache?
25+
### useToolCache
2626

27-
`boolean`
27+
`boolean` = `false`
2828

2929
## Returns
3030

0 commit comments

Comments
 (0)