Authenticate from CI
Give the pipeline one credential, stored as a CI secret.nh reads it from NERVES_HUB_TOKEN. API calls send it as Authorization: Bearer <credential>.
Use a product API key where you can. A leaked key exposes one product with the permissions you chose.
Product API keys are on the NervesHub main branch but in no tagged release as of NervesHub 2.5.4. On 2.5.4 and earlier, use a user access token.
- Product API key
- User access token
- In the product, open Product settings and select the API keys tab.
- Click Create key. Enter a Name, such as
CI deploys. - Choose the Role. Uploading firmware and creating releases need Manage, or a custom role with the Upload firmware and Create, edit and approve releases permissions.
- Click Create key, copy the key, and store it as a secret in your CI system. It is shown only once.
Configure nh in CI
Set these environment variables in the job.nh reads them without any saved settings.
Every variable can also be written with the
NERVES_CLOUD_ prefix. See CLI configuration.
To install nh on the runner, download the archive for the runner’s platform from the releases page. See Installation.
Sign in CI
NervesHub refuses fwup firmware that is not signed with a key registered to the organization. The other formats have their own signing rules.fwup and AtomVM firmware
nh firmware upload signs fwup (.fw) and AtomVM (.avm) images with an Ed25519 key before it uploads them. In CI, pass the key in NERVES_HUB_PRIVATE_KEY.
The value is the base64 encoding of the 64-byte Ed25519 private key, unencrypted. This is the format of the private key file fwup -g writes.
1
Generate a key pair
On your own machine, generate a key pair with fwup. It writes
fwup-key.pub and fwup-key.priv to the current directory.2
Register the public key
Register the public key with your organization. This needs a user access token, because signing keys belong to the organization.
3
Store the private key as a secret
Store the contents of
fwup-key.priv as a secret in your CI system, and expose it to the job as NERVES_HUB_PRIVATE_KEY. Keep the file itself somewhere safe and out of version control.fwup, so fwup must be on the runner’s PATH. AtomVM images need nothing else.
Other ways to supply the key:
If no key is given and
--skip-signing is not passed, the upload fails.
ESP-IDF and RAUC firmware
- ESP-IDF (
.bin):nhsigns withespsecure.py, which must be on the runner’sPATH, using an RSA-3072 key passed with--key-file <pem>. An image that is already signed is uploaded as it is. - RAUC (
.raucb): bundles are signed when they are built.nhuploads them as they are.
Upload and deploy with nh
- Detects the format from the file’s contents.
- Reads the image’s metadata and refuses an image built for a different product.
- Signs the image.
- Uploads it to the product.
- For each
--deploy, creates a release with the new firmware on that deployment group. The release becomes the group’s current release, with no archive.
nh looks for a single image in _build/<MIX_TARGET>_<MIX_ENV>/nerves/images/ and asks for confirmation, which fails without a terminal unless you also pass --yes.
The deploy option
--deploynames an existing deployment group. Repeat it to update several groups.- When
--deployis not given,NERVES_HUB_DEPLOYMENT_NAMEis used if it is set. - If a deployment fails, the firmware stays uploaded. The error names the firmware UUID and the group. Retry that step with
nh deployment update <group> --firmware <uuid>.
--deploy and create the release yourself:
Output and exit status
With-o json, nh firmware upload prints one JSON document on stdout: the uploaded firmware, with a deployed list naming the groups it updated. Progress messages go to stderr.
product, platform, architecture and tool.
nh exits 0 on success and non-zero on any failure, including a failed deployment after a successful upload. In JSON mode the document is still printed in that case, so a script can read the UUID.
GitHub Action
Thenervescloud/upload-nerves-firmware action downloads nh, signs and uploads a firmware file, and optionally updates a deployment group.
fwup must already be on the runner’s PATH. The action does not install it.
Inputs
Outputs
What the action does
- Installs
nhfor the runner’s platform (Linux, macOS or Windows on amd64 or arm64) and caches it. - Exports
NERVES_HUB_ORG,NERVES_HUB_PRODUCT,NERVES_HUB_TOKENand, whenuriis set,NERVES_HUB_URIto the job. Later steps can runnhwithout further setup. - Runs
nh firmware upload <firmware> --output json. The signing key is passed to that command only, and is not exported to the job. - When
deploymentis set, runsnh deployment update <deployment> --firmware <uuid>.
version: latest, the action asks the GitHub API for the newest nh release. It uses GITHUB_TOKEN for that request when the variable is set in the step’s environment. Pin version to avoid the lookup.
Equivalent API calls
The API does not sign firmware, so sign the file first. Sign an fwup image with fwup:Upload firmware
Send the file as thefirmware field of a multipart/form-data body.
201 Created, a Location header for the new firmware, and the firmware in the body.
422 with the reason in errors.detail, for example a signature that matches none of the organization’s keys, or firmware built for a different product.
This call needs the Upload firmware permission.
Create a release
Point a deployment group at the firmware by creating a release.
A successful call returns
201 Created. The request is refused with 422 if the group’s current release already has the same firmware and archive.
This call needs the Create, edit and approve releases permission.
If the releases route returns 404 although the deployment group exists, the server does not have the release API. Update the group instead, which creates a release the same way:
nh firmware upload --deploy and nh deployment update --firmware make this same choice for you.

