Skip to content

Commit 6ee67a7

Browse files
committed
Github Actions
1 parent d57f4a2 commit 6ee67a7

File tree

4 files changed

+93
-13
lines changed

4 files changed

+93
-13
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.0" ]
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: 65 additions & 12 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.0-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
mavenCentral()
1834
}
@@ -58,14 +74,15 @@ artifacts { archives jar }
5874

5975
uploadArchives {
6076
repositories {
61-
if (project.hasProperty("filesmaven")) {
62-
logger.info('Publishing to files server')
63-
6477
mavenDeployer {
6578
configuration = configurations.deployerJars
6679

67-
repository(url: project.filesmaven.url) {
68-
authentication(userName: project.filesmaven.username, privateKey: project.filesmaven.key)
80+
if (System.env.MAVEN_USER) {
81+
repository(url: "https://maven.minecraftforge.net/") {
82+
authentication(userName: System.env.MAVEN_USER, password: System.env.MAVEN_PASSWORD)
83+
}
84+
} else {
85+
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
6986
}
7087

7188
pom {
@@ -114,10 +131,46 @@ uploadArchives {
114131
}
115132
}
116133
}
117-
}
118-
else
119-
{
120-
add project.repositories.mavenLocal()
121-
}
122134
}
123135
}
136+
137+
def gitInfo(dir) {
138+
String.metaClass.rsplit = { String del, int limit = -1 ->
139+
def lst = new ArrayList()
140+
def x = 0, idx
141+
def tmp = delegate
142+
while ((idx = tmp.lastIndexOf(del)) != -1 && (limit == -1 || x++ < limit)) {
143+
lst.add(0, tmp.substring(idx + del.length(), tmp.length()))
144+
tmp = tmp.substring(0, idx)
145+
}
146+
lst.add(0, tmp)
147+
return lst
148+
}
149+
150+
def git = null
151+
try {
152+
git = org.eclipse.jgit.api.Git.open(dir)
153+
} catch (org.eclipse.jgit.errors.RepositoryNotFoundException e) {
154+
return [
155+
tag: '0.0',
156+
offset: '0',
157+
hash: '00000000',
158+
branch: 'master',
159+
commit: '0000000000000000000000',
160+
abbreviatedId: '00000000'
161+
]
162+
}
163+
def desc = git.describe().setLong(true).setTags(true).call().rsplit('-', 2)
164+
def head = git.repository.exactRef('HEAD')
165+
def longBranch = head.symbolic ? head?.target?.name : null // matches Repository.getFullBranch() but returning null when on a detached HEAD
166+
167+
def ret = [:]
168+
ret.tag = desc[0]
169+
ret.offset = desc[1]
170+
ret.hash = desc[2]
171+
ret.branch = longBranch != null ? org.eclipse.jgit.lib.Repository.shortenRefName(longBranch) : null
172+
ret.commit = org.eclipse.jgit.lib.ObjectId.toString(head.objectId)
173+
ret.abbreviatedId = head.objectId.abbreviate(8).name()
174+
175+
return ret
176+
}

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.8-bin.zip
6+
distributionUrl=https://github.com/gradle/gradle-distributions/releases/download/v1.8.0/gradle-1.8-bin.zip

0 commit comments

Comments
 (0)