GitHub Action
Check out this section for a full reference on the GitHub Action.
In the simplest case you just need the Action to compute the version number from the repository commit history. This example shows how:
jobs:
infer-version:
name: Infer the repository version with Nyx
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Nyx infer
id: nyx
uses: mooltiverse/nyx@main
- name: Print version # This step uses the version inferred by Nyx
run: echo the inferred version is ${{ steps.nyx.outputs.version }}
Very simple, and you can then use the version as ${{ steps.nyx.outputs.version }}
.
If you want Nyx not just to read the repository but also publish a release or push changes to a remote repository, you also need to pass the credentials using the GITHUB_TOKEN
and giving the mark
or publish
command, like in this example:
jobs:
infer-version:
name: Publish the release (if any) with Nyx
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Nyx publish
id: nyx
uses: mooltiverse/nyx@main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NYX_VERBOSITY: 'INFO'
with:
command: 'publish'
changelogPath: 'CHANGELOG.md'
preset: 'extended'
releaseLenient: 'true'
stateFile: '.nyx-state.json'
summaryFile: '.nyx-summary.txt'
Here the verbosity is passed as an environment variable (NYX_VERBOSITY
) just like the GITHUB_TOKEN
secret, while we also use the extended preset and generate a few other files from Nyx. The GH_TOKEN
is an arbitrary name and needs to match the one used for the configured AUTHENTICATION_TOKEN
.
In order to avoid hardcoding values, secrets can be fetched from environment variables, like in this configuration snippet from a .nyx.json
configuration file (to be stored in your Git repository):
"services":{
"github": {
"type": "GITHUB",
"options": {
"AUTHENTICATION_TOKEN": "{{#environmentVariable}}GH_TOKEN{{/environmentVariable}}",
"REPOSITORY_NAME": "myrepo",
"REPOSITORY_OWNER": "acme"
}
}
},