From 2bbe3d89d7a597d40f64a55d897d9163745d36e8 Mon Sep 17 00:00:00 2001
From: Thomas Boop <thboop@github.com>
Date: Tue, 29 Sep 2020 16:11:24 -0400
Subject: [PATCH] Add Env Files

---
 dist/index.js     | 538 +++++++++++++++++++++++++++-------------------
 package-lock.json |   6 +-
 2 files changed, 318 insertions(+), 226 deletions(-)

diff --git a/dist/index.js b/dist/index.js
index a91c8a5d..2a1638cb 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1243,6 +1243,32 @@ class SemVer {
 module.exports = SemVer
 
 
+/***/ }),
+
+/***/ 82:
+/***/ (function(__unusedmodule, exports) {
+
+"use strict";
+
+// We use any as a valid input type
+/* eslint-disable @typescript-eslint/no-explicit-any */
+Object.defineProperty(exports, "__esModule", { value: true });
+/**
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
+ * @param input input to sanitize into a string
+ */
+function toCommandValue(input) {
+    if (input === null || input === undefined) {
+        return '';
+    }
+    else if (typeof input === 'string' || input instanceof String) {
+        return input;
+    }
+    return JSON.stringify(input);
+}
+exports.toCommandValue = toCommandValue;
+//# sourceMappingURL=utils.js.map
+
 /***/ }),
 
 /***/ 87:
@@ -1252,6 +1278,42 @@ module.exports = require("os");
 
 /***/ }),
 
+/***/ 102:
+/***/ (function(__unusedmodule, exports, __webpack_require__) {
+
+"use strict";
+
+// For internal use, subject to change.
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+    result["default"] = mod;
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+// We use any as a valid input type
+/* eslint-disable @typescript-eslint/no-explicit-any */
+const fs = __importStar(__webpack_require__(747));
+const os = __importStar(__webpack_require__(87));
+const utils_1 = __webpack_require__(82);
+function issueCommand(command, message) {
+    const filePath = process.env[`GITHUB_${command}`];
+    if (!filePath) {
+        throw new Error(`Unable to find environment variable for file command ${command}`);
+    }
+    if (!fs.existsSync(filePath)) {
+        throw new Error(`Missing file at path: ${filePath}`);
+    }
+    fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
+        encoding: 'utf8'
+    });
+}
+exports.issueCommand = issueCommand;
+//# sourceMappingURL=file-command.js.map
+
+/***/ }),
+
 /***/ 120:
 /***/ (function(module, __unusedexports, __webpack_require__) {
 
@@ -2235,45 +2297,45 @@ const Range = __webpack_require__(124)
 /***/ (function(__unusedmodule, exports, __webpack_require__) {
 
 "use strict";
-
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
-    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
-    return new (P || (P = Promise))(function (resolve, reject) {
-        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
-        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
-        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
-        step((generator = generator.apply(thisArg, _arguments || [])).next());
-    });
-};
-var __importStar = (this && this.__importStar) || function (mod) {
-    if (mod && mod.__esModule) return mod;
-    var result = {};
-    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
-    result["default"] = mod;
-    return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const core = __importStar(__webpack_require__(470));
-const finder = __importStar(__webpack_require__(927));
-const path = __importStar(__webpack_require__(622));
-function run() {
-    return __awaiter(this, void 0, void 0, function* () {
-        try {
-            let version = core.getInput('python-version');
-            if (version) {
-                const arch = core.getInput('architecture', { required: true });
-                const installed = yield finder.findPythonVersion(version, arch);
-                core.info(`Successfully setup ${installed.impl} (${installed.version})`);
-            }
-            const matchersPath = path.join(__dirname, '..', '.github');
-            core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
-        }
-        catch (err) {
-            core.setFailed(err.message);
-        }
-    });
-}
-run();
+
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+    return new (P || (P = Promise))(function (resolve, reject) {
+        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+        step((generator = generator.apply(thisArg, _arguments || [])).next());
+    });
+};
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+    result["default"] = mod;
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const core = __importStar(__webpack_require__(470));
+const finder = __importStar(__webpack_require__(927));
+const path = __importStar(__webpack_require__(622));
+function run() {
+    return __awaiter(this, void 0, void 0, function* () {
+        try {
+            let version = core.getInput('python-version');
+            if (version) {
+                const arch = core.getInput('architecture', { required: true });
+                const installed = yield finder.findPythonVersion(version, arch);
+                core.info(`Successfully setup ${installed.impl} (${installed.version})`);
+            }
+            const matchersPath = path.join(__dirname, '..', '.github');
+            core.info(`##[add-matcher]${path.join(matchersPath, 'python.json')}`);
+        }
+        catch (err) {
+            core.setFailed(err.message);
+        }
+    });
+}
+run();
 
 
 /***/ }),
@@ -2422,6 +2484,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
 };
 Object.defineProperty(exports, "__esModule", { value: true });
 const os = __importStar(__webpack_require__(87));
