.github/workflows/publish.yml
name: Publish BUTRLoader
on:
push:
tags:
- '*'
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Disable the .NET first time experience to skip caching NuGet packages and speed up the build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending .NET CLI telemetry to Microsoft.
DOTNET_CLI_TELEMETRY_OPTOUT: true
jobs:
changelog:
name: Get Changelog
runs-on: ubuntu-latest
outputs:
mod_version: ${{ steps.changelog.outputs.mod_version.test }}
mod_description: ${{ steps.changelog.outputs.mod_description.test }}
steps:
- uses: actions/checkout@v4
- name: Install and Run ChangelogParser
id: changelog
run: |
dotnet tool install -g Bannerlord.ChangelogParser
vers="$(bannerlord_changelog_parser latestversion -f "$PWD/changelog.txt")"
echo "::set-output name=mod_version::$vers"
desc="$(bannerlord_changelog_parser fulldescription -f "$PWD/changelog.txt")"
desc="${desc//'%'/'%25'}"
desc="${desc//$'\n'/'%0A'}"
desc="${desc//$'\r'/'%0D'}"
echo "::set-output name=mod_description::$desc"
shell: bash
build:
name: Build BUTRLoader
runs-on: windows-latest
steps:
- name: Setup
uses: butr/actions-common-setup@v2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
- name: Build BUTRLoader
run: |
mkdir bannerlord;
dotnet build src/Bannerlord.BUTRLoader.AssemblyManager/Bannerlord.BUTRLoader.AssemblyManager.csproj --configuration=Release -p:GameFolder="$PWD/bannerlord" /nowarn:MSB4011;
shell: pwsh
- name: Cleanup
run: >-
cd $PWD/bannerlord;
Get-ChildItem -Exclude bin | Remove-Item -Recurse -Force;
cd bin;
cd Win64_Shipping_Client;
Get-ChildItem -Exclude Bannerlord.BUTRLoader.dll,Bannerlord.BUTRLoader.pdb,TaleWorlds.MountAndBlade.Launcher.exe.config | Remove-Item -Recurse -Force;
shell: pwsh
- name: Upload Bannerlord folder
uses: actions/upload-artifact@v4
with:
name: bannerlord
path: ./bannerlord/
###########################
# NEXUSMODS #
###########################
publish-on-nexusmods:
needs: ["changelog", "build"]
if: startsWith(github.ref, 'refs/tags/v')
name: Publish BUTRLoader on NexusMods
uses: BUTR/workflows/.github/workflows/release-nexusmods.yml@master
with:
nexusmods_game_id: mountandblade2bannerlord
nexusmods_mod_id: 2513
mod_filename: BUTRLoader
mod_version: ${{ needs.changelog.outputs.mod_version }}
mod_description: ${{ needs.changelog.outputs.mod_description }}
artifact_name: bannerlord
secrets:
NEXUSMODS_APIKEY: ${{ secrets.ARAGAS_NEXUSMODS_API_KEY }}
NEXUSMODS_SESSION_COOKIE: ${{ secrets.ARAGAS_NEXUSMODS_SESSION_COOKIE }}
###########################
# GITHUB #
###########################
publish-on-github:
needs: ["changelog", "build"]
if: startsWith(github.ref, 'refs/tags/v')
name: Publish BUTRLoader on GitHub
runs-on: ubuntu-latest
environment:
name: GitHub Release
url: ${{ steps.upload_release_asset.outputs.browser_download_url }}
steps:
- name: Setup
uses: butr/actions-common-setup@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Download BUTRLoader artifact
uses: actions/download-artifact@v4
with:
name: bannerlord
path: ./bannerlord
- name: 7z BUTRLoader
run: 7z a -t7z Bannerlord.BUTRLoader.7z ./bannerlord/* -mx9
#shell: pwsh
# pwsh casues it to include the root folder
- name: Install Bannerlord.ChangelogParser
if: ${{ inputs.mod_version == '' || inputs.mod_description == '' }}
run: dotnet tool install -g Bannerlord.ChangelogParser;
shell: pwsh
- name: Set Version
id: set_version
run: |
if ${{ inputs.mod_version == '' }}
then
vers="$(bannerlord_changelog_parser latestversion -f "$PWD/changelog.txt")"
echo "::set-output name=mod_version::$vers"
else
echo "::set-output name=mod_version::${{ inputs.mod_version }}"
fi
- name: Set Description
id: set_description
run: |
if ${{ inputs.mod_description == '' }}
then
desc="$(bannerlord_changelog_parser fulldescription -f "$PWD/changelog.txt")"
desc="${desc//'%'/'%25'}"
desc="${desc//$'"'/'%22'}"
desc="${desc//$'\n'/'%0A'}"
desc="${desc//$'\r'/'%0D'}"
echo "::set-output name=mod_description::$desc"
else
desc="${{ inputs.mod_description }}"
desc="${desc//'%'/'%25'}"
desc="${desc//$'"'/'%22'}"
desc="${desc//$'\n'/'%0A'}"
desc="${desc//$'\r'/'%0D'}"
echo "::set-output name=mod_description::$desc"
fi
- name: Create Release
uses: actions/create-release@v1
id: create_release
with:
tag_name: v${{ steps.set_version.outputs.mod_version }}
release_name: Release ${{ steps.set_version.outputs.mod_version }}
body: ${{ steps.set_description.outputs.mod_description }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset BUTRLoader
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Bannerlord.BUTRLoader.7z
asset_name: Bannerlord.BUTRLoader.7z
asset_content_type: application/x-7z-compressed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}