Skip to content

Commit 3501cd6

Browse files
committed
Update CI to provide git versions
1 parent 3d26a54 commit 3501cd6

File tree

3 files changed

+116
-81
lines changed

3 files changed

+116
-81
lines changed

.github/workflows/ci-tests-nightly.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ jobs:
1818
runs-on: ubuntu-20.04
1919
outputs:
2020
release_type: ${{steps.cf_release_type.outputs.value }}
21+
version: ${{steps.version.outputs.version }}
22+
2123
steps:
2224
- name: Checkout
2325
uses: actions/[email protected]
@@ -29,6 +31,20 @@ jobs:
2931
path: './gradle.properties'
3032
property: 'cf_release_type'
3133

34+
- name: Find Current Tag
35+
id: current
36+
uses: jimschubert/query-tag-action@v1
37+
with:
38+
include: 'v*'
39+
exclude: '*-rc*'
40+
commit-ish: '@'
41+
skip-unshallow: 'true'
42+
43+
- name: Semver Version
44+
id: version
45+
run: |
46+
version=$(echo "${{steps.current.outputs.tag}}" | cut -dv -f2)
47+
echo "::set-output name=version::$version"
3248
tests:
3349
name: Gradle Tests
3450
runs-on: ubuntu-20.04
@@ -106,10 +122,16 @@ jobs:
106122

107123
- name: Generate Resources
108124
run: ./gradlew runData
125+
env:
126+
CC_RELEASE: false
127+
CC_SEMVER_VERSION: ${{ needs.vars.outputs.version }}
128+
CC_BUILD_NUM: "0"
109129

110130
- name: Publish gradle nightly jar
111131
run: ./gradlew publishNightlyPublicationToGitHubPackagesRepository
112132
env:
113-
CM_RELEASE: false
133+
CC_RELEASE: false
134+
CC_SEMVER_VERSION: ${{ needs.vars.outputs.version }}
135+
CC_BUILD_NUM: "0"
114136
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
115137
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tagged-release.yml

Lines changed: 90 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
# Creates releases on Curseforge and Github Releases based on v* tags
2-
name: Latest Tag
2+
name: Tagged Commit Release
33

44
on:
55
workflow_dispatch:
66

77
jobs:
88
vars:
9-
name: Get Variables
9+
name: Gather Variables
1010
runs-on: ubuntu-20.04
1111
outputs:
1212
release_type: ${{steps.cf_release_type.outputs.value }}
1313
cf_project: ${{steps.cf_project.outputs.value }}
14-
mod_version: ${{steps.mod_version.outputs.value }}
1514
mod_id: ${{steps.mod_id.outputs.value }}
15+
version: ${{steps.version.outputs.version }}
16+
1617
steps:
1718
- name: Checkout
1819
uses: actions/checkout@v2
1920

21+
- name: Unshallow
22+
run: git fetch --prune --unshallow
23+
2024
- name: Release Type
2125
id: cf_release_type
2226
uses: christian-draeger/[email protected]
@@ -31,20 +35,28 @@ jobs:
3135
path: './gradle.properties'
3236
property: 'cf_project'
3337

34-
- name: Mod Version
35-
id: mod_version
36-
uses: christian-draeger/[email protected]
37-
with:
38-
path: './gradle.properties'
39-
property: 'mod_version'
40-
4138
- name: Mod ID
4239
id: mod_id
4340
uses: christian-draeger/[email protected]
4441
with:
4542
path: './gradle.properties'
4643
property: 'mod_id'
4744

45+
- name: Find Current Tag
46+
id: current
47+
uses: jimschubert/query-tag-action@v1
48+
with:
49+
include: 'v*'
50+
exclude: '*-rc*'
51+
commit-ish: '@'
52+
skip-unshallow: 'true'
53+
54+
- name: Semver Version
55+
id: version
56+
run: |
57+
version=$(echo "${{steps.current.outputs.tag}}" | cut -dv -f2)
58+
echo "::set-output name=version::$version"
59+
4860
changelog:
4961
name: Generate Changelog (tags)
5062
runs-on: ubuntu-20.04
@@ -114,22 +126,40 @@ jobs:
114126
distribution: 'temurin'
115127
java-version: "17"
116128

117-
- name: Cache Gradle packages
118-
uses: actions/cache@v2
119-
with:
120-
path: |
121-
~/.gradle/caches
122-
~/.gradle/wrapper
123-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
124-
restore-keys: ${{ runner.os }}-gradle-
125-
126129
- name: Grant execute permission for gradlew
127130
run: chmod +x gradlew
128131

129-
- name: Build JAR with Gradle
130-
run: ./gradlew build -x test
132+
- name: Create datagen assets
133+
run: ./gradlew runData
134+
timeout-minutes: 15
135+
env:
136+
CC_RELEASE: true
137+
CC_SEMVER_VERSION: ${{ needs.vars.outputs.version }}
138+
CC_BUILD_NUM: "0"
139+
140+
- name: Test JAR with GameTest Server
141+
run: ./gradlew runGameTestServer
142+
timeout-minutes: 20
143+
env:
144+
CC_SEMVER_VERSION: ${{ needs.vars.outputs.version }}
145+
CC_BUILD_NUM: "0"
146+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
147+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148+
149+
- name: Upload build failure
150+
if: failure()
151+
uses: actions/upload-artifact@v3
152+
with:
153+
name: test-data
154+
path: run/gametest
155+
156+
- name: Build JAR
157+
run: ./gradlew build
158+
timeout-minutes: 10
131159
env:
132-
CM_RELEASE: true
160+
CC_RELEASE: true
161+
CC_SEMVER_VERSION: ${{ needs.vars.outputs.version }}
162+
CC_BUILD_NUM: "0"
133163
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
134164
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135165

@@ -138,8 +168,8 @@ jobs:
138168
with:
139169
name: libs
140170
path: |
141-
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}.jar
142-
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}-api.jar
171+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}.jar
172+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}-api.jar
143173
144174
view:
145175
name: View Changelog Output
@@ -153,8 +183,8 @@ jobs:
153183
path: changelog
154184
- run: cat changelog/CHANGELOG.md
155185

156-
release:
157-
name: Make Releases
186+
release-gh:
187+
name: Make Github Release
158188
runs-on: ubuntu-20.04
159189
needs: [changelog, vars, jar]
160190
steps:
@@ -176,18 +206,38 @@ jobs:
176206
- name: Create GitHub Release
177207
uses: "marvinpinto/action-automatic-releases@latest"
178208
with:
179-
title: "Release ${{ github.event.release.tag_name }}"
180-
automatic_release_tag: "latest"
209+
title: "Release ${{ needs.vars.outputs.version }}"
210+
automatic_release_tag: "${{ needs.vars.outputs.version }}"
181211
repo_token: "${{ secrets.GITHUB_TOKEN }}"
182212
prerelease: false
183213
files: |
184214
changelog/CHANGELOG.md
185-
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}.jar
186-
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}-api.jar
215+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}.jar
216+
build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}-api.jar
217+
218+
release-cf:
219+
name: Make Curseforge Release
220+
runs-on: ubuntu-20.04
221+
needs: [changelog, vars, jar]
222+
steps:
223+
- name: Download Build Results
224+
uses: actions/download-artifact@v2
225+
with:
226+
name: libs
227+
path: build-out
228+
- name: Download Changelog Results
229+
uses: actions/download-artifact@v2
230+
with:
231+
name: out
232+
path: changelog
233+
234+
- name: Load Changelog File
235+
id: changelog
236+
run: echo ::set-output name=changelog::$(cat changelog/CHANGELOG.md)
187237

188238
- name: Full File
189239
id: filename
190-
run: echo "::set-output name=fullpath::build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.mod_version }}.jar"
240+
run: echo "::set-output name=fullpath::build-out/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}.jar"
191241

192242
- name: Create CurseForge Release
193243
uses: itsmeow/curseforge-upload@master
@@ -198,20 +248,14 @@ jobs:
198248
file_path: ${{ steps.filename.outputs.fullpath }}
199249
changelog: ${{ steps.changelog.outputs.changelog }}
200250
changelog_type: markdown
201-
game_versions: java:Java 8,Forge
251+
game_versions: java:Java 17,Forge
202252
release_type: ${{ needs.vars.outputs.release_type }}
203253

204254
publishMaven:
205255
name: Maven Release (GH Packages)
206256
runs-on: ubuntu-20.04
207257
needs: [changelog, vars, jar]
208258
steps:
209-
- name: Download Changelog Results
210-
uses: actions/download-artifact@v2
211-
with:
212-
name: out
213-
path: changelog
214-
215259
- name: Checkout
216260
uses: actions/checkout@v2
217261

@@ -221,21 +265,17 @@ jobs:
221265
distribution: 'temurin'
222266
java-version: "17"
223267

224-
- name: Cache Gradle packages
225-
uses: actions/cache@v2
226-
with:
227-
path: |
228-
~/.gradle/caches
229-
~/.gradle/wrapper
230-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
231-
restore-keys: ${{ runner.os }}-gradle-
232-
233268
- name: Grant execute permission for gradlew
234269
run: chmod +x gradlew
235270

236-
- name: Publish package
237-
run: ./gradlew publishMavenPublicationToGitHubPackagesRepository -x test
271+
- name: Generate Resources
272+
run: ./gradlew runData
273+
274+
- name: Publish gradle nightly jar
275+
run: ./gradlew publishReleasePublicationToGitHubPackagesRepository
238276
env:
239-
CM_RELEASE: "true"
277+
CC_RELEASE: true
278+
CC_SEMVER_VERSION: ${{ needs.vars.outputs.version }}
279+
CC_BUILD_NUM: "0"
240280
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
241281
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,38 +19,11 @@ plugins {
1919

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

22-
def semver = { ->
23-
try {
24-
def code = new ByteArrayOutputStream()
25-
exec {
26-
commandLine 'git', 'describe', '--tags', '--match', 'v*'
27-
standardOutput = code
28-
}
29-
30-
return code.toString().trim().substring(1).split('-')[0]
31-
}
32-
catch (ignored) {
33-
return "2.0.0";
34-
}
35-
}
36-
37-
def buildNumber = { ->
38-
try {
39-
def code = new ByteArrayOutputStream()
40-
exec {
41-
commandLine 'git', 'describe', '--tags', '--match', 'v*'
42-
standardOutput = code
43-
}
44-
45-
return Integer.parseInt(code.toString().trim().split('-')[1])
46-
}
47-
catch (ignored) {
48-
return 0;
49-
}
50-
}
22+
def semver = System.getenv("CC_SEMVER_VERSION")
23+
def buildNumber = System.getenv("CC_BUILD_NUM")
5124

5225
def nightlyVersion = "${semver}.${buildNumber}"
53-
def isRelease = (System.getenv("CM_RELEASE") ?: "false").equalsIgnoreCase("true")
26+
def isRelease = (System.getenv("CC_RELEASE") ?: "false").equalsIgnoreCase("true")
5427

5528
task getBuildInfo() {
5629
println("Mod ID: ${mod_id}")

0 commit comments

Comments
 (0)