Skip to content

Commit

Permalink
Add build scripts and versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Nov 17, 2024
1 parent 956f1eb commit 1de4a11
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Data Generation

on:
workflow_call:
inputs:
version:
required: true
type: string

jobs:
datagen:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Build
run: ./gradlew :spatial-neoforge:build
env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Store Compiled
if: success()
uses: actions/upload-artifact@v4
with:
name: build
path: spatial/build

- name: Store Compiled
if: success()
uses: actions/upload-artifact@v4
with:
name: build-neo
path: spatial-neoforge/build
48 changes: 48 additions & 0 deletions .github/workflows/_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# REQUIRES DATAGEN TO BE CALLED IN A JOB BEFORE THIS!!

name: Publish

on:
workflow_call:
inputs:
version:
required: true
type: string

jobs:
publish:
name: Publish Code as Github Package - ${{ inputs.version }}
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Pull Compilation Data
uses: actions/download-artifact@v4
with:
name: build
path: spatial/build

- name: Pull Compilation Data (Main)
uses: actions/download-artifact@v4
with:
name: build-neo
path: spatial-neoforge/build

- name: Publish
run: ./gradlew :spatial:publish
env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64 changes: 64 additions & 0 deletions .github/workflows/_run-gametests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Run Game Tests

on:
workflow_call:
inputs:
version:
required: true
type: string

env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
run-tests:
name: Run Game Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Pull Compilation Data
uses: actions/download-artifact@v4
with:
name: build
path: spatial/build

- name: Pull Compilation Data (Main)
uses: actions/download-artifact@v4
with:
name: build-neo
path: spatial-neoforge/build

- name: Run Game Tests
run: ./gradlew :spatial-neoforge:runGameTestServer

- name: Upload test failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-data
path: run/gametest

- name: Run JUnit Tests
run: ./gradlew :spatial-neoforge:test

- name: Upload test reports on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-reports
path: spatial-neoforge/build/reports
57 changes: 57 additions & 0 deletions .github/workflows/nightly-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish and Announce Nightly Build

env:
GH_PKG_URL: "https://maven.pkg.github.com/${{ github.repository }}"

on:
workflow_dispatch:
push:
paths-ignore:
- "README.md"
- "LICENSE"
- ".github/**/*"
- "**/*.gradle.kts"
- "**/gradle.properties"

jobs:
vars:
name: Get Variables
runs-on: ubuntu-22.04
outputs:
version: ${{steps.version.outputs.version}}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 150
fetch-tags: true

- name: Version
id: version
uses: paulhatch/[email protected]
with:
change_path: "spatial"
version_format: "${major}.${minor}.${patch}"
search_commit_body: true

build:
needs: [ vars ]
uses: ./.github/workflows/_build.yml
secrets: inherit
with:
version: ${{ needs.vars.outputs.version }}

tests:
needs: [ build, vars ]
uses: ./.github/workflows/_run-gametests.yml
secrets: inherit
with:
version: ${{ needs.vars.outputs.version }}

publish:
needs: [ vars, tests ]
uses: ./.github/workflows/_publish.yml
secrets: inherit
with:
version: ${{ needs.vars.outputs.version }}
24 changes: 24 additions & 0 deletions spatial/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
var envVersion: String = System.getenv("VERSION") ?: "0.0.1"
if (envVersion.startsWith("v"))
envVersion = envVersion.trimStart('v')

plugins {
id("idea")
id("java")
id("maven-publish")

alias(neoforged.plugins.moddev)
}
Expand All @@ -17,4 +22,23 @@ java {

neoForge {
neoFormVersion = neoforged.versions.neoform
}


val PACKAGES_URL = System.getenv("GH_PKG_URL") ?: "https://maven.pkg.github.com/compactmods/spatial"
publishing {
publications.register<MavenPublication>("spatial") {
from(components.getByName("java"))
}

repositories {
// GitHub Packages
maven(PACKAGES_URL) {
name = "GitHubPackages"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
}

0 comments on commit 1de4a11

Please sign in to comment.