Skip to content

Commit d4c9434

Browse files
Update to Node.js 24 and modernize async usage (#654)
* Update to Node.js 24 and modernize async usage Bump Node.js version to 24 in workflows, action metadata, and engines. Update TypeScript target to ES2022 and use native async/await instead of __awaiter in compiled JS. Upgrade @types/node to 24.1.0 and update undici-types. Remove legacy async helpers and refactor code for improved readability and compatibility with modern Node.js. * update licences * update indentation * update package.json version * documentation update --------- Co-authored-by: Aparna Jyothi <[email protected]>
1 parent 5c125af commit d4c9434

File tree

11 files changed

+260
-319
lines changed

11 files changed

+260
-319
lines changed

.github/workflows/basic-validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
name: Basic validation
1717
uses: actions/reusable-workflows/.github/workflows/basic-validation.yml@main
1818
with:
19-
node-version: '20'
19+
node-version: '24'

.github/workflows/check-dist.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
name: Check dist/
1717
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
1818
with:
19-
node-version: '20'
19+
node-version: '24'

.licenses/npm/@types/node.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.

.licenses/npm/undici-types.dep.yml

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

README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ See [action.yml](action.yml)
2222
**Basic**:
2323
```yaml
2424
steps:
25-
- uses: actions/checkout@v4
26-
- uses: actions/setup-dotnet@v4
25+
- uses: actions/checkout@v5
26+
- uses: actions/setup-dotnet@v5
2727
with:
2828
dotnet-version: '8.0.x'
2929
- run: dotnet build <my project>
@@ -33,9 +33,9 @@ steps:
3333
**Multiple version installation**:
3434
```yml
3535
steps:
36-
- uses: actions/checkout@v4
36+
- uses: actions/checkout@v5
3737
- name: Setup dotnet
38-
uses: actions/setup-dotnet@v4
38+
uses: actions/setup-dotnet@v5
3939
with:
4040
dotnet-version: |
4141
8.0.x
@@ -59,8 +59,8 @@ This input sets up the action to install the latest build of the specified quali
5959

6060
```yml
6161
steps:
62-
- uses: actions/checkout@v4
63-
- uses: actions/setup-dotnet@v4
62+
- uses: actions/checkout@v5
63+
- uses: actions/setup-dotnet@v5
6464
with:
6565
dotnet-version: '8.0.x'
6666
dotnet-quality: 'preview'
@@ -74,8 +74,8 @@ steps:
7474

7575
```yml
7676
steps:
77-
- uses: actions/checkout@v4
78-
- uses: actions/setup-dotnet@v4
77+
- uses: actions/checkout@v5
78+
- uses: actions/setup-dotnet@v5
7979
with:
8080
global-json-file: csharp/global.json
8181
- run: dotnet build <my project>
@@ -91,8 +91,8 @@ The action searches for [NuGet Lock files](https://learn.microsoft.com/nuget/con
9191

9292
```yaml
9393
steps:
94-
- uses: actions/checkout@v4
95-
- uses: actions/setup-dotnet@v4
94+
- uses: actions/checkout@v5
95+
- uses: actions/setup-dotnet@v5
9696
with:
9797
dotnet-version: 8.x
9898
cache: true
@@ -116,8 +116,8 @@ steps:
116116
env:
117117
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
118118
steps:
119-
- uses: actions/checkout@v4
120-
- uses: actions/setup-dotnet@v4
119+
- uses: actions/checkout@v5
120+
- uses: actions/setup-dotnet@v5
121121
with:
122122
dotnet-version: 8.x
123123
cache: true
@@ -130,8 +130,8 @@ steps:
130130
env:
131131
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
132132
steps:
133-
- uses: actions/checkout@v4
134-
- uses: actions/setup-dotnet@v4
133+
- uses: actions/checkout@v5
134+
- uses: actions/setup-dotnet@v5
135135
with:
136136
dotnet-version: 8.x
137137
cache: true
@@ -150,9 +150,9 @@ jobs:
150150
dotnet: [ '7.0.x', '8.0.x', '9.0.x' ]
151151
name: Dotnet ${{ matrix.dotnet }} sample
152152
steps:
153-
- uses: actions/checkout@v4
153+
- uses: actions/checkout@v5
154154
- name: Setup dotnet
155-
uses: actions/setup-dotnet@v4
155+
uses: actions/setup-dotnet@v5
156156
with:
157157
dotnet-version: ${{ matrix.dotnet }}
158158
- name: Execute dotnet
@@ -170,9 +170,9 @@ jobs:
170170
dotnet: [ '7.0.x', '8.0.x', '9.0.x' ]
171171
name: Dotnet ${{ matrix.dotnet }} sample
172172
steps:
173-
- uses: actions/checkout@v4
173+
- uses: actions/checkout@v5
174174
- name: Setup dotnet
175-
uses: actions/setup-dotnet@v4
175+
uses: actions/setup-dotnet@v5
176176
id: stepid
177177
with:
178178
dotnet-version: ${{ matrix.dotnet }}
@@ -186,8 +186,8 @@ jobs:
186186
### Github Package Registry (GPR)
187187
```yml
188188
steps:
189-
- uses: actions/checkout@v4
190-
- uses: actions/setup-dotnet@v4
189+
- uses: actions/checkout@v5
190+
- uses: actions/setup-dotnet@v5
191191
with:
192192
dotnet-version: '8.0.x'
193193
source-url: https://nuget.pkg.github.com/<owner>/index.json
@@ -202,7 +202,7 @@ steps:
202202

203203
### Azure Artifacts
204204
```yml
205-
- uses: actions/setup-dotnet@v4
205+
- uses: actions/setup-dotnet@v5
206206
with:
207207
source-url: https://pkgs.dev.azure.com/<your-organization>/_packaging/<your-feed-name>/nuget/v3/index.json
208208
env:
@@ -213,7 +213,7 @@ steps:
213213

214214
### nuget.org
215215
```yml
216-
- uses: actions/setup-dotnet@v4
216+
- uses: actions/setup-dotnet@v5
217217
with:
218218
dotnet-version: 8.0.x
219219
- name: Publish the package to nuget.org
@@ -236,7 +236,7 @@ Using the **dotnet-version** output it's possible to get the installed by the ac
236236
In case of a single version installation, the `dotnet-version` output contains the version that is installed by the action.
237237

238238
```yaml
239-
- uses: actions/setup-dotnet@v4
239+
- uses: actions/setup-dotnet@v5
240240
id: stepid
241241
with:
242242
dotnet-version: 8.0.402
@@ -248,7 +248,7 @@ In case of a single version installation, the `dotnet-version` output contains t
248248
In case of a multiple version installation, the `dotnet-version` output contains the latest version that is installed by the action.
249249

250250
```yaml
251-
- uses: actions/setup-dotnet@v4
251+
- uses: actions/setup-dotnet@v5
252252
id: stepid
253253
with:
254254
dotnet-version: |
@@ -261,7 +261,7 @@ In case of a multiple version installation, the `dotnet-version` output contains
261261
When the `dotnet-version` input is used along with the `global-json-file` input, the `dotnet-version` output contains the version resolved from the `global.json`.
262262

263263
```yaml
264-
- uses: actions/setup-dotnet@v4
264+
- uses: actions/setup-dotnet@v5
265265
id: stepid
266266
with:
267267
dotnet-version: |
@@ -302,7 +302,7 @@ build:
302302
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
303303
steps:
304304
- uses: actions/checkout@main
305-
- uses: actions/setup-dotnet@v4
305+
- uses: actions/setup-dotnet@v5
306306
with:
307307
dotnet-version: '8.0.x'
308308
cache: true

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ outputs:
3030
dotnet-version:
3131
description: 'Contains the installed by action .NET SDK version for reuse.'
3232
runs:
33-
using: 'node20'
33+
using: 'node24'
3434
main: 'dist/setup/index.js'
3535
post: 'dist/cache-save/index.js'
3636
post-if: success()

dist/cache-save/index.js

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -87721,15 +87721,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
8772187721
__setModuleDefault(result, mod);
8772287722
return result;
8772387723
};
87724-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
87725-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
87726-
return new (P || (P = Promise))(function (resolve, reject) {
87727-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
87728-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
87729-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
87730-
step((generator = generator.apply(thisArg, _arguments || [])).next());
87731-
});
87732-
};
8773387724
var __importDefault = (this && this.__importDefault) || function (mod) {
8773487725
return (mod && mod.__esModule) ? mod : { "default": mod };
8773587726
};
@@ -87747,40 +87738,38 @@ process.on('uncaughtException', e => {
8774787738
const warningPrefix = '[warning]';
8774887739
core.info(`${warningPrefix}${e.message}`);
8774987740
});
87750-
function run() {
87751-
return __awaiter(this, void 0, void 0, function* () {
87752-
try {
87753-
if (core.getBooleanInput('cache')) {
87754-
yield cachePackages();
87755-
}
87756-
}
87757-
catch (error) {
87758-
core.setFailed(error.message);
87741+
async function run() {
87742+
try {
87743+
if (core.getBooleanInput('cache')) {
87744+
await cachePackages();
8775987745
}
87760-
});
87746+
}
87747+
catch (error) {
87748+
core.setFailed(error.message);
87749+
}
8776187750
}
8776287751
exports.run = run;
87763-
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
87752+
const cachePackages = async () => {
8776487753
const state = core.getState(constants_1.State.CacheMatchedKey);
8776587754
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
8776687755
if (!primaryKey) {
8776787756
core.info('Primary key was not generated, not saving cache.');
8776887757
return;
8776987758
}
87770-
const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)();
87759+
const { 'global-packages': cachePath } = await (0, cache_utils_1.getNuGetFolderPath)();
8777187760
if (!node_fs_1.default.existsSync(cachePath)) {
8777287761
throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`);
8777387762
}
8777487763
if (primaryKey === state) {
8777587764
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
8777687765
return;
8777787766
}
87778-
const cacheId = yield cache.saveCache([cachePath], primaryKey);
87767+
const cacheId = await cache.saveCache([cachePath], primaryKey);
8777987768
if (cacheId == -1) {
8778087769
return;
8778187770
}
8778287771
core.info(`Cache saved with the key: ${primaryKey}`);
87783-
});
87772+
};
8778487773
run();
8778587774

