Skip to content

Commit 9fa21f8

Browse files
author
Michael Ruf
committed
Add gitlab workflow and refactor gradle stuff for better artifacts
1 parent 7732f0d commit 9fa21f8

14 files changed

Lines changed: 151 additions & 57 deletions

File tree

.github/workflows/build.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- '*'
8+
9+
env:
10+
# For any reason, specifying this in the modrinth step does not work?
11+
# But it is also well documented here, so this should be ok to do
12+
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Check tag condition
19+
if: startsWith(github.ref, 'refs/tags/')
20+
run: echo "Ref is a tag"
21+
22+
- name: Check out project
23+
if: success()
24+
uses: actions/checkout@v3
25+
26+
- name: Set up JDK 17
27+
if: success()
28+
uses: actions/setup-java@v3
29+
with:
30+
java-version: 17
31+
distribution: 'microsoft'
32+
33+
- name: Setup Gradle
34+
if: success()
35+
uses: gradle/gradle-build-action@v2
36+
with:
37+
gradle-version: 7.4.2
38+
39+
- name: Build fabric-mod
40+
if: success()
41+
run: gradle :fabric-mod:remapJar
42+
43+
- name: Build velocity-plugin
44+
if: success()
45+
run: gradle :velocity-plugin:shadowJar
46+
47+
- name: Release on GitHub
48+
if: success() && startsWith(github.ref, 'refs/tags/') # Failsafe check again
49+
uses: softprops/action-gh-release@v1
50+
with:
51+
files: |
52+
**/libs/proxy-command-*.jar
53+
README.md
54+
CHANGELOG.md
55+
LICENSE
56+
body_path: CHANGELOG.md
57+
draft: false
58+
prerelease: false
59+
fail_on_unmatched_files: true
60+
61+
- name: Upload fabric-mod to modrinth
62+
if: success()
63+
run: gradle :fabric-mod:modrinth

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Initial project creation

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ For example, you can teleport all players to a different server with a command b
3131
execute as @a run proxycommand "server SERVERNAME"
3232
```
3333

34+
## Changelog
35+
36+
Changelog per release cycle can be found [here](https://github.com/michiruf/MCProxyCommand/blob/master/CHANGELOG.md).
37+
This changelog information from one release to the next one.
38+
3439

3540
## License
3641

37-
[MIT License](https://github.com/michiruf/MCAllayFollowAlways/blob/master/LICENSE)
42+
[MIT License](https://github.com/michiruf/MCProxyCommand/blob/master/LICENSE)
3843

3944

4045
## Additional reading (for devs)

build.gradle

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
allprojects {
2-
// Got from https://github.com/PaperMC/Velocity/blob/dev/3.0.0/build.gradle
32
ext {
43
getCurrentShortRevision = {
4+
// Got from https://github.com/PaperMC/Velocity/blob/dev/3.0.0/build.gradle
55
new ByteArrayOutputStream().withStream { os ->
66
exec {
77
executable = "git"
@@ -11,5 +11,30 @@ allprojects {
1111
return os.toString().trim().substring(0, 8)
1212
}
1313
}
14+
15+
getLatestTag = {
16+
new ByteArrayOutputStream().withStream { os ->
17+
exec {
18+
executable = "git"
19+
args = ["describe", "--tags", "--abbrev=0"]
20+
standardOutput = os
21+
}
22+
return os.toString().trim()
23+
}
24+
}
25+
26+
getCurrentCommitCount = {
27+
new ByteArrayOutputStream().withStream { os ->
28+
exec {
29+
executable = "git"
30+
args = ["rev-list", "--all", "--count"]
31+
standardOutput = os
32+
}
33+
return os.toString().trim()
34+
}
35+
}
1436
}
37+
38+
project.version = "${project.ext.getLatestTag()}-${project.ext.getCurrentCommitCount()}-${project.ext.getCurrentShortRevision()}"
39+
project.group = 'michiruf'
1540
}

common/build.gradle

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,27 @@ plugins {
22
id 'java'
33
}
44

5-
version = project.mod_version
6-
group = project.maven_group
5+
dependencies {
6+
}
7+
8+
def targetJavaVersion = 17
9+
tasks.withType(JavaCompile).configureEach {
10+
// ensure that the encoding is set to UTF-8, no matter what the system default is
11+
// this fixes some edge cases with special characters not displaying correctly
12+
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
13+
// If Javadoc is generated, this must be specified in that task too.
14+
it.options.encoding = "UTF-8"
15+
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
16+
it.options.release = targetJavaVersion
17+
}
18+
}
19+
20+
java {
21+
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
22+
if (JavaVersion.current() < javaVersion) {
23+
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
24+
}
25+
archivesBaseName = "$rootProject.name-common"
26+
// If you remove this line, sources will not be generated.
27+
withSourcesJar()
28+
}

fabric-mod/build.gradle

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ plugins {
33
id 'com.modrinth.minotaur' version '2.+'
44
}
55

6-
version = project.mod_version
7-
group = project.maven_group
6+
// Fabric Properties. Check these on https://modmuss50.me/fabric.html
7+
def minecraft_version='1.19.2'
8+
def yarn_mappings='1.19.2+build.28'
9+
def loader_version='0.14.11'
10+
def fabric_version='0.68.0+1.19.2'
811

912
repositories {
13+
// NOTE This should currently be not needed, but to fiddle around with this dependency issue
14+
// we keep this for now
1015
maven {
1116
url = 'https://api.modrinth.com/maven'
1217
}
1318
}
1419

1520
dependencies {
1621
// To change the versions see the gradle.properties file
17-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
18-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
19-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
22+
minecraft "com.mojang:minecraft:${minecraft_version}"
23+
mappings "net.fabricmc:yarn:${yarn_mappings}:v2"
24+
modImplementation "net.fabricmc:fabric-loader:${loader_version}"
2025

2126
// Fabric API
2227
// It took 2 days to find out, that the dependency mods use or require the deprecated api of fabric,
@@ -33,8 +38,8 @@ dependencies {
3338
//modImplementation "maven.modrinth:fabric-api:${project.fabric_version}"
3439
// But if we do this, then the code for this project does not know fabric-api, so we just declare them
3540
// as compile time
36-
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
37-
modCompileOnly "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
41+
modCompileOnly "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
42+
modCompileOnly "net.fabricmc.fabric-api:fabric-api-deprecated:${fabric_version}"
3843

3944
// NOTE To work with the problems above, place these mods inside the mods folder
4045
// List of mods:
@@ -55,12 +60,13 @@ dependencies {
5560
// Error got because Identifier is null
5661

5762
implementation project(':common')
63+
include project(':common')
5864
}
5965

6066
modrinth {
61-
projectId = 'proxycommand'
67+
projectId = 'proxy-command'
6268
versionNumber = project.version
63-
versionType = 'alpha'
69+
versionType = project.version.contains('SNAPSHOT') ? 'alpha' : 'release'
6470
gameVersions = ['1.19.2']
6571
loaders = ['fabric']
6672
dependencies {
@@ -74,7 +80,7 @@ modrinth {
7480
// Use the environment variable `$MODRINTH_TOKEN` for the token
7581
// token = 'mySecretToken'
7682
}
77-
83+
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
7884

7985
processResources {
8086
inputs.property 'version', project.version
@@ -102,17 +108,11 @@ java {
102108
if (JavaVersion.current() < javaVersion) {
103109
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
104110
}
105-
archivesBaseName = project.archives_base_name
111+
archivesBaseName = "$rootProject.name-fabric"
106112
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
107113
// if it is present.
108114
// If you remove this line, sources will not be generated.
109115
withSourcesJar()
110116
}
111117

112-
jar {
113-
from("LICENSE") {
114-
rename { "${it}_${project.archives_base_name}" }
115-
}
116-
}
117-
118118
tasks.runServer.workingDir = 'run'

fabric-mod/run/server.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Minecraft server properties
2-
#Sun Dec 18 05:46:05 CET 2022
2+
#Sun Dec 18 20:55:10 CET 2022
33
enable-jmx-monitoring=false
44
rcon.port=25575
55
level-seed=1248939201

fabric-mod/src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"schemaVersion": 1,
3-
"id": "proxycommand",
3+
"id": "proxy-command",
44
"version": "${version}",
55
"name": "ProxyCommand",
66
"description": "",

gradle.properties

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
11
# Done to increase the memory available to gradle.
22
org.gradle.jvmargs=-Xmx1G
3-
# Fabric Properties
4-
# check these on https://modmuss50.me/fabric.html
5-
minecraft_version=1.19.2
6-
yarn_mappings=1.19.2+build.28
7-
loader_version=0.14.11
8-
# Mod Properties
9-
mod_version=1.0-SNAPSHOT
10-
maven_group=michiruf
11-
archives_base_name=proxycommand
12-
# Dependencies
13-
# check this on https://modmuss50.me/fabric.html
14-
fabric_version=0.68.0+1.19.2

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pluginManagement {
88
}
99
}
1010

11-
rootProject.name = 'proxycommand'
11+
rootProject.name = 'proxy-command'
1212
include 'common'
1313
include 'fabric-mod'
1414
include 'velocity-plugin'

0 commit comments

Comments
 (0)