This GitHub Action will setup a Nushell environment for you.
In most cases, you only need to specify the version
of Nushell to be used in your workflow.
For instance, the example below installs version v0.90
of Nushell.
After that, you can define the commands to be executed in subsequent steps. Remember to set shell: nu {0}
to ensure the commands are run using nu
:
- uses: hustcer/setup-nu@v3
with:
version: "0.90" # Don't use 0.90 here, as it was a float number and will be convert to 0.9, you can use v0.90/0.90.0 or '0.90'
- run: print $'Nu version info:(char nl)'; version
shell: nu {0}
- name: Default shell will be `nu`
shell: nu {0}
run: |
print $'Nu path:(which nu)(char nl)'
def greeting [name: string] {
print $'Hello ($name)'
}
greeting hustcer
Of cause, You can also set the default shell to nu
by setting the defaults.run.shell
config:
name: basic
on: push
defaults:
run:
shell: nu {0}
jobs:
basic-usage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: hustcer/setup-nu@main
with:
version: "*"
- run: version; print $"(char nl)Dir contents:(char nl)"; ls ((which nu).path.0 | path dirname)
- run: |
print $'Current env:(char nl)'
print $env
- name: You can run bash commands, too
run: pwd && ls -la
shell: bash
To use modules in Nu
, please refer to the following examples:
- Use Nu modules by setting
NU_LIB_DIRS
constant:
- name: Setup nu
uses: hustcer/setup-nu@v3
with:
version: 0.101.0
- name: Use Your Nu Modules by NU_LIB_DIRS Constant
shell: nu {0}
run: |
const NU_LIB_DIRS = [ ${{ github.workspace }}/nu ]
use module.nu *
print 'Use module by NU_LIB_DIRS Constant'
print (get-env 'ABC-XYZ' 'DEFAULT-FROM-NU-LIB-DIRS-CONSTANT')
- Use Nu modules in
nu -c
- name: Setup nu
uses: hustcer/setup-nu@v3
with:
version: 0.101.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Use Your Nu Modules
shell: nu {0}
run: |
nu -c "use nu/module.nu *; print (get-env 'ABC-XYZ' 'DEFAULT-ABC-XYZ')"
You have to wrap the nu
code in nu -c ""
, and the nu version should be equal to or above 0.69
.
- Use modules from absolute path
- name: Setup nu
uses: hustcer/setup-nu@v3
with:
version: 0.101.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Use Your Nu Modules by Absolute Path
shell: nu {0}
run: |
use ${{ github.workspace }}/nu/module.nu *
print 'Use module from: ${{ github.workspace }}/nu/module.nu'
print (get-env 'ABC-XYZ' 'DEFAULT-ABC-XYZ-ABSOLUTE-PATH')
Again, the nu version should be equal to or above 0.69
.
They aren't perfect yet, but they do work. By the way, if you discover a better approach, feel free to let me know—PRs are always welcome!
Nushell
is actively being developed. If you'd like to try out the latest features, you can set the version to nightly
, as shown below:
- uses: hustcer/setup-nu@v3
with:
version: nightly # Will download and setup the latest nightly version of Nushell
- run: print $'Nu version info:(char nl)'; version
shell: nu {0}
- name: Default shell will be `nu`
shell: nu {0}
run: |
print $'Nu path:(which nu)(char nl)'
def greeting [name: string] {
print $'Hello ($name)'
}
greeting hustcer
Warning Use the
Nushell
nightly version with caution: Thenu
binary is subject to frequent changes, which may disrupt your workflow. Only the latest nightly version will be downloaded and set up, and the version requirement isnightly
.
Or, check the following examples:
- run-matrix.yaml
- Advanced example: How Nushell Make a Release? Workflow, Script
If you'd like to use the latest version of nushell, you can do so by setting check-latest
to true
(this is functionally identical to using version: '*'
, but it's more readable). For example, the
following command installs the latest version:
- uses: hustcer/setup-nu@v3
with:
check-latest: true
- run: print $'Nu version info:(char nl)'; version
Note: As Nushell is still evolving toward version 1.0
, significant changes may occur with each release. It is recommended to use a specific version instead.
Name | Type | Description |
---|---|---|
version |
string |
Optional, A valid NPM-style semver specification, such as 0.86.0 , etc. and nightly . Default * |
check-latest |
bool |
Optional, Set to true if you want to use the latest version, default false |
enable-plugins |
bool | string |
Optional, Set to true if you want to register the bundled plugins or a comma-separated string of plugin names like nu_plugin_polars,nu_plugin_query , Nu v0.86 and above is required, default false |
features |
string |
Optional, Available choice: default or full , and the full features will include the commands from extra and dataframe . full can be used for Nu from v0.86 to v0.93 and was removed after v0.93.1 , default: default |
github-token |
string |
Optional, Your GitHub token or PAT token, default: ${{ github.token }} |
The semver specification is passed directly to NPM's semver package. This GitHub Action will install the latest matching release.
Licensed under:
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)