Skip to content

Commit 51f6837

Browse files
authored
Update @actions/core Version and move towards uses environment files to talk to runner (#135)
* update toolkit version * update licensed * fix typo
1 parent 7a98346 commit 51f6837

File tree

5 files changed

+127
-53
lines changed

5 files changed

+127
-53
lines changed

.github/workflows/workflow.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ jobs:
8181
- name: Set new tool cache (macOS)
8282
if: runner.os == 'macos'
8383
run: |
84-
echo "::set-env name=DOTNET_INSTALL_DIR::/Users/runner/.dotnet2"
84+
echo "DOTNET_INSTALL_DIR=/Users/runner/.dotnet2" >> $GITHUB_ENV
8585
- name: Set new tool cache (Ubuntu)
8686
if: runner.os == 'linux'
8787
run: |
88-
echo "::set-env name=DOTNET_INSTALL_DIR::/home/runner/.dotnet2"
88+
echo "DOTNET_INSTALL_DIR=/home/runner/.dotnet2" >> $GITHUB_ENV
8989
- name: Set new tool cache (Windows)
9090
if: runner.os == 'windows'
91+
shell: bash
9192
run: |
92-
echo "::set-env name=DOTNET_INSTALL_DIR::$env:LocalAppData\Microsoft\dotnet2"
93+
echo "DOTNET_INSTALL_DIR=$LocalAppData\Microsoft\dotnet2" >> $GITHUB_ENV
9394
# 2.0, 3.0, 5.0 needs to be in single quotes to interpret as a string instead of as an integer
9495
- name: Setup dotnet '2.0'
9596
uses: ./
@@ -100,15 +101,16 @@ jobs:
100101
- name: Set new tool cache (macOS)
101102
if: runner.os == 'macos'
102103
run: |
103-
echo "::set-env name=DOTNET_INSTALL_DIR::/Users/runner/.dotnet3"
104+
echo "DOTNET_INSTALL_DIR=/Users/runner/.dotnet3" >> $GITHUB_ENV
104105
- name: Set new tool cache (Ubuntu)
105106
if: runner.os == 'linux'
106107
run: |
107-
echo "::set-env name=DOTNET_INSTALL_DIR::/home/runner/.dotnet3"
108+
echo "DOTNET_INSTALL_DIR=/home/runner/.dotnet3" >> $GITHUB_ENV
108109
- name: Set new tool cache (Windows)
109110
if: runner.os == 'windows'
111+
shell: bash
110112
run: |
111-
echo "::set-env name=DOTNET_INSTALL_DIR::$env:LocalAppData\Microsoft\dotnet3"
113+
echo "DOTNET_INSTALL_DIR=$LocalAppData\Microsoft\dotnet3" >> $GITHUB_ENV
112114
- name: Setup dotnet 2.0.x
113115
uses: ./
114116
with:
@@ -118,15 +120,16 @@ jobs:
118120
- name: Set new tool cache (macOS)
119121
if: runner.os == 'macos'
120122
run: |
121-
echo "::set-env name=DOTNET_INSTALL_DIR::/Users/runner/.dotnet4"
123+
echo "DOTNET_INSTALL_DIR=/Users/runner/.dotnet4" >> $GITHUB_ENV
122124
- name: Set new tool cache (Ubuntu)
123125
if: runner.os == 'linux'
124126
run: |
125-
echo "::set-env name=DOTNET_INSTALL_DIR::/home/runner/.dotnet4"
127+
echo "DOTNET_INSTALL_DIR=/home/runner/.dotnet4" >> $GITHUB_ENV
126128
- name: Set new tool cache (Windows)
127129
if: runner.os == 'windows'
130+
shell: bash
128131
run: |
129-
echo "::set-env name=DOTNET_INSTALL_DIR::$env:LocalAppData\Microsoft\dotnet4"
132+
echo "DOTNET_INSTALL_DIR=$LocalAppData\Microsoft\dotnet4" >> $GITHUB_ENV
130133
- name: Setup dotnet 2.0.*
131134
uses: ./
132135
with:

.licenses/npm/@actions/core.dep.yml

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/index.js

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,6 +2932,32 @@ module.exports = function(tagname, parent, val) {
29322932
};
29332933

29342934

2935+
/***/ }),
2936+
2937+
/***/ 82:
2938+
/***/ (function(__unusedmodule, exports) {
2939+
2940+
"use strict";
2941+
2942+
// We use any as a valid input type
2943+
/* eslint-disable @typescript-eslint/no-explicit-any */
2944+
Object.defineProperty(exports, "__esModule", { value: true });
2945+
/**
2946+
* Sanitizes an input into a string so it can be passed into issueCommand safely
2947+
* @param input input to sanitize into a string
2948+
*/
2949+
function toCommandValue(input) {
2950+
if (input === null || input === undefined) {
2951+
return '';
2952+
}
2953+
else if (typeof input === 'string' || input instanceof String) {
2954+
return input;
2955+
}
2956+
return JSON.stringify(input);
2957+
}
2958+
exports.toCommandValue = toCommandValue;
2959+
//# sourceMappingURL=utils.js.map
2960+
29352961
/***/ }),
29362962

29372963
/***/ 87:
@@ -2941,6 +2967,42 @@ module.exports = require("os");
29412967

