@ -9,17 +9,20 @@ on:
nexusmods_mod_id:
nexusmods_mod_id:
required : true
required : true
type : string
type : string
nexusmods_file_group_id:
required : true
type : string
mod_filename:
mod_filename:
required : true
required : true
type : string
type : string
mod_version:
mod_version:
required : false
required : false
type : string
type : string
default : ''
default : ""
mod_description:
mod_description:
required : false
required : false
type : string
type : string
default : ''
default : ""
artifact_name:
artifact_name:
required : true
required : true
type : string
type : string
@ -27,15 +30,9 @@ on:
required : false
required : false
type : boolean
type : boolean
default : true
default : true
append_v_to_version:
required : false
type : boolean
default : true
secrets:
secrets:
NEXUSMODS_APIKEY:
NEXUSMODS_APIKEY:
required : true
required : true
NEXUSMODS_SESSION_COOKIE:
required : true
jobs:
jobs:
publish-on-nexusmods:
publish-on-nexusmods:
@ -45,87 +42,84 @@ jobs:
name : NexusMods
name : NexusMods
url : https://www.nexusmods.com/${{ inputs.nexusmods_game_id }}/mods/${{ inputs.nexusmods_mod_id }}
url : https://www.nexusmods.com/${{ inputs.nexusmods_game_id }}/mods/${{ inputs.nexusmods_mod_id }}
steps:
steps:
- name : Setup
uses : butr/actions-common-setup@v2
with:
github-token : ${{ secrets.GITHUB_TOKEN }}
- name : Setup
- name : Install BUTR.NexusUploader
uses : butr/actions-common-setup@v2
run : dotnet tool install -g BUTR.NexusUploader;
with:
shell : pwsh
github-token : ${{ secrets.GITHUB_TOKEN }}
- name : Download Module artifact
- name : Download Module artifact
uses : actions/download-artifact@v4
uses : actions/download-artifact@v4
with:
with:
name : ${{ inputs.artifact_name }}
name : ${{ inputs.artifact_name }}
path : ./artifact
path : ./artifact
continue-on-error : true
continue-on-error : true
- name : Download Module artifact Pattern
- name : Download Module artifact Pattern
uses : actions/download-artifact@v4
uses : actions/download-artifact@v4
with:
with:
pattern : ${{ inputs.artifact_name }}-*
pattern : ${{ inputs.artifact_name }}-*
merge-multiple : true
merge-multiple : true
path : ./artifact
path : ./artifact
continue-on-error : true
continue-on-error : true
- name : 7z Module
- name : 7z Module
run : 7z a -t7z "${{ inputs.mod_filename }}.7z" ./artifact/* -mx9
run : 7z a -t7z "${{ inputs.mod_filename }}.7z" ./artifact/* -mx9
#shell: pwsh
# pwsh casues it to include the root folder
- name : Install Bannerlord.ChangelogParser
- name : Install Bannerlord.ChangelogParser
if : ${{ inputs.mod_description == '' }}
if : ${{ inputs.mod_description == '' }}
run : dotnet tool install -g Bannerlord.ChangelogParser;
run : dotnet tool install -g Bannerlord.ChangelogParser;
shell : pwsh
shell : pwsh
- name : Set Version
- name : Set Version
id : set_version
id : set_version
run : |
run : |
if ${{ inputs.mod_version == '' }}
if ${{ inputs.mod_version == '' }}
then
then
vers="$(bannerlord_changelog_parser latestversion -f "$PWD/changelog.txt")"
vers="$(bannerlord_changelog_parser latestversion -f "$PWD/changelog.txt")"
echo "::set-output name=mod_version::$vers "
echo "mod_version=$vers" >> "$GITHUB_OUTPUT "
else
else
echo "::set-output name=mod_version::${{ inputs.mod_version }} "
echo "mod_version=${{ inputs.mod_version }}" >> "$GITHUB_OUTPUT "
fi
fi
- name : Set Description
- name : Set Description
id : set_description
id : set_description
run : |
run : |
if ${{ inputs.mod_description == '' }}
if ${{ inputs.mod_description == '' }}
then
then
desc="$(bannerlord_changelog_parser ${{ inputs.mod_description_full && 'fulldescription' || 'description' }} -f "$PWD/changelog.txt")"
desc="$(bannerlord_changelog_parser ${{ inputs.mod_description_full && 'fulldescription' || 'description' }} -f "$PWD/changelog.txt")"
desc="${desc//'%'/'%25'}"
else
desc="${desc//$'"'/'%22'}"
desc="${{ inputs.mod_description }}"
desc="${desc//$'\n'/'%0A'}"
fi
desc="${desc//$'\r'/'%0D'}"
echo "mod_description<<EOF" >> "$GITHUB_OUTPUT"
echo "::set-output name=mod_description::$desc"
echo "$desc" >> "$GITHUB_OUTPUT"
c_desc="${desc#'For'*'%0A* '}"
echo "EOF" >> "$GITHUB_OUTPUT"
c_desc="${c_desc//'%0A* '/'%0A'}"
c_desc="${desc#'For'*$'\n'* }"
echo "::set-output name=mod_changelog::$c_desc"
c_desc="${c_desc//$'\n'* /$'\n'}"
else
echo "mod_changelog<<EOF" >> "$GITHUB_OUTPUT"
desc="${{ inputs.mod_description }}"
echo "$c_desc" >> "$GITHUB_OUTPUT"
desc="${desc//'%'/'%25'}"
echo "EOF" >> "$GITHUB_OUTPUT"
desc="${desc//$'"'/'%22'}"
desc="${desc//$'\n'/'%0A'}"
desc="${desc//$'\r'/'%0D'}"
echo "::set-output name=mod_description::$desc"
c_desc="${desc#'For'*'%0A* '}"
c_desc="${c_desc//'%0A* '/'%0A'}"
echo "::set-output name=mod_changelog::$c_desc"
fi
- name : Install BUTR.NexusUploader
- name : Upload to NexusMods
run : dotnet tool install -g BUTR.NexusUploader;
uses : Nexus-Mods/upload-action@v1.0.0-beta.2
shell : pwsh
with:
api_key : ${{ secrets.NEXUSMODS_APIKEY }}
file_group_id : ${{ inputs.nexusmods_file_group_id }}
filename : ${{ inputs.mod_filename }}.7z
version : ${{ steps.set_version.outputs.mod_version }}
display_name : ${{ inputs.mod_filename }}
description : ${{ steps.set_description.outputs.mod_description }}
file_category : main
- name : Run BUTR.NexusUploader
- name : Update NexusMods Changelog
run : |
run : >-
unex upload ${{ inputs.nexusmods_mod_id }} "${{ inputs.mod_filename }}.7z" -v "${{ inputs.append_v_to_version && 'v' || '' }}${{ steps.set_version.outputs.mod_version }}" -f "${{ inputs.mod_filename }}";
unex changelog "${{ steps.set_version.outputs.mod_version }}"
unex changelog "${{ inputs.append_v_to_version && 'v' || '' }}${{ steps.set_version.outputs.mod_version }}" -c "${{ steps.set_description.outputs.mod_changelog }}" -m "${{ inputs.nexusmods_mod_id }}";
-c "${{ steps.set_description.outputs.mod_changelog }}"
shell : pwsh
-m "${{ inputs.nexusmods_mod_id }}";
env:
shell : pwsh
UNEX_GAME : ${{ inputs.nexusmods_game_id }}
env:
UNEX_FILEDESCRIPTION : ${{ steps.set_description.outputs.mod_description }}
UNEX_GAME : ${{ inputs.nexusmods_game_id }}
UNEX_PREVIOUSFILE : auto
UNEX_APIKEY : ${{ secrets.NEXUSMODS_APIKEY }}
UNEX_APIKEY : ${{ secrets.NEXUSMODS_APIKEY }}
UNEX_SESSION_COOKIE : ${{ secrets.NEXUSMODS_SESSION_COOKIE }}
UNEX_DEBUG : true