Note
You'll need to have a reasonably modern version of Node.js handy (20.x or later should work!).
If you are using a version manager like nodenv
or
nvm
, this template has a .node-version
file at the root of the repository that
will be used to automatically switch to the correct version when you cd
into the repository. Additionally, this
.node-version
file is used by GitHub Actions in any actions/setup-node
actions.
If you're using Volta there is no need to do anything, as it will handle obtaining and using the correct version.
- π οΈ Install the dependencies
npm install
- β Run tests
$ npm test
PASS __tests__/main.test.ts
action
β errors on invalid input (6 ms)
β does nothing with no libraries passed in (237 ms)
β does updates in only matched project (116 ms)
β does updates in all matched projects (111 ms)
β fails action when dotnet call fails (115 ms)
...
- ποΈ Package the actions for distribution
npm run package
This action is used to update NuGet dependencies in all projects of a solution. It has limited checking to ensure it does not accidentally add a new dependency to a project that does not already have it.
This action requires that dotnet
is available in the environment. It is recommended to use the actions/setup-dotnet
action to ensure the correct version of dotnet
is available.
The action accepts libraries
as a JSON object. The object should be a mapping of library name to version. The version
can be a specific version, or a version range.
{
"library-name": "1.0.0",
"other-library": "2.0.0"
}
Workflow example
name: Library Updated
on:
repository_dispatch:
types:
- library_updated
jobs:
update_library:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x
source-url: https://nuget.pkg.github.com/cfacorp/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add updated libraries to solution
uses: tehbilly/rex-actions/update-nuget-dependencies@v1
with:
libraries: ${{ toJSON(github.event.client_payload.libraries) }}
After testing, you can create version tag(s) that developers can use to reference different stable versions of your action. For more information, see Versioning in the GitHub Actions toolkit.
Once changes are merged into main
, you can create a new version tag using the following commands:
# Create tag for version v1 -- this is the identifier used when referencing the action in a workflow
# Use --force as the tag likely already exists
git tag v1 --force
# Force push the tag to overwrite it, so consumers will get changes
git push --tags --force