8778687775

@@ -87814,15 +87803,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
8781487803
__setModuleDefault(result, mod);
8781587804
return result;
8781687805
};
87817-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
87818-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
87819-
return new (P || (P = Promise))(function (resolve, reject) {
87820-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
87821-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
87822-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
87823-
step((generator = generator.apply(thisArg, _arguments || [])).next());
87824-
});
87825-
};
8782687806
Object.defineProperty(exports, "__esModule", ({ value: true }));
8782787807
exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0;
8782887808
const cache = __importStar(__nccwpck_require__(7799));
@@ -87854,8 +87834,8 @@ const constants_1 = __nccwpck_require__(9042);
8785487834
* }
8785587835
* ```
8785687836
*/
87857-
const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () {
87858-
const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true });
87837+
const getNuGetFolderPath = async () => {
87838+
const { stdout, stderr, exitCode } = await exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true });
8785987839
if (exitCode) {
8786087840
throw new Error(!stderr.trim()
8786187841
? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}`
@@ -87876,7 +87856,7 @@ const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* ()
8787687856
}
8787787857
}
8787887858
return result;
87879-
});
87859+
};
8788087860
exports.getNuGetFolderPath = getNuGetFolderPath;
8788187861
function isCacheFeatureAvailable() {
8788287862
if (cache.isFeatureAvailable()) {

0 commit comments

Comments
 (0)