Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feature(actions): adjust how template cloning works and bump gradle #31

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
40 changes: 40 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
pauliesnug marked this conversation as resolved.
Show resolved Hide resolved
tab_width = 4
trim_trailing_whitespace = true

[*.gradle]
indent_style = tab

[*.java]
indent_style = tab
ij_continuation_indent_size = 8
ij_java_imports_layout = $*,|,java.**,|,javax.**,|,*,|,net.minecraft.**,|,org.polyfrost.**
pauliesnug marked this conversation as resolved.
Show resolved Hide resolved
ij_java_class_count_to_use_import_on_demand = 999

[*.json]
indent_style = space
indent_size = 2

[.editorconfig]
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false

[*.gradle]
indent_style = tab

[*.toml]
indent_style = tab
tab_width = 2

[*.properties]
indent_style = space
indent_size = 2
30 changes: 30 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
gradlew* linguist-vendored
gradle/wrapper/* linguist-vendored

*.java text eol=lf diff=java
*.gradle text eol=lf diff=java
*.kt text eol=lf diff=kotlin
*.kts text eol=lf diff=kotlin
gradlew text eol=lf
*.bat text eol=crlf

*.md text eol=lf diff=markdown

.editorconfig text eol=lf

*.json text eol=lf
*.json5 text eol=lf
*.properties text eol=lf
*.toml text eol=lf
*.xml text eol=lf diff=html

# Modding specific
*.accesswidener text eol=lf

# These files are binary and should be left untouched
# (binary is a macro for -text -diff)
*.class binary
*.dll binary
*.ear binary
*.jar binary
*.jks binary
*.png binary
*.so binary
*.war binary
14 changes: 14 additions & 0 deletions .github/template-cleanup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# %NAME%

![Build](https://github.com/%REPOSITORY%/workflows/Build/badge.svg)

## Template TODO list
- [x] Create a new [Forge mod template][template] project.
- [ ] Get familiar with the [legacy modding documentation][docs].
- [ ] Set the `MOD_ID` in `gradle.properties`
-
---
Mod based on nea89's [Forge mod template][template].

[template]: https://github.com/nea89o/Forge1.8.9Template
[docs]: https://moddev.nea.moe/
15 changes: 15 additions & 0 deletions .github/template-cleanup/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Constants
modGroup = %GROUP%
modName = %NAME%
modMCVersion = 1.8.9
modID = examplemod
modVersion = 1.0.0
modGitHub = https://github.com/%REPOSITORY%

# Loom Settings
loom.platform = forge

# Gradle Settings
org.gradle.jvmargs = -Xmx2g
org.gradle.caching = true
gradleVersion = 8.7
26 changes: 26 additions & 0 deletions .github/template-cleanup/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://maven.architectury.dev/")
maven("https://maven.fabricmc.net")
maven("https://maven.minecraftforge.net/")
maven("https://repo.spongepowered.org/maven/")
maven("https://repo.sk1er.club/repository/maven-releases/")
}
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"gg.essential.loom" -> useModule("gg.essential:architectury-loom:${requested.version}")
}
}
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}


rootProject.name = "%NAME%"
7 changes: 4 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: Run Gradle Build
name: Build
on:
- push
- pull_request

jobs:
gradle:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4.1.1
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4.0.0
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ jobs:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: gradle/wrapper-validation-action@v2.0.0
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
38 changes: 0 additions & 38 deletions .github/workflows/init.yml

This file was deleted.

54 changes: 54 additions & 0 deletions .github/workflows/template-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Template Cleanup
on:
push:
branches: [main]

jobs:
template-cleanup:
name: Template Cleanup
runs-on: ubuntu-latest
if: github.event.repository.name != 'Forge1.8.9Template'
permissions:
contents: write
steps:
- name: Fetch Sources
uses: actions/checkout@v4

- name: Cleanup
run: |
NAME="${GITHUB_REPOSITORY##*/}"
ACTOR=$(echo $GITHUB_ACTOR | tr '[:upper:]' '[:lower:]')
SAFE_NAME=$(echo $NAME | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
SAFE_ACTOR=$(echo $ACTOR | sed 's/[^a-zA-Z0-9]//g' | tr '[:upper:]' '[:lower:]')
GROUP="com.github.$SAFE_ACTOR.$SAFE_NAME"

sed -i "s/%NAME%/$NAME/g" .github/template-cleanup/*
sed -i "s/%REPOSITORY%/${GITHUB_REPOSITORY/\//\\/}/g" .github/template-cleanup/*
sed -i "s/%GROUP%/$GROUP/g" .github/template-cleanup/*

find src -type f -exec sed -i "s/org.jetbrains.plugins.template/$GROUP/g" {} +
pauliesnug marked this conversation as resolved.
Show resolved Hide resolved
find src -type f -exec sed -i "s/Example Mod/$NAME/g" {} +
find src -type f -exec sed -i "s/Authors/$ACTOR/g" {} +

mkdir -p src/main/java/${GROUP//.//}
cp -R .github/template-cleanup/. .
cp -R src/main/java/com/example/* src/main/java/${GROUP//.//}/

rm -rf \
.github/template-cleanup \
.github/workflows/template-cleanup.yml \
.github/workflows/template-verify.yml \
LICENSE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you move this back into a script file so you can still call the script without using github actions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!


- name: Commit Files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "Template cleanup"

- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: main
github_token: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/template-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Template Verify
on:
push:
branches: [main]
paths: ['**/gradle.properties']
pull_request:
paths: ['**/gradle.properties']

jobs:
build:
name: Template Verify
if: github.event.repository.name == 'Forge1.8.9Template'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.properties.outputs.version }}
changelog: ${{ steps.properties.outputs.changelog }}
steps:
- name: Fetch Sources
uses: actions/checkout@v4

- name: Verify gradle.properties
run: |
echo "\`\`\`diff" >> $GITHUB_STEP_SUMMARY

diff -U 0 \
-I '^modVersion' \
-I '^modGroup' \
-I '^modName' \
-I '^modGitHub' \
--label .github/template-cleanup/gradle.properties \
--label gradle.properties \
.github/template-cleanup/gradle.properties gradle.properties \
>> $GITHUB_STEP_SUMMARY

echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Architectury Loom based template for 1.8.9 forge mods

> [!TIP]
>
> Click the <kbd>Use this template</kbd> button and clone it in IntelliJ IDEA.

**For other templates, do check out the [other branches of this repository](https://github.com/romangraef/Forge1.8.9Template/branches/all)**

## Usage
Expand Down
Loading