Skip to content

Commit

Permalink
Overhaul CI processes into smaller, reusable workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
robotgryphon committed Apr 4, 2024
1 parent a87d3b7 commit 059746e
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 70 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: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/src/generated/resources
79 changes: 14 additions & 65 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 @@ -25,7 +25,6 @@ jobs:
fetch-depth: 150
fetch-tags: true
submodules: true

- name: Version
id: version
uses: paulhatch/[email protected]
Expand All @@ -35,71 +34,21 @@ jobs:
search_commit_body: true

datagen:
name: Data Generators
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: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/src/generated/resources

publish-gh-package:
name: Publish Github Package - Nightly
runs-on: ubuntu-22.04
needs: [ vars, datagen ]
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/src/generated/resources

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

publish:
needs: [vars, datagen]
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: Release Variables

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/src/generated/resources

- name: Publish
run: ./gradlew :neoforge:publish
env:
VERSION: ${{ inputs.version }}
GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 changes: 73 additions & 0 deletions .github/workflows/tagged-version-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Creates releases on Curseforge and Github Releases based on v* tags
name: Tagged Version Release

on:
workflow_dispatch:

jobs:
vars:
name: Gather Variables
uses: ./.github/workflows/variables-release.yml
secrets: inherit

datagen:
name: Build
needs: [vars]
uses: ./.github/workflows/datagen.yml
secrets: inherit
with:
version: ${{ needs.vars.outputs.modVersion }}

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

release-gh:
name: Make Github Release
runs-on: ubuntu-20.04
needs: [vars, publish]
steps:
- name: Download Build Results
uses: actions/download-artifact@v4
with:
name: libs
path: build-out

- name: Create GitHub Release
uses: "marvinpinto/action-automatic-releases@latest"
with:
title: "Release ${{ needs.vars.outputs.modVersion }}"
automatic_release_tag: "${{ needs.vars.outputs.modVersion }}"
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
files: |
build/libs/simplehoney-neoforge-${{ needs.vars.outputs.modVersion }}.jar
# build/libs/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}-api.jar

release-cf:
name: Make Curseforge Release
runs-on: ubuntu-20.04
needs: [vars, publish]
steps:
- name: Download Build Results
uses: actions/download-artifact@v4
with:
name: libs
path: build-out

- name: Full File
id: filename
run: echo "::set-output name=fullpath::build-out/simplehoney-neoforge-${{ needs.vars.outputs.modVersion }}.jar"

- name: Create CurseForge Release
uses: itsmeow/curseforge-upload@master
with:
token: ${{ secrets.CURSEFORGE_TOKEN }}
project_id: ${{ secrets.CF_PROJECT_ID }}
game_endpoint: minecraft
file_path: ${{ steps.filename.outputs.fullpath }}
game_versions: java:Java 17,NeoForge
release_type: beta
59 changes: 59 additions & 0 deletions .github/workflows/variables-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release Variables

on:
workflow_call:
outputs:
mcVersion:
description: "Minecraft Version"
value: ${{ jobs.vars.outputs.mcVersion }}
neoVersion:
description: "Neoforge Version"
value: ${{ jobs.vars.outputs.neoVersion }}
modVersion:
description: "Mod Version"
value: ${{ jobs.vars.outputs.modVersion }}

jobs:
vars:
name: Get Variables
runs-on: ubuntu-latest
outputs:
mcVersion: ${{steps.minecraft.outputs.version}}
neoVersion: ${{steps.neoforge.outputs.version}}
modVersion: ${{steps.version.outputs.version}}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 150
fetch-tags: 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: Version
id: version
uses: paulhatch/[email protected]
with:
change_path: "neoforge"
version_format: "${major}.${minor}.${patch}"
search_commit_body: true

- name: MC Version
id: minecraft
run: ./gradlew mcVersion -q >> "$GITHUB_OUTPUT"
env:
VERSION: ${{ steps.version.outputs.version }}

- name: NeoForge Version
id: neoforge
run: ./gradlew neoVersion -q >> "$GITHUB_OUTPUT"
env:
VERSION: ${{ steps.version.outputs.version }}
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tasks.create("mcVersion") {
doFirst {
val mc = libraries.versions.minecraft.get()
println($"version=$mc")
}
}

tasks.create("neoVersion") {
doFirst {
val neo = libraries.versions.neoforge.get()
println($"version=$neo")
}
}
5 changes: 4 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
org.gradle.debug=false
org.gradle.debug=false

## Mod Properties
mod_id=simplehoney
4 changes: 2 additions & 2 deletions neoforge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ tasks.withType<Jar> {
"Specification-Vendor" to "CompactMods",
"Specification-Version" to "2",
"Implementation-Title" to "Simple Honey",
"Implementation-Version" to archiveVersion,
"Implementation-Version" to envVersion,
"Implementation-Vendor" to "CompactMods",
"Implementation-Timestamp" to now,
"Minecraft-Version" to libraries.versions.minecraft.get(),
Expand All @@ -187,7 +187,7 @@ tasks.withType<ProcessResources>().configureEach {
"mod_id" to modId,
"mod_name" to prop("mod_name"),
"mod_license" to prop("mod_license"),
"mod_version" to prop("mod_version"),
"mod_version" to envVersion,
"mod_authors" to prop("mod_authors"),
"mod_description" to prop("mod_description")
)
Expand Down
2 changes: 0 additions & 2 deletions neoforge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ neo_version_range=[20.4,)
loader_version_range=[2,)

## Mod Properties
mod_id=simplehoney
mod_name=Simple Honey
mod_license=MIT
mod_version=0.1.0
mod_group_id=dev.compactmods.simplehoney
mod_authors=RobotGryphon
mod_description=Because working with vanilla beehives is pain.

0 comments on commit 059746e

Please sign in to comment.