29422968
/***/ }),
29432969

2970+
/***/ 102:
2971+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
2972+
2973+
"use strict";
2974+
2975+
// For internal use, subject to change.
2976+
var __importStar = (this && this.__importStar) || function (mod) {
2977+
if (mod && mod.__esModule) return mod;
2978+
var result = {};
2979+
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
2980+
result["default"] = mod;
2981+
return result;
2982+
};
2983+
Object.defineProperty(exports, "__esModule", { value: true });
2984+
// We use any as a valid input type
2985+
/* eslint-disable @typescript-eslint/no-explicit-any */
2986+
const fs = __importStar(__webpack_require__(747));
2987+
const os = __importStar(__webpack_require__(87));
2988+
const utils_1 = __webpack_require__(82);
2989+
function issueCommand(command, message) {
2990+
const filePath = process.env[`GITHUB_${command}`];
2991+
if (!filePath) {
2992+
throw new Error(`Unable to find environment variable for file command ${command}`);
2993+
}
2994+
if (!fs.existsSync(filePath)) {
2995+
throw new Error(`Missing file at path: ${filePath}`);
2996+
}
2997+
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
2998+
encoding: 'utf8'
2999+
});
3000+
}
3001+
exports.issueCommand = issueCommand;
3002+
//# sourceMappingURL=file-command.js.map
3003+
3004+
/***/ }),
3005+
29443006
/***/ 118:
29453007
/***/ (function(module, __unusedexports, __webpack_require__) {
29463008

@@ -8936,6 +8998,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
89368998
};
89378999
Object.defineProperty(exports, "__esModule", { value: true });
89389000
const os = __importStar(__webpack_require__(87));
9001+
const utils_1 = __webpack_require__(82);
89399002
/**
89409003
* Commands
89419004
*
@@ -8989,28 +9052,14 @@ class Command {
89899052
return cmdStr;
89909053
}
89919054
}
8992-
/**
8993-
* Sanitizes an input into a string so it can be passed into issueCommand safely
8994-
* @param input input to sanitize into a string
8995-
*/
8996-
function toCommandValue(input) {
8997-
if (input === null || input === undefined) {
8998-
return '';
8999-
}
9000-
else if (typeof input === 'string' || input instanceof String) {
9001-
return input;
9002-
}
9003-
return JSON.stringify(input);
9004-
}
9005-
exports.toCommandValue = toCommandValue;
90069055
function escapeData(s) {
9007-
return toCommandValue(s)
9056+
return utils_1.toCommandValue(s)
90089057
.replace(/%/g, '%25')
90099058
.replace(/\r/g, '%0D')
90109059
.replace(/\n/g, '%0A');
90119060
}
90129061
function escapeProperty(s) {
9013-
return toCommandValue(s)
9062+
return utils_1.toCommandValue(s)
90149063
.replace(/%/g, '%25')
90159064
.replace(/\r/g, '%0D')
90169065
.replace(/\n/g, '%0A')
@@ -11241,6 +11290,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
1124111290
};
1124211291
Object.defineProperty(exports, "__esModule", { value: true });
1124311292
const command_1 = __webpack_require__(431);
11293+
const file_command_1 = __webpack_require__(102);
11294+
const utils_1 = __webpack_require__(82);
1124411295
const os = __importStar(__webpack_require__(87));
1124511296
const path = __importStar(__webpack_require__(622));
1124611297
/**
@@ -11267,9 +11318,17 @@ var ExitCode;
1126711318
*/
1126811319
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1126911320
function exportVariable(name, val) {
11270-
const convertedVal = command_1.toCommandValue(val);
11321+
const convertedVal = utils_1.toCommandValue(val);
1127111322
process.env[name] = convertedVal;
11272-
command_1.issueCommand('set-env', { name }, convertedVal);
11323+
const filePath = process.env['GITHUB_ENV'] || '';
11324+
if (filePath) {
11325+
const delimiter = '_GitHubActionsFileCommandDelimeter_';
11326+
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
11327+
file_command_1.issueCommand('ENV', commandValue);
11328+
}
11329+
else {
11330+
command_1.issueCommand('set-env', { name }, convertedVal);
11331+
}
1127311332
}
1127411333
exports.exportVariable = exportVariable;
1127511334
/**
@@ -11285,7 +11344,13 @@ exports.setSecret = setSecret;
1128511344
* @param inputPath
1128611345
*/
1128711346
function addPath(inputPath) {
11288-
command_1.issueCommand('add-path', {}, inputPath);
11347+
const filePath = process.env['GITHUB_PATH'] || '';
11348+
if (filePath) {
11349+
file_command_1.issueCommand('PATH', inputPath);
11350+
}
11351+
else {
11352+
command_1.issueCommand('add-path', {}, inputPath);
11353+
}
1128911354
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
1129011355
}
1129111356
exports.addPath = addPath;

package-lock.json

Lines changed: 29 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"author": "GitHub",
3131
"license": "MIT",
3232
"dependencies": {
33-
"@actions/core": "^1.2.5",
33+
"@actions/core": "^1.2.6",
3434
"@actions/exec": "^1.0.4",
3535
"@actions/github": "^1.1.0",
3636
"@actions/http-client": "^1.0.8",

0 commit comments

Comments
 (0)