Skip to content
Open
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
46 changes: 46 additions & 0 deletions .github/rename_project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
while getopts a:n:u:d: flag
do
case "${flag}" in
a) author=${OPTARG};;
n) display_name=${OPTARG};;
u) urlname=${OPTARG};;
d) description=${OPTARG};;
esac
done

code_name="$(echo "$display_name" | sed -r 's/.*/\L&/;s/(^| )([a-z])/\U\2/g')"
mod_id="$(echo "${author}.${code_name}" | sed -r 's/.*/\L&/')"

echo "Author: $author";
echo "Display Name: $display_name";
echo "Description: $description";
echo "Code Name: $code_name";
echo "Mod ID: $mod_id";

echo "Renaming project..."

original_author="Author"
original_code_name="TestMod"
original_mod_id="author.testmod"
original_display_name="Test Mod"
original_description="Put a neat description here"

for filename in $(git ls-files)
do
if [[ "$filename" != lib/* && "$filename" != .github/* ]]
then
sed -i "s/$original_author/$author/g" $filename
sed -i "s/$original_code_name/$code_name/g" $filename
sed -i "s/$original_mod_id/$mod_id/g" $filename
sed -i "s/$original_display_name/$display_name/g" $filename
sed -i "s/$original_description/$description/g" $filename
#sed -i "s/ / /g" $filename
echo "Renamed $filename"
fi
done

mv src/TestMod.csproj "src/${code_name}.csproj"

# This command runs only once on GHA!
rm -r .github/
53 changes: 53 additions & 0 deletions .github/workflows/rename_project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Rename the project from template

on: [push]

permissions: write-all

jobs:
rename-project:
if: ${{ !contains (github.repository, '/TemplateMod') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# by default, it uses a depth of 1
# this fetches all history so that we can read each commit
fetch-depth: 0
ref: ${{ github.head_ref }}

- run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}' | tr '-' ' ')" >> $GITHUB_ENV
shell: bash

- run: echo "REPOSITORY_URLNAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV
shell: bash

- run: echo "REPOSITORY_OWNER=$(echo '${{ github.repository }}' | awk -F '/' '{print $1}')" >> $GITHUB_ENV
shell: bash

- name: Get repository description and fork status
uses: actions/github-script@v6
id: get_info
with:
script: |
const response = await github.rest.repos.get({
owner: context.repo.owner,
repo: context.repo.repo,
});
return {"description": response.data.description, "isFork": response.data.fork};
result-encoding: json

- run: echo "REPOSITORY_DESCRIPTION=$(echo "${{fromJson(steps.get_info.outputs.result).description}}")" >> $GITHUB_ENV
shell: bash

- name: Rename the project
if: fromJson(steps.get_info.outputs.result).isFork != true
run: |
echo "Renaming the project with -a(author) ${{ env.REPOSITORY_OWNER }} -n(name) ${{ env.REPOSITORY_NAME }} -u(urlname) ${{ env.REPOSITORY_URLNAME }}"
.github/rename_project.sh -a ${{ env.REPOSITORY_OWNER }} -n "${{ env.REPOSITORY_NAME }}" -u ${{ env.REPOSITORY_URLNAME }} -d "${{ env.REPOSITORY_DESCRIPTION }}"

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "Applied template changes."
# commit_options: '--amend --no-edit'
push_options: --force
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Usage
Use this template on GitHub or just [download the code](https://github.com/alduris/TemplateMod/archive/refs/heads/master.zip), whichever is easiest.

If you chose the latter it's recommended you delete the hidden `.github` folder before uploading to github.

Rename `src/TestMod.csproj`, then edit `mod/modinfo.json` and `src/Plugin.cs` to customize your mod.

See [the modding wiki](https://rainworldmodding.miraheze.org/wiki/Mod_Directories) for `modinfo.json` documentation.
Expand All @@ -21,4 +23,4 @@ In a nutshell, this means:

You do not have to license your code under CC0 though! (Though it would be cool if you did.) Feel free to license your code however you wish, or not at all.

**DISCLAIMER**: Any and all reference .dll files included (in the `lib` folder) are NOT covered under CC0! They are protected by copyright under their original owners. The actual code in the .dll files has been stripped so they serve no purpose other than for compiler reference (hopefully alleviating most legal issues this would otherwise cause), but this is expected to be upheld by you, the person using this template! Any reference .dlls you may add should be stripped before pushing to any public repository! And if it is possible to get code from Nuget instead, I recommend you do that instead of adding the dll here.
**DISCLAIMER**: Any and all reference .dll files included (in the `lib` folder) are NOT covered under CC0! They are protected by copyright under their original owners. The actual code in the .dll files has been stripped so they serve no purpose other than for compiler reference (hopefully alleviating most legal issues this would otherwise cause), but this is expected to be upheld by you, the person using this template! Any reference .dlls you may add should be stripped before pushing to any public repository! And if it is possible to get code from Nuget instead, I recommend you do that instead of adding the dll here.
2 changes: 1 addition & 1 deletion mod/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "testmod",
"id": "author.testmod",
"name": "Test Mod",
"version": "0.1.0",
"authors": "Author",
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace TestMod;

[BepInPlugin("com.author.testmod", "Test Mod", "0.1.0")]
[BepInPlugin("author.testmod", "Test Mod", "0.1.0")]
sealed class Plugin : BaseUnityPlugin
{
public static new ManualLogSource Logger;
Expand Down