No description
  • TypeScript 69.6%
  • JavaScript 30.4%
Find a file
Jeff Kluge fd55a6f3b3
Migrate to ESM and update all npm packages to latest versions (#234)
* Migrate to ESM and update all npm packages to latest versions

- Add type: module to package.json
- Update @actions/core, @actions/exec, @actions/io to v3 (ESM-only)
- Update @actions/tool-cache to v4 (ESM-only)
- Update semver, ts-jest, jest, prettier, nock, eslint-plugin-github,
  eslint-plugin-jest, @types/node, @typescript-eslint/parser
- Switch tsconfig module to nodenext with matching moduleResolution
- Enable isolatedModules for ts-jest ESM compatibility
- Add .js extensions to all relative imports
- Replace __dirname with import.meta.dirname in tests
- Convert jest.config.js to ESM with useESM and moduleNameMapper
- Use --experimental-vm-modules for Jest ESM support
- Regenerate lib/ and dist/ output

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Update codeql workflow

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 14:32:41 -07:00
.github Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
__tests__ Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
dist Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
lib Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
src Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
.gitattributes Create .gitattributes (#38) 2022-04-06 10:25:59 -07:00
.gitignore Introduce end-of-line normalization (#39) 2022-04-06 11:00:47 -07:00
.prettierrc.json Introduce end-of-line normalization (#39) 2022-04-06 11:00:47 -07:00
action.yml Migrate action runtime from node20 to node24 (#220) 2026-03-24 09:46:56 -07:00
jest.config.js Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
LICENSE Introduce end-of-line normalization (#39) 2022-04-06 11:00:47 -07:00
package-lock.json Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
package.json Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00
README.md Upgrade NuGet setup action to version 3 (#226) 2026-03-27 13:23:46 -07:00
tsconfig.json Migrate to ESM and update all npm packages to latest versions (#234) 2026-04-15 14:32:41 -07:00

Setup NuGet.exe

This action downloads and installs a given version of NuGet.exe. Using this action will add nuget to your $PATH on all operating systems, including macOS and linux, without having to prefix it with mono.

NuGet functionality also gets delivered with Visual Studio, msbuild and dotnet SDK. You should consider using the official setup-dotnet or one of the msbuild actions.

Usage

See action.yml

Supported values for nuget-version:

  • latest -- the latest blessed NuGet release.
  • preview -- the latest EarlyAccessPreview release.
  • X.Y.Z -- concrete semver version for a release (e.g. 5.3.1).
  • semver range -- any valid semver range specifier (e.g. 5, >=5, 5.3.x, etc)

This action also supports configuring your NuGet API key using GitHub secrets. The API key should be passed in as an nuget-api-key input. See the GitHub documentation on secrets for how to configure secrets on your repository.

Basic:

steps:
- uses: actions/checkout@master
- uses: nuget/setup-nuget@v3
  with:
    nuget-api-key: ${{ secrets.NuGetAPIKey }}
    nuget-version: '5.x'
- run: nuget restore MyProject.sln

Matrix Testing:

name: NuGet Restore
on: [push, pull_request]
jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest, macOS-latest]
        nuget: [latest, preview, 4.x, 5.3.1]
    name: NuGet@${{ matrix.nuget }} sample
    steps:
      - uses: actions/checkout@master
      - name: Setup NuGet.exe
        uses: nuget/setup-nuget@v3
        with:
          nuget-version: ${{ matrix.nuget }}
      - run: nuget restore MyProject.sln

Caching

The downloaded nuget.exe files are automatically cached between runs. To cache your global nuget directory, consider using the official cache action.

Caching Example

Note: For this example, you'll need to enable repeatable builds for your project.

steps:
- uses: actions/checkout@master
- uses: nuget/setup-nuget@v3
  with:
    nuget-version: '5.x'
- uses: actions/cache@v4
  id: cache
  with:
    path: ~/.nuget/packages
    key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
- name: NuGet Restore
  if: steps.cache.outputs.cache-hit != 'true'
  run: nuget restore MyProject.sln

Contributing

Code in Main

Install the dependencies

$ npm install

Build the typescript and package it for distribution

$ npm run build && npm run package

Run the tests ✔️

$ npm test

 PASS  ./index.test.js
  ✓ throws invalid number (3ms)wait 500 ms (504ms)test runs (95ms)

...

Publish to a distribution branch

Actions are run from GitHub repos so we will checkin the packed dist folder.

Then run ncc and push the results:

$ npm run package
$ git add dist
$ git commit -a -m "prod dependencies"
$ git push origin releases/v1

Note: We recommend using the --license option for ncc, which will create a license file for all of the production node modules used in your project.

Your action is now published! 🚀

See the versioning documentation

License

The scripts and documentation in this project are released under the MIT License.