Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export declare function isAuthenticated(): Promise<boolean>;
* specification is installed.
* @returns The path of the installed tool.
*/
export declare function installGcloudSDK(version: string, skipToolCache?: boolean): Promise<string>;
export declare function installGcloudSDK(version: string, useToolCache?: boolean): Promise<string>;
/**
* computeGcloudVersion computes the appropriate gcloud version for the given
* string. If the string is the empty string or the special value "latest", it
Expand Down
175 changes: 136 additions & 39 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5755,6 +5755,118 @@ function coerce (version, options) {
/******/ "use strict";
/******/ var __webpack_modules__ = ({

/***/ 7258:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) {


/*
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.actionsGenReadme = actionsGenReadme;
const promises_1 = __nccwpck_require2_(1943);
const YAML = __importStar(__nccwpck_require2_(8815));
/**
* actionsGenReadme parses the action.yml file and auto-generates README.md
* inputs and outputs in a consistent format.
*/
async function actionsGenReadme(dir = '') {
// For testing
if (dir) {
process.chdir(dir);
}
const readmeContents = (await (0, promises_1.readFile)('README.md', 'utf8')).split('\n');
const actionContents = await (0, promises_1.readFile)('action.yml', 'utf8');
const action = YAML.parse(actionContents);
const actionInputs = Object.entries(action.inputs || {});
if (actionInputs.length === 0)
console.warn(`action.yml inputs are empty`);
const inputs = [];
for (const [input, opts] of actionInputs) {
const required = opts.required ? 'Required' : 'Optional';
const description = (opts.description || '')
.split('\n')
.map((line) => (line.trim() === '' ? '' : ` ${line}`))
.join('\n')
.trim();
if (description === '') {
throw new Error(`Input "${input}" is missing a description`);
}
const def = opts.default ? `, default: \`${opts.default}\`` : '';
inputs.push(`- <a name="__input_${input}"></a><a href="#user-content-__input_${input}"><code>${input}</code></a>: _(${required}${def})_ ${description}\n`);
}
const startInputs = readmeContents.indexOf('<!-- BEGIN_AUTOGEN_INPUTS -->');
const endInputs = readmeContents.indexOf('<!-- END_AUTOGEN_INPUTS -->');
readmeContents.splice(startInputs + 1, endInputs - startInputs - 1, '', ...inputs, '');
const actionOutputs = Object.entries(action.outputs || {});
if (actionOutputs.length === 0)
console.warn(`action.yml outputs are empty`);
const outputs = [];
for (const [output, opts] of actionOutputs) {
const description = (opts?.description || '')
.split('\n')
.map((line) => (line.trim() === '' ? '' : ` ${line}`))
.join('\n')
.trim();
if (description === '') {
throw new Error(`Output "${output}" is missing a description`);
}
outputs.push(`- <a name="__output_${output}"></a><a href="#user-content-__output_${output}"><code>${output}</code></a>: ${description}\n`);
}
const startOutputs = readmeContents.indexOf('<!-- BEGIN_AUTOGEN_OUTPUTS -->');
const endOutputs = readmeContents.indexOf('<!-- END_AUTOGEN_OUTPUTS -->');
readmeContents.splice(startOutputs + 1, endOutputs - startOutputs - 1, '', ...outputs, '');
await (0, promises_1.writeFile)('README.md', readmeContents.join('\n'), 'utf8');
}


/***/ }),

/***/ 9081:
/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => {

Expand Down Expand Up @@ -6406,7 +6518,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.forceRemove = forceRemove;
exports.isEmptyDir = isEmptyDir;
exports.writeSecureFile = writeSecureFile;
exports.removeFile = removeFile;
const fs_1 = __nccwpck_require2_(9896);
const errors_1 = __nccwpck_require2_(3916);
/**
Expand Down Expand Up @@ -6461,29 +6572,6 @@ async function writeSecureFile(outputPath, data, options) {
await fs_1.promises.writeFile(outputPath, data, opts);
return outputPath;
}
/**
* removeFile removes the file at the given path. If the file does not exist, it
* does nothing.
*
* @param filePath Path of the file on disk to delete.
*
* @returns A boolean, true if the file was deleted, false otherwise.
*
* @deprecated Use #forceRemove instead.
*/
async function removeFile(filePath) {
try {
await fs_1.promises.unlink(filePath);
return true;
}
catch (err) {
if ((0, errors_1.isNotFoundError)(err)) {
return false;
}
const msg = (0, errors_1.errorMessage)(err);
throw new Error(`Failed to remove "${filePath}": ${msg}`);
}
}


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

/***/ }),

/***/ 1943:
/***/ ((module) => {

module.exports = __nccwpck_require__(1943);

/***/ }),

