Skip to content

Commit

Permalink
Refactor CI into reusable workflow files
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Apr 8, 2024
1 parent 37d6416 commit 4941690
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 78 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/datagen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Data Generation

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

jobs:
datagen:
name: Data Generators
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: 17

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

- name: Data Generation
run: ./gradlew :neoforge-datagen:runData
env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Store Built Assets
if: success()
uses: actions/upload-artifact@v4
with:
name: generated-data
path: neoforge-main/src/generated/resources
101 changes: 23 additions & 78 deletions .github/workflows/nightly-builds.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Gradle Tests and Nightly (CI)
name: Publish and Announce Nightly Build

env:
GH_PKG_URL: "https://maven.pkg.github.com/${{ github.repository }}"
Expand All @@ -10,6 +10,8 @@ on:
- "README.md"
- "LICENSE"
- ".github/**/*"
- "**/*.gradle.kts"
- "**/gradle.properties"

jobs:
vars:
Expand All @@ -25,7 +27,6 @@ jobs:
fetch-depth: 150
fetch-tags: true
submodules: true

- name: Version
id: version
uses: paulhatch/[email protected]
Expand All @@ -34,85 +35,29 @@ jobs:
version_format: "${major}.${minor}.${patch}.${increment}-nightly"
search_commit_body: true

tests:
name: Gradle Tests
runs-on: ubuntu-22.04
needs: [ vars ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

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

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

- name: Data Generation
run: ./gradlew :neoforge-datagen:runData
env:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Store Built Assets
if: success()
uses: actions/upload-artifact@v4
with:
name: generated-data
path: neoforge-main/src/generated/resources

- name: Game Tests
run: ./gradlew :neoforge-main:runGameTestServer
env:
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
datagen:
needs: [vars]
uses: ./.github/workflows/datagen.yml
secrets: inherit
with:
version: ${{ needs.vars.outputs.version }}

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

publish-gh-package:
name: Publish Github Package - Nightly
runs-on: ubuntu-22.04
needs: [ vars, tests ]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true

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

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

- name: Pull Built Generated Data
uses: actions/download-artifact@v4
with:
name: generated-data
path: neoforge-main/src/generated/resources

- name: Publish
run: ./gradlew :neoforge-main:publish
env:
VERSION: ${{ needs.vars.outputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests:
needs: [datagen]
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 }}

announce:
name: Discord Announcement
needs: [ publish-gh-package ]
needs: [ publish ]
uses: ./.github/workflows/announce-latest-nightly.yml
secrets: inherit
42 changes: 42 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# 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: 17

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

- name: Pull Built Generated Data
uses: actions/download-artifact@v4
with:
name: generated-data
path: neoforge-main/src/generated/resources

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

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

jobs:
datagen:
name: Data Generators
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: 17

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

- name: Pull Built Generated Data
uses: actions/download-artifact@v4
with:
name: generated-data
path: neoforge-main/src/generated/resources

- name: Run Game Tests
run: ./gradlew :neoforge-main:runGameTestServer
env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

0 comments on commit 4941690

Please sign in to comment.