+const utils_1 = __webpack_require__(82);
 /**
  * Commands
  *
@@ -2476,13 +2539,13 @@ class Command {
     }
 }
 function escapeData(s) {
-    return (s || '')
+    return utils_1.toCommandValue(s)
         .replace(/%/g, '%25')
         .replace(/\r/g, '%0D')
         .replace(/\n/g, '%0A');
 }
 function escapeProperty(s) {
-    return (s || '')
+    return utils_1.toCommandValue(s)
         .replace(/%/g, '%25')
         .replace(/\r/g, '%0D')
         .replace(/\n/g, '%0A')
@@ -2603,6 +2666,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
 };
 Object.defineProperty(exports, "__esModule", { value: true });
 const command_1 = __webpack_require__(431);
+const file_command_1 = __webpack_require__(102);
+const utils_1 = __webpack_require__(82);
 const os = __importStar(__webpack_require__(87));
 const path = __importStar(__webpack_require__(622));
 /**
@@ -2625,11 +2690,21 @@ var ExitCode;
 /**
  * Sets env variable for this action and future actions in the job
  * @param name the name of the variable to set
- * @param val the value of the variable
+ * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
  */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
 function exportVariable(name, val) {
-    process.env[name] = val;
-    command_1.issueCommand('set-env', { name }, val);
+    const convertedVal = utils_1.toCommandValue(val);
+    process.env[name] = convertedVal;
+    const filePath = process.env['GITHUB_ENV'] || '';
+    if (filePath) {
+        const delimiter = '_GitHubActionsFileCommandDelimeter_';
+        const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
+        file_command_1.issueCommand('ENV', commandValue);
+    }
+    else {
+        command_1.issueCommand('set-env', { name }, convertedVal);
+    }
 }
 exports.exportVariable = exportVariable;
 /**
@@ -2645,7 +2720,13 @@ exports.setSecret = setSecret;
  * @param inputPath
  */
 function addPath(inputPath) {
-    command_1.issueCommand('add-path', {}, inputPath);
+    const filePath = process.env['GITHUB_PATH'] || '';
+    if (filePath) {
+        file_command_1.issueCommand('PATH', inputPath);
+    }
+    else {
+        command_1.issueCommand('add-path', {}, inputPath);
+    }
     process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
 }
 exports.addPath = addPath;
@@ -2668,12 +2749,22 @@ exports.getInput = getInput;
  * Sets the value of an output.
  *
  * @param     name     name of the output to set
- * @param     value    value to store
+ * @param     value    value to store. Non-string values will be converted to a string via JSON.stringify
  */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
 function setOutput(name, value) {
     command_1.issueCommand('set-output', { name }, value);
 }
 exports.setOutput = setOutput;
+/**
+ * Enables or disables the echoing of commands into stdout for the rest of the step.
+ * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
+ *
+ */
+function setCommandEcho(enabled) {
+    command_1.issue('echo', enabled ? 'on' : 'off');
+}
+exports.setCommandEcho = setCommandEcho;
 //-----------------------------------------------------------------------
 // Results
 //-----------------------------------------------------------------------
