Skip to content

Commit 17f7bfd

Browse files
committed
Prep for nightly builds and new workflows
1 parent 98c4b08 commit 17f7bfd

File tree

5 files changed

+117
-35
lines changed

5 files changed

+117
-35
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Gradle Tests and Nightly (CI)
2+
3+
on: push
4+
5+
jobs:
6+
vars:
7+
name: Get Variables
8+
runs-on: ubuntu-20.04
9+
outputs:
10+
release_type: ${{steps.cf_release_type.outputs.value }}
11+
mod_version: ${{steps.mod_version.outputs.value }}
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Release Type
17+
id: cf_release_type
18+
uses: christian-draeger/[email protected]
19+
with:
20+
path: './gradle.properties'
21+
property: 'cf_release_type'
22+
23+
- name: Mod Version
24+
id: mod_version
25+
uses: christian-draeger/[email protected]
26+
with:
27+
path: './gradle.properties'
28+
property: 'mod_version'
29+
30+
tests:
31+
name: Gradle Tests
32+
runs-on: ubuntu-20.04
33+
needs: [ vars ]
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v2
37+
38+
- name: Set up JDK 8
39+
uses: actions/setup-java@v1
40+
with:
41+
java-version: "8.0.282"
42+
43+
- name: Cache Gradle packages
44+
uses: actions/cache@v2
45+
with:
46+
path: |
47+
~/.gradle/caches
48+
~/.gradle/wrapper
49+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
50+
restore-keys: ${{ runner.os }}-gradle-
51+
52+
- name: Grant execute permission for gradlew
53+
run: chmod +x gradlew
54+
55+
- name: Test JAR with Gradle
56+
run: ./gradlew test
57+
env:
58+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
61+
nightly:
62+
name: Publish Nightly
63+
runs-on: ubuntu-20.04
64+
needs: [ vars, tests ]
65+
steps:
66+
- name: Checkout
67+
uses: actions/checkout@v2
68+
69+
- name: Set up JDK 8
70+
uses: actions/setup-java@v1
71+
with:
72+
java-version: "8.0.282"
73+
74+
- name: Cache Gradle packages
75+
uses: actions/cache@v2
76+
with:
77+
path: |
78+
~/.gradle/caches
79+
~/.gradle/wrapper
80+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
81+
restore-keys: ${{ runner.os }}-gradle-
82+
83+
- name: Grant execute permission for gradlew
84+
run: chmod +x gradlew
85+
86+
- name: Publish gradle nightly jar
87+
run: ./gradlew publishNightlyMavenPublicationToGitHubPackagesRepository
88+
env:
89+
CM_RELEASE: false
90+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci-tests.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/manual-gh-packages.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,9 @@ jobs:
117117
run: chmod +x gradlew
118118

119119
- name: Publish JAR with Gradle
120-
run: ./gradlew publish --max-workers 1
120+
run: ./gradlew publish -x test
121121
env:
122+
CM_RELEASE: true
122123
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
123124
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124125

.github/workflows/tagged-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ jobs:
119119
run: chmod +x gradlew
120120

121121
- name: Publish package
122-
run: ./gradlew publish --max-workers 1
122+
run: ./gradlew publish -x test
123123
env:
124+
CM_RELEASE: true
124125
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
125126
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
126127

build.gradle

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath "net.minecraftforge.gradle:ForgeGradle:4.1.9"
9+
classpath "net.minecraftforge.gradle:ForgeGradle:4.1.12"
1010
}
1111
}
1212

@@ -18,10 +18,16 @@ plugins {
1818

1919
apply plugin: "net.minecraftforge.gradle"
2020

21-
version = "${mod_version}"
22-
group = 'com.robotgryphon' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
21+
def gitCommitHash = 'git rev-parse --verify --short HEAD'.execute().text.trim()
22+
def isRelease = (System.getenv("CM_RELEASE") ?: "false").equalsIgnoreCase("true")
23+
24+
version = isRelease ? mod_version : "nightly-${gitCommitHash}"
25+
group = 'com.robotgryphon'
2326
archivesBaseName = mod_id
2427

28+
println("Mod ID: ${mod_id}");
29+
println("Version: ${version}");
30+
2531
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
2632

2733
sourceSets {
@@ -227,7 +233,7 @@ jar {
227233
"Specification-Vendor" : "",
228234
"Specification-Version" : "1", // We are version 1 of ourselves
229235
"Implementation-Title" : project.name,
230-
"Implementation-Version" : "${archiveVersion}",
236+
"Implementation-Version": isRelease ? archiveVersion : "nightly-${gitCommitHash}",
231237
"Implementation-Vendor" : "",
232238
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
233239
])
@@ -258,6 +264,18 @@ publishing {
258264
}
259265
}
260266
}
267+
268+
nightlyMaven(MavenPublication) {
269+
artifactId = mod_id
270+
artifacts {
271+
artifact(jar) {
272+
group = "dev.compactmods.nightly"
273+
}
274+
artifact(apiJar) {
275+
classifier = "api"
276+
}
277+
}
278+
}
261279
}
262280

263281
repositories {

0 commit comments

Comments
 (0)