/***/ 4589:
/***/ ((module) => {

Expand Down Expand Up @@ -41738,7 +41834,7 @@ async function isAuthenticated() {
* specification is installed.
* @returns The path of the installed tool.
*/
async function installGcloudSDK(version, skipToolCache) {
async function installGcloudSDK(version, useToolCache = false) {
// Retrieve the release corresponding to the specified version and OS
const osPlat = os.platform();
const osArch = os.arch();
Expand All @@ -41752,24 +41848,25 @@ async function installGcloudSDK(version, skipToolCache) {
throw new Error(`Failed to download release, url: ${url}`);
}
// Either cache the tool or just add it directly to the path.
if (skipToolCache) {
// Caching the tool on disk takes a really long time, and it's not clear
// whether it's even valuable since it's ONLY cached on disk on the runner.
// For GitHub-managed runners, that is useless since they are ephemeral.
//
// See https://github.com/google-github-actions/setup-gcloud/issues/701 for
// discussion, but it's actually faster to skip the caching and just add the
// tool directly to the path.
const toolRoot = path.join(extPath, 'google-cloud-sdk');
core.addPath(path.join(toolRoot, 'bin'));
return toolRoot;
}
else {
//
// Caching the tool on disk takes a really long time, and it's not clear
// whether it's even valuable since it's ONLY cached on disk on the runner.
// For GitHub-managed runners, that is useless since they are ephemeral.
//
// See https://github.com/google-github-actions/setup-gcloud/issues/701 for
// discussion, but it's actually faster to skip the caching and just add the
// tool directly to the path.
if (useToolCache) {
const toolRoot = path.join(extPath, 'google-cloud-sdk');
const cachedToolRoot = await toolCache.cacheDir(toolRoot, 'gcloud', resolvedVersion, osArch);
core.addPath(path.join(cachedToolRoot, 'bin'));
return cachedToolRoot;
}
else {
const toolRoot = path.join(extPath, 'google-cloud-sdk');
core.addPath(path.join(toolRoot, 'bin'));
return toolRoot;
}
}
/**
* computeGcloudVersion computes the appropriate gcloud version for the given
Expand Down Expand Up @@ -43928,7 +44025,7 @@ module.exports = parseParams
/***/ ((module) => {

"use strict";
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"}}');
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"}}');

/***/ })

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index/functions/authenticateGcloudSDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **authenticateGcloudSDK**(`filepath`): `Promise`\<`void`\>

Defined in: [index.ts:235](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L235)
Defined in: [index.ts:239](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L239)

Authenticates the gcloud tool using the provided credentials file.

Expand Down
2 changes: 1 addition & 1 deletion docs/index/functions/bestVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **bestVersion**(`spec`): `Promise`\<`string`\>

Defined in: [index.ts:282](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L282)
Defined in: [index.ts:286](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L286)

bestVersion takes a version constraint and gets the latest available version
that satisfies the constraint.
Expand Down
2 changes: 1 addition & 1 deletion docs/index/functions/computeBestVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **computeBestVersion**(`spec`, `versions`): `string`

Defined in: [index.ts:321](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L321)
Defined in: [index.ts:325](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L325)

computeBestVersion computes the latest available version that still satisfies
the spec. This is a helper function and is only exported for testing.
Expand Down
2 changes: 1 addition & 1 deletion docs/index/functions/computeGcloudVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **computeGcloudVersion**(`version?`): `Promise`\<`string`\>

Defined in: [index.ts:222](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L222)
Defined in: [index.ts:226](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L226)

computeGcloudVersion computes the appropriate gcloud version for the given
string. If the string is the empty string or the special value "latest", it
Expand Down
2 changes: 1 addition & 1 deletion docs/index/functions/getLatestGcloudSDKVersion.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **getLatestGcloudSDKVersion**(): `Promise`\<`string`\>

Defined in: [index.ts:271](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L271)
Defined in: [index.ts:275](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L275)

getLatestGcloudSDKVersion fetches the latest version number from the API.

Expand Down
2 changes: 1 addition & 1 deletion docs/index/functions/installComponent.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **installComponent**(`component`): `Promise`\<`void`\>

Defined in: [index.ts:255](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L255)
Defined in: [index.ts:259](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L259)

Install a Cloud SDK component.

Expand Down
6 changes: 3 additions & 3 deletions docs/index/functions/installGcloudSDK.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Function: installGcloudSDK()

> **installGcloudSDK**(`version`, `skipToolCache?`): `Promise`\<`string`\>
> **installGcloudSDK**(`version`, `useToolCache`): `Promise`\<`string`\>

Defined in: [index.ts:168](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L168)

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

### skipToolCache?
### useToolCache

`boolean`
`boolean` = `false`

## Returns

Expand Down
2 changes: 1 addition & 1 deletion docs/index/functions/setProject.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

> **setProject**(`projectId`): `Promise`\<`void`\>

Defined in: [index.ts:245](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L245)
Defined in: [index.ts:249](https://github.com/google-github-actions/setup-cloud-sdk/blob/main/src/index.ts#L249)

Sets the GCP Project Id in the gcloud config.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@google-github-actions/setup-cloud-sdk",
"version": "1.2.2",
"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",
Expand Down
Loading