@@ -2707,18 +2798,18 @@ function debug(message) {
 exports.debug = debug;
 /**
  * Adds an error issue
- * @param message error issue message
+ * @param message error issue message. Errors will be converted to string via toString()
  */
 function error(message) {
-    command_1.issue('error', message);
+    command_1.issue('error', message instanceof Error ? message.toString() : message);
 }
 exports.error = error;
 /**
  * Adds an warning issue
- * @param message warning issue message
+ * @param message warning issue message. Errors will be converted to string via toString()
  */
 function warning(message) {
-    command_1.issue('warning', message);
+    command_1.issue('warning', message instanceof Error ? message.toString() : message);
 }
 exports.warning = warning;
 /**
@@ -2776,8 +2867,9 @@ exports.group = group;
  * Saves state for current action, the state can only be retrieved by this action's post job execution.
  *
  * @param     name     name of the state to store
- * @param     value    value to store
+ * @param     value    value to store. Non-string values will be converted to a string via JSON.stringify
  */
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
 function saveState(name, value) {
     command_1.issueCommand('save-state', { name }, value);
 }
@@ -6258,178 +6350,178 @@ module.exports = lte
 /***/ (function(__unusedmodule, exports, __webpack_require__) {
 
 "use strict";
-
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
-    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
-    return new (P || (P = Promise))(function (resolve, reject) {
-        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
-        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
-        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
-        step((generator = generator.apply(thisArg, _arguments || [])).next());
-    });
-};
-var __importStar = (this && this.__importStar) || function (mod) {
-    if (mod && mod.__esModule) return mod;
-    var result = {};
-    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
-    result["default"] = mod;
-    return result;
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const os = __importStar(__webpack_require__(87));
-const path = __importStar(__webpack_require__(622));
-const semver = __importStar(__webpack_require__(876));
-let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
-if (!cacheDirectory) {
-    let baseLocation;
-    if (process.platform === 'win32') {
-        // On windows use the USERPROFILE env variable
-        baseLocation = process.env['USERPROFILE'] || 'C:\\';
-    }
-    else {
-        if (process.platform === 'darwin') {
-            baseLocation = '/Users';
-        }
-        else {
-            baseLocation = '/home';
-        }
-    }
-    cacheDirectory = path.join(baseLocation, 'actions', 'cache');
-}
-const core = __importStar(__webpack_require__(470));
-const tc = __importStar(__webpack_require__(533));
-const IS_WINDOWS = process.platform === 'win32';
-// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
-// This is where pip is, along with anything that pip installs.
-// There is a seperate directory for `pip install --user`.
-//
-// For reference, these directories are as follows:
-//   macOS / Linux:
-//      <sys.prefix>/bin (by default /usr/local/bin, but not on hosted agents -- see the `else`)
-//      (--user) ~/.local/bin
-//   Windows:
-//      <Python installation dir>\Scripts
-//      (--user) %APPDATA%\Python\PythonXY\Scripts
-// See https://docs.python.org/3/library/sysconfig.html
-function binDir(installDir) {
-    if (IS_WINDOWS) {
-        return path.join(installDir, 'Scripts');
-    }
-    else {
-        return path.join(installDir, 'bin');
-    }
-}
-// Note on the tool cache layout for PyPy:
-// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
-// A particular version of PyPy may contain one or more versions of the Python interpreter.
-// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
-// We only care about the Python version, so we don't use the PyPy version for the tool cache.
-function usePyPy(majorVersion, architecture) {
-    const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
-    let installDir = findPyPy(architecture);
-    if (!installDir && IS_WINDOWS) {
-        // PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
-        // On our Windows virtual environments, we only install an x86 version.
-        // Fall back to x86.
-        installDir = findPyPy('x86');
-    }
-    if (!installDir) {
-        // PyPy not installed in $(Agent.ToolsDirectory)
-        throw new Error(`PyPy ${majorVersion} not found`);
-    }
-    // For PyPy, Windows uses 'bin', not 'Scripts'.
-    const _binDir = path.join(installDir, 'bin');
-    // On Linux and macOS, the Python interpreter is in 'bin'.
-    // On Windows, it is in the installation root.
-    const pythonLocation = IS_WINDOWS ? installDir : _binDir;
-    core.exportVariable('pythonLocation', pythonLocation);
-    core.addPath(installDir);
-    core.addPath(_binDir);
-    const impl = 'pypy' + majorVersion.toString();
-    core.setOutput('python-version', impl);
-    return { impl: impl, version: versionFromPath(installDir) };
-}
-function useCpythonVersion(version, architecture) {
-    return __awaiter(this, void 0, void 0, function* () {
-        const desugaredVersionSpec = desugarDevVersion(version);
-        const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
-        core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
-        const installDir = tc.find('Python', semanticVersionSpec, architecture);
-        if (!installDir) {
-            // Fail and list available versions
-            const x86Versions = tc
-                .findAllVersions('Python', 'x86')
-                .map(s => `${s} (x86)`)
-                .join(os.EOL);
-            const x64Versions = tc
-                .findAllVersions('Python', 'x64')
-                .map(s => `${s} (x64)`)
-                .join(os.EOL);
-            throw new Error([
-                `Version ${version} with arch ${architecture} not found`,
-                'Available versions:',
-                x86Versions,
-                x64Versions
-            ].join(os.EOL));
-        }
-        core.exportVariable('pythonLocation', installDir);
-        core.addPath(installDir);
-        core.addPath(binDir(installDir));
-        if (IS_WINDOWS) {
-            // Add --user directory
-            // `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
-            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
-            const version = path.basename(path.dirname(installDir));
-            const major = semver.major(version);
-            const minor = semver.minor(version);
-            const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
-            core.addPath(userScriptsDir);
-        }
-        // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
-        const installed = versionFromPath(installDir);
-        core.setOutput('python-version', installed);
-        return { impl: 'CPython', version: installed };
-    });
-}
-/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
-function desugarDevVersion(versionSpec) {
-    if (versionSpec.endsWith('-dev')) {
-        const versionRoot = versionSpec.slice(0, -'-dev'.length);
-        return `>= ${versionRoot}.0-a0`;
-    }
-    else {
-        return versionSpec;
-    }
-}
-/** Extracts python version from install path from hosted tool cache as described in README.md */
-function versionFromPath(installDir) {
-    const parts = installDir.split(path.sep);
-    const idx = parts.findIndex(part => part === 'PyPy' || part === 'Python');
-    return parts[idx + 1] || '';
-}
-/**
- * Python's prelease versions look like `3.7.0b2`.
- * This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
- * If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent.
- */
-function pythonVersionToSemantic(versionSpec) {
-    const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
-    return versionSpec.replace(prereleaseVersion, '$1-$2');
-}
-exports.pythonVersionToSemantic = pythonVersionToSemantic;
-function findPythonVersion(version, architecture) {
-    return __awaiter(this, void 0, void 0, function* () {
-        switch (version.toUpperCase()) {
-            case 'PYPY2':
-                return usePyPy(2, architecture);
-            case 'PYPY3':
-                return usePyPy(3, architecture);
-            default:
-                return yield useCpythonVersion(version, architecture);
-        }
-    });
-}
-exports.findPythonVersion = findPythonVersion;
+
+var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
+    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
+    return new (P || (P = Promise))(function (resolve, reject) {
+        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
+        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
+        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
+        step((generator = generator.apply(thisArg, _arguments || [])).next());
+    });
+};
+var __importStar = (this && this.__importStar) || function (mod) {
+    if (mod && mod.__esModule) return mod;
+    var result = {};
+    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
+    result["default"] = mod;
+    return result;
+};
+Object.defineProperty(exports, "__esModule", { value: true });
+const os = __importStar(__webpack_require__(87));
+const path = __importStar(__webpack_require__(622));
+const semver = __importStar(__webpack_require__(876));
+let cacheDirectory = process.env['RUNNER_TOOLSDIRECTORY'] || '';
+if (!cacheDirectory) {
+    let baseLocation;
+    if (process.platform === 'win32') {
+        // On windows use the USERPROFILE env variable
+        baseLocation = process.env['USERPROFILE'] || 'C:\\';
+    }
+    else {
+        if (process.platform === 'darwin') {
+            baseLocation = '/Users';
+        }
+        else {
+            baseLocation = '/home';
+        }
+    }
+    cacheDirectory = path.join(baseLocation, 'actions', 'cache');
+}
+const core = __importStar(__webpack_require__(470));
+const tc = __importStar(__webpack_require__(533));
+const IS_WINDOWS = process.platform === 'win32';
+// Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
+// This is where pip is, along with anything that pip installs.
+// There is a seperate directory for `pip install --user`.
+//
+// For reference, these directories are as follows:
+//   macOS / Linux:
+//      <sys.prefix>/bin (by default /usr/local/bin, but not on hosted agents -- see the `else`)
+//      (--user) ~/.local/bin
+//   Windows:
+//      <Python installation dir>\Scripts
+//      (--user) %APPDATA%\Python\PythonXY\Scripts
+// See https://docs.python.org/3/library/sysconfig.html
+function binDir(installDir) {
+    if (IS_WINDOWS) {
+        return path.join(installDir, 'Scripts');
+    }
+    else {
+        return path.join(installDir, 'bin');
+    }
+}
+// Note on the tool cache layout for PyPy:
+// PyPy has its own versioning scheme that doesn't follow the Python versioning scheme.
+// A particular version of PyPy may contain one or more versions of the Python interpreter.
+// For example, PyPy 7.0 contains Python 2.7, 3.5, and 3.6-alpha.
+// We only care about the Python version, so we don't use the PyPy version for the tool cache.
+function usePyPy(majorVersion, architecture) {
+    const findPyPy = tc.find.bind(undefined, 'PyPy', majorVersion.toString());
+    let installDir = findPyPy(architecture);
+    if (!installDir && IS_WINDOWS) {
+        // PyPy only precompiles binaries for x86, but the architecture parameter defaults to x64.
+        // On our Windows virtual environments, we only install an x86 version.
+        // Fall back to x86.
+        installDir = findPyPy('x86');
+    }
+    if (!installDir) {
+        // PyPy not installed in $(Agent.ToolsDirectory)
+        throw new Error(`PyPy ${majorVersion} not found`);
+    }
+    // For PyPy, Windows uses 'bin', not 'Scripts'.
+    const _binDir = path.join(installDir, 'bin');
+    // On Linux and macOS, the Python interpreter is in 'bin'.
+    // On Windows, it is in the installation root.
+    const pythonLocation = IS_WINDOWS ? installDir : _binDir;
+    core.exportVariable('pythonLocation', pythonLocation);
+    core.addPath(installDir);
+    core.addPath(_binDir);
+    const impl = 'pypy' + majorVersion.toString();
+    core.setOutput('python-version', impl);
+    return { impl: impl, version: versionFromPath(installDir) };
+}
+function useCpythonVersion(version, architecture) {
+    return __awaiter(this, void 0, void 0, function* () {
+        const desugaredVersionSpec = desugarDevVersion(version);
+        const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
+        core.debug(`Semantic version spec of ${version} is ${semanticVersionSpec}`);
+        const installDir = tc.find('Python', semanticVersionSpec, architecture);
+        if (!installDir) {
+            // Fail and list available versions
+            const x86Versions = tc
+                .findAllVersions('Python', 'x86')
+                .map(s => `${s} (x86)`)
+                .join(os.EOL);
+            const x64Versions = tc
+                .findAllVersions('Python', 'x64')
+                .map(s => `${s} (x64)`)
+                .join(os.EOL);
+            throw new Error([
+                `Version ${version} with arch ${architecture} not found`,
+                'Available versions:',
+                x86Versions,
+                x64Versions
+            ].join(os.EOL));
+        }
+        core.exportVariable('pythonLocation', installDir);
+        core.addPath(installDir);
+        core.addPath(binDir(installDir));
+        if (IS_WINDOWS) {
+            // Add --user directory
+            // `installDir` from tool cache should look like $RUNNER_TOOL_CACHE/Python/<semantic version>/x64/
+            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
+            const version = path.basename(path.dirname(installDir));
+            const major = semver.major(version);
+            const minor = semver.minor(version);
+            const userScriptsDir = path.join(process.env['APPDATA'] || '', 'Python', `Python${major}${minor}`, 'Scripts');
+            core.addPath(userScriptsDir);
+        }
+        // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
+        const installed = versionFromPath(installDir);
+        core.setOutput('python-version', installed);
+        return { impl: 'CPython', version: installed };
+    });
+}
+/** Convert versions like `3.8-dev` to a version like `>= 3.8.0-a0`. */
+function desugarDevVersion(versionSpec) {
+    if (versionSpec.endsWith('-dev')) {
+        const versionRoot = versionSpec.slice(0, -'-dev'.length);
+        return `>= ${versionRoot}.0-a0`;
+    }
+    else {
+        return versionSpec;
+    }
+}
+/** Extracts python version from install path from hosted tool cache as described in README.md */
+function versionFromPath(installDir) {
+    const parts = installDir.split(path.sep);
+    const idx = parts.findIndex(part => part === 'PyPy' || part === 'Python');
+    return parts[idx + 1] || '';
+}
+/**
+ * Python's prelease versions look like `3.7.0b2`.
+ * This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
+ * If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent.
+ */
+function pythonVersionToSemantic(versionSpec) {
+    const prereleaseVersion = /(\d+\.\d+\.\d+)((?:a|b|rc)\d*)/g;
+    return versionSpec.replace(prereleaseVersion, '$1-$2');
+}
+exports.pythonVersionToSemantic = pythonVersionToSemantic;
+function findPythonVersion(version, architecture) {
+    return __awaiter(this, void 0, void 0, function* () {
+        switch (version.toUpperCase()) {
+            case 'PYPY2':
+                return usePyPy(2, architecture);
+            case 'PYPY3':
+                return usePyPy(3, architecture);
+            default:
+                return yield useCpythonVersion(version, architecture);
+        }
+    });
+}
+exports.findPythonVersion = findPythonVersion;
 
 
 /***/ }),
diff --git a/package-lock.json b/package-lock.json
index f4648dcb..94c73941 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,9 +5,9 @@
   "requires": true,
   "dependencies": {
     "@actions/core": {
-      "version": "1.2.3",
-      "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz",
-      "integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w=="
+      "version": "1.2.6",
+      "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.6.tgz",
+      "integrity": "sha512-ZQYitnqiyBc3D+k7LsgSBmMDVkOVidaagDG7j3fOym77jNunWRuYx7VSHa9GNfFZh+zh61xsCjRj4JxMZlDqTA=="
     },
     "@actions/exec": {
       "version": "1.0.3",