Skip to content

Commit 1de4a11

Browse files
committed
Add build scripts and versioning
1 parent 956f1eb commit 1de4a11

File tree

5 files changed

+239
-0
lines changed

5 files changed

+239
-0
lines changed

.github/workflows/_build.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Data Generation
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
datagen:
12+
name: Build
13+
runs-on: ubuntu-22.04
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Set up JDK
19+
uses: actions/setup-java@v4
20+
with:
21+
distribution: temurin
22+
java-version: 21
23+
24+
- name: Setup Gradle
25+
uses: gradle/actions/setup-gradle@v4
26+
27+
- name: Build
28+
run: ./gradlew :spatial-neoforge:build
29+
env:
30+
VERSION: ${{ inputs.version }}
31+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Store Compiled
35+
if: success()
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: build
39+
path: spatial/build
40+
41+
- name: Store Compiled
42+
if: success()
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: build-neo
46+
path: spatial-neoforge/build

.github/workflows/_publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# REQUIRES DATAGEN TO BE CALLED IN A JOB BEFORE THIS!!
2+
3+
name: Publish
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
version:
9+
required: true
10+
type: string
11+
12+
jobs:
13+
publish:
14+
name: Publish Code as Github Package - ${{ inputs.version }}
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
submodules: true
21+
22+
- name: Set up JDK
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: temurin
26+
java-version: 21
27+
28+
- name: Setup Gradle
29+
uses: gradle/actions/setup-gradle@v4
30+
31+
- name: Pull Compilation Data
32+
uses: actions/download-artifact@v4
33+
with:
34+
name: build
35+
path: spatial/build
36+
37+
- name: Pull Compilation Data (Main)
38+
uses: actions/download-artifact@v4
39+
with:
40+
name: build-neo
41+
path: spatial-neoforge/build
42+
43+
- name: Publish
44+
run: ./gradlew :spatial:publish
45+
env:
46+
VERSION: ${{ inputs.version }}
47+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Run Game Tests
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
10+
env:
11+
VERSION: ${{ inputs.version }}
12+
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
15+
jobs:
16+
run-tests:
17+
name: Run Game Tests
18+
runs-on: ubuntu-22.04
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
submodules: true
24+
25+
- name: Set up JDK
26+
uses: actions/setup-java@v4
27+
with:
28+
distribution: temurin
29+
java-version: 21
30+
31+
- name: Setup Gradle
32+
uses: gradle/actions/setup-gradle@v4
33+
34+
- name: Pull Compilation Data
35+
uses: actions/download-artifact@v4
36+
with:
37+
name: build
38+
path: spatial/build
39+
40+
- name: Pull Compilation Data (Main)
41+
uses: actions/download-artifact@v4
42+
with:
43+
name: build-neo
44+
path: spatial-neoforge/build
45+
46+
- name: Run Game Tests
47+
run: ./gradlew :spatial-neoforge:runGameTestServer
48+
49+
- name: Upload test failure
50+
if: failure()
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: test-data
54+
path: run/gametest
55+
56+
- name: Run JUnit Tests
57+
run: ./gradlew :spatial-neoforge:test
58+
59+
- name: Upload test reports on failure
60+
if: failure()
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: test-reports
64+
path: spatial-neoforge/build/reports
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Publish and Announce Nightly Build
2+
3+
env:
4+
GH_PKG_URL: "https://maven.pkg.github.com/${{ github.repository }}"
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
paths-ignore:
10+
- "README.md"
11+
- "LICENSE"
12+
- ".github/**/*"
13+
- "**/*.gradle.kts"
14+
- "**/gradle.properties"
15+
16+
jobs:
17+
vars:
18+
name: Get Variables
19+
runs-on: ubuntu-22.04
20+
outputs:
21+
version: ${{steps.version.outputs.version}}
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/checkout@v4
26+
with:
27+
fetch-depth: 150
28+
fetch-tags: true
29+
30+
- name: Version
31+
id: version
32+
uses: paulhatch/[email protected]
33+
with:
34+
change_path: "spatial"
35+
version_format: "${major}.${minor}.${patch}"
36+
search_commit_body: true
37+
38+
build:
39+
needs: [ vars ]
40+
uses: ./.github/workflows/_build.yml
41+
secrets: inherit
42+
with:
43+
version: ${{ needs.vars.outputs.version }}
44+
45+
tests:
46+
needs: [ build, vars ]
47+
uses: ./.github/workflows/_run-gametests.yml
48+
secrets: inherit
49+
with:
50+
version: ${{ needs.vars.outputs.version }}
51+
52+
publish:
53+
needs: [ vars, tests ]
54+
uses: ./.github/workflows/_publish.yml
55+
secrets: inherit
56+
with:
57+
version: ${{ needs.vars.outputs.version }}

spatial/build.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
var envVersion: String = System.getenv("VERSION") ?: "0.0.1"
2+
if (envVersion.startsWith("v"))
3+
envVersion = envVersion.trimStart('v')
4+
15
plugins {
26
id("idea")
37
id("java")
8+
id("maven-publish")
49

510
alias(neoforged.plugins.moddev)
611
}
@@ -17,4 +22,23 @@ java {
1722

1823
neoForge {
1924
neoFormVersion = neoforged.versions.neoform
25+
}
26+
27+
28+
val PACKAGES_URL = System.getenv("GH_PKG_URL") ?: "https://maven.pkg.github.com/compactmods/spatial"
29+
publishing {
30+
publications.register<MavenPublication>("spatial") {
31+
from(components.getByName("java"))
32+
}
33+
34+
repositories {
35+
// GitHub Packages
36+
maven(PACKAGES_URL) {
37+
name = "GitHubPackages"
38+
credentials {
39+
username = System.getenv("GITHUB_ACTOR")
40+
password = System.getenv("GITHUB_TOKEN")
41+
}
42+
}
43+
}
2044
}

0 commit comments

Comments
 (0)