Skip to content

Commit 3607357

Browse files
committed
Github Actions
1 parent 778e03d commit 3607357

File tree

4 files changed

+94
-14
lines changed

4 files changed

+94
-14
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ "FG_1.1" ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
uses: MinecraftForge/SharedActions/.github/workflows/gradle.yml@main
13+
with:
14+
java: 8
15+
gradle_tasks: "uploadArchives"
16+
artifact_group: "net.minecraftforge.gradle"
17+
artifact_name: "ForgeGradle"
18+
secrets:
19+
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
20+
PROMOTE_ARTIFACT_WEBHOOK: ${{ secrets.PROMOTE_ARTIFACT_WEBHOOK }}
21+
PROMOTE_ARTIFACT_USERNAME: ${{ secrets.PROMOTE_ARTIFACT_USERNAME }}
22+
PROMOTE_ARTIFACT_PASSWORD: ${{ secrets.PROMOTE_ARTIFACT_PASSWORD }}
23+
MAVEN_USER: ${{ secrets.MAVEN_USER }}
24+
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
25+
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
26+
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ out
1818
*.idea
1919
*.iml
2020

21+
/repo/

build.gradle

Lines changed: 66 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,34 @@
1+
buildscript {
2+
repositories {
3+
maven {
4+
url "https://plugins.gradle.org/m2/"
5+
}
6+
}
7+
dependencies {
8+
classpath 'org.eclipse.jgit:org.eclipse.jgit:5.10.0.202012080955-r'
9+
}
10+
}
11+
112
apply plugin: 'java'
213
apply plugin: 'idea'
314
apply plugin: 'eclipse'
415
apply plugin: 'maven'
516

17+
project.ext {
18+
GIT_INFO = gitInfo(rootProject.file('.'))
19+
}
20+
621
group = 'net.minecraftforge.gradle'
7-
version = '1.1-SNAPSHOT'
22+
version = "${project.ext.GIT_INFO.tag}.${project.ext.GIT_INFO.offset}"
23+
println "Version $version"
824
archivesBaseName = 'ForgeGradle'
925
targetCompatibility = '1.6'
1026
sourceCompatibility = '1.6'
1127

1228
repositories {
1329
maven {
1430
name = "forge"
15-
url = "http://files.minecraftforge.net/maven"
31+
url = "https://maven.minecraftforge.net/"
1632
}
1733
maven {
1834
name = "sonatype"
@@ -62,16 +78,17 @@ artifacts { archives jar }
6278

6379
uploadArchives {
6480
repositories {
65-
if (project.hasProperty("filesmaven")) {
66-
logger.info('Publishing to files server')
67-
6881
mavenDeployer {
6982
configuration = configurations.deployerJars
7083

71-
repository(url: project.filesmaven.url) {
72-
authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key)
84+
if (System.env.MAVEN_USER) {
85+
repository(url: "https://maven.minecraftforge.net/") {
86+
authentication(userName: System.env.MAVEN_USER, password: System.env.MAVEN_PASSWORD)
87+
}
88+
} else {
89+
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
7390
}
74-
91+
7592
pom {
7693
groupId = project.group
7794
version = project.version
@@ -118,10 +135,46 @@ uploadArchives {
118135
}
119136
}
120137
}
121-
}
122-
else
123-
{
124-
add project.repositories.mavenLocal()
125-
}
126138
}
127139
}
140+
141+
def gitInfo(dir) {
142+
String.metaClass.rsplit = { String del, int limit = -1 ->
143+
def lst = new ArrayList()
144+
def x = 0, idx
145+
def tmp = delegate
146+
while ((idx = tmp.lastIndexOf(del)) != -1 && (limit == -1 || x++ < limit)) {
147+
lst.add(0, tmp.substring(idx + del.length(), tmp.length()))
148+
tmp = tmp.substring(0, idx)
149+
}
150+
lst.add(0, tmp)
151+
return lst
152+
}
153+
154+
def git = null
155+
try {
156+
git = org.eclipse.jgit.api.Git.open(dir)
157+
} catch (org.eclipse.jgit.errors.RepositoryNotFoundException e) {
158+
return [
159+
tag: '0.0',
160+
offset: '0',
161+
hash: '00000000',
162+
branch: 'master',
163+
commit: '0000000000000000000000',
164+
abbreviatedId: '00000000'
165+
]
166+
}
167+
def desc = git.describe().setLong(true).setTags(true).call().rsplit('-', 2)
168+
def head = git.repository.exactRef('HEAD')
169+
def longBranch = head.symbolic ? head?.target?.name : null // matches Repository.getFullBranch() but returning null when on a detached HEAD
170+
171+
def ret = [:]
172+
ret.tag = desc[0]
173+
ret.offset = desc[1]
174+
ret.hash = desc[2]
175+
ret.branch = longBranch != null ? org.eclipse.jgit.lib.Repository.shortenRefName(longBranch) : null
176+
ret.commit = org.eclipse.jgit.lib.ObjectId.toString(head.objectId)
177+
ret.abbreviatedId = head.objectId.abbreviate(8).name()
178+
179+
return ret
180+
}

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
6+
distributionUrl=https://github.com/gradle/gradle-distributions/releases/download/v1.10.0/gradle-1.10-bin.zip

0 commit comments

Comments
 (0)