Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 54 additions & 12 deletions .github/workflows/nexus-upload.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Nexus Mods Upload

on:
workflow_run:
workflows: ["Release"]
types: [completed]
workflow_dispatch:
inputs:
version:
Expand All @@ -13,28 +16,64 @@ permissions: {}
jobs:
upload:
runs-on: ubuntu-latest
environment: nexus
if: github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main' && !endsWith(github.event.workflow_run.display_title, '(test)'))
concurrency:
group: nexus-upload
cancel-in-progress: false

permissions:
contents: read

steps:
- name: Resolve version
id: version
- name: Check Nexus configuration
shell: bash
env:
VERSION: ${{ inputs.version }}
NEXUSMODS_API_KEY: ${{ secrets.NEXUSMODS_API_KEY }}
NEXUSMODS_FILE_ID: ${{ secrets.NEXUSMODS_FILE_ID }}
NEXUSMODS_MOD_ID: ${{ secrets.NEXUSMODS_MOD_ID }}
NEXUSMODS_DISPLAY_NAME: ${{ vars.NEXUSMODS_DISPLAY_NAME }}
run: |
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
MISSING=0
for NAME in NEXUSMODS_API_KEY NEXUSMODS_FILE_ID NEXUSMODS_MOD_ID NEXUSMODS_DISPLAY_NAME; do
if [[ -z "${!NAME}" ]]; then
echo "Error: ${NAME} is not set in the nexus environment" >&2
MISSING=1
fi
done
exit "${MISSING}"

- name: Validate input version
if: github.event_name == 'workflow_dispatch'
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
if [[ ! "${INPUT_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: version must be X.Y.Z without 'v' prefix; test builds don't go to Nexus" >&2
exit 1
fi
echo "value=${VERSION}" >> "${GITHUB_OUTPUT}"

- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: v${{ steps.version.outputs.value }}
ref: ${{ github.event.workflow_run.head_sha || format('v{0}', inputs.version) }}

- name: Resolve version
id: version
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
TAG="$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n1 || true)"
VERSION="${TAG#v}"
VERSION="${VERSION:-${INPUT_VERSION}}"
if [[ ! "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: version must be X.Y.Z without 'v' prefix; test builds don't go to Nexus" >&2
exit 1
fi
echo "value=${VERSION}" >> "${GITHUB_OUTPUT}"

- name: Compute cliff range
id: range
Expand Down Expand Up @@ -95,22 +134,25 @@ jobs:
NOTES: ${{ steps.cliff.outputs.content }}
run: |
DELIM="$(dd if=/dev/urandom bs=15 count=1 status=none | base64)"
echo "notes<<$DELIM" >> "$GITHUB_OUTPUT"
echo "${NOTES//"## "/}" >> "$GITHUB_OUTPUT"
echo "$DELIM" >> "$GITHUB_OUTPUT"
{
printf 'notes<<%s\n' "${DELIM}"
printf '%s\n' "${NOTES//"## "/}"
printf '%s\n' "${DELIM}"
} >> "${GITHUB_OUTPUT}"

- name: Upload to Nexus Mods
uses: Nexus-Mods/upload-action@v1.0.0-beta.11
with:
api_key: ${{ secrets.NEXUSMODS_API_KEY }}
file_id: ${{ vars.NEXUSMODS_FILE_GROUP_ID }}
file_id: ${{ secrets.NEXUSMODS_FILE_ID }}
filename: ${{ steps.artifact.outputs.zip }}
display_name: ${{ github.event.repository.name }}
display_name: ${{ vars.NEXUSMODS_DISPLAY_NAME }}
description: ${{ steps.notes.outputs.notes }}
version: ${{ steps.version.outputs.value }}
archive_existing_version: true
update_mod_version: true
primary_mod_manager_download: true
allow_mod_manager_download: true
show_requirements_pop_up: true
mod_id: ${{ vars.NEXUSMODS_MOD_ID }}
mod_id: ${{ secrets.NEXUSMODS_MOD_ID }}
changelog: ${{ steps.notes.outputs.notes }}
56 changes: 38 additions & 18 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ Local builds use the `0.0.0` default.
A release run from any branch other than `main` fails.
Release and test runs both fail on a commit that already has a release tag.
If a run fails after creating the tag (for example during the asset upload), delete the GitHub Release and the tag before running it again.
2. Run `nexus-upload.yml` via **workflow_dispatch** with the version (no `v` prefix).
See [Nexus Mods upload](#nexus-mods-upload).
2. `nexus-upload.yml` starts once `release.yml` finishes.
Approve the pending `nexus` deployment with **Review deployments** on the workflow run's page to let the upload proceed.
If it doesn't start, or you need to re-run a failed upload, run it manually via **workflow_dispatch** with the version (no `v` prefix).
The version must match an existing `vX.Y.Z` tag exactly, since a manual run checks out that tag.
See [Nexus Mods upload](#nexus-mods-upload) for the environment setup.
3. If the Nexus page changed, regenerate it (see below) and paste it into the Nexus Mods page editor.

## Test builds
Expand Down Expand Up @@ -47,26 +50,43 @@ python3 scripts/generate-nexus-page.py

## Nexus Mods upload

`nexus-upload.yml` runs manually via **workflow_dispatch** with the version (no `v` prefix).
It checks out the `vX.Y.Z` tag, generates release notes with git-cliff, downloads the zip from the GitHub Release, and uploads it to Nexus Mods.
It also posts the notes to the mod's Changelog tab.
`nexus-upload.yml` runs on a `workflow_run` trigger chained off `release.yml`.
`release.yml` publishes the GitHub Release with the default `GITHUB_TOKEN`, and GitHub doesn't start a `release: published` workflow from events caused by `GITHUB_TOKEN`.
`workflow_run` fires when `release.yml` itself completes, whatever token published inside it.
Test builds are skipped.
The `upload` job runs under the `nexus` [GitHub environment](https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment), which requires manual approval before the job proceeds and scopes the Nexus secrets to that environment.
A manual **workflow_dispatch** run with the version (no `v` prefix), for example to re-run a failed upload, needs the same approval.

Each upload archives the previous file version, sets the mod's version on Nexus, marks the new file as the primary mod manager download, and shows the requirements pop-up.
It also posts the git-cliff notes to the mod's Changelog tab.
That endpoint appends, so re-running a successful upload for the same version adds a duplicate entry.
Each upload archives the previous file version, marks the new file as the primary mod manager download, and shows the requirements pop-up.

`workflow_run` always runs the copy of `nexus-upload.yml` committed to `main`, so changes to this workflow only take effect after merging to `main`.

Do not restrict the `nexus` environment to tags.
`workflow_run` jobs always run against the default branch's ref (`refs/heads/main`), not the tag from the upstream `release.yml` run, so a tag-only policy blocks every automatic upload.
A deployment-branch policy limited to `main` works with the automatic trigger and keeps `workflow_dispatch` runs from other branches away from the secrets.

**Prerequisites (one-time setup):**

1. Upload your first file manually via the [Nexus Mods web UI](https://www.nexusmods.com) to create the file group.
2. Add to the repository:
- **Secret** `NEXUSMODS_API_KEY`: your Nexus Mods API key
- **Variable** `NEXUSMODS_FILE_GROUP_ID`: the file group ID
- **Variable** `NEXUSMODS_MOD_ID`: the mod's internal ID, used for the Changelog tab
1. Upload your first file manually via the [Nexus Mods web UI](https://www.nexusmods.com): this creates the file that later uploads add versions to.
2. Note its file ID and the mod ID from the **Advanced** option on the mod page's Files tab, or from the file's edit menu on the Manage Files page.
3. Create the `nexus` environment (Settings → Environments → New environment) with a required reviewer, before the workflow referencing it is merged to `main`.
Otherwise GitHub creates it unprotected on first reference.
4. Add to the `nexus` environment as secrets (Settings → Environments → `nexus` → Environment secrets):
- `NEXUSMODS_API_KEY`: your Nexus Mods API key
- `NEXUSMODS_FILE_ID`: the file ID
- `NEXUSMODS_MOD_ID`: the mod ID, used to post each release's notes to the mod's Changelog tab.
It is **not** the number in the mod page URL.
5. Add to the `nexus` environment as a variable (Settings → Environments → `nexus` → Environment variables):
- `NEXUSMODS_DISPLAY_NAME`: the file name shown on Nexus

## CI

| Workflow | Trigger | What it does |
| ------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `ci.yml` | PRs to `main` touching source/cmake/vcpkg | clang-format (ubuntu) → build + test (windows, parallel) → clang-tidy (windows) |
| `release.yml` | Manual `workflow_dispatch` (see [Making a release](#making-a-release) and [Test builds](#test-builds)) | Computes the version, builds, packages via `scripts/package.sh`, tags the commit, publishes a GitHub Release (or prerelease) with zip + PDB |
| `nexus-upload.yml` | Manual `workflow_dispatch` (see [Nexus Mods upload](#nexus-mods-upload)) | Downloads the release zip, generates cliff release notes, uploads to Nexus Mods |
| `lint.yml` | PRs touching scripts, markdown docs, or markdown lint config/workflow files | shellcheck (scripts) + markdown checks (`dprint` and `vale`) |
| `pr-title.yml` | PR opened/edited/synchronised | Validates PR title follows Conventional Commits |
| Workflow | Trigger | What it does |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `ci.yml` | PRs to `main` touching source/cmake/vcpkg | clang-format (ubuntu) → build + test (windows, parallel) → clang-tidy (windows) |
| `release.yml` | Manual `workflow_dispatch` (see [Making a release](#making-a-release) and [Test builds](#test-builds)) | Computes the version, builds, packages via `scripts/package.sh`, tags the commit, publishes a GitHub Release (or prerelease) with zip + PDB |
| `nexus-upload.yml` | Starts via `workflow_run` once `release.yml` completes, gated on approval in the `nexus` environment; also manual `workflow_dispatch` (see [Nexus Mods upload](#nexus-mods-upload)) | Downloads the release zip, generates cliff release notes, uploads to Nexus Mods |
| `lint.yml` | PRs touching scripts, markdown docs, or markdown lint config/workflow files | shellcheck (scripts) + markdown checks (`dprint` and `vale`) |
| `pr-title.yml` | PR opened/edited/synchronised | Validates PR title follows Conventional Commits |
Loading