Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Nov 28, 2021
1 parent 218afb6 commit 5c12a9c
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/fabric-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: Fabric Build
on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [17] # Latest version
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- name: checkout repository
uses: actions/checkout@v2
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew fabric:build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: fabric/build/libs/
44 changes: 44 additions & 0 deletions .github/workflows/fabric-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Taken from Leuokcyte (https://github.com/NucleoidMC/leukocyte/blob/main/.github/workflows/release.yml)

name: Fabric Release

on:
release:
types:
- published
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and publish with Gradle
run: ./gradlew fabric:build fabric:modrinth fabric:curseforge --stacktrace
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
with:
files: 'fabric/build/libs/*-fabric.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/forge-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.

name: Forge Build
on: [pull_request, push]

jobs:
build:
strategy:
matrix:
# Use these Java versions
java: [17] # Latest version
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- name: checkout repository
uses: actions/checkout@v2
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- name: make gradle wrapper executable
if: ${{ runner.os != 'Windows' }}
run: chmod +x ./gradlew
- name: build
run: ./gradlew forge:build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' }}
uses: actions/upload-artifact@v2
with:
name: Artifacts
path: forge/build/libs/
44 changes: 44 additions & 0 deletions .github/workflows/forge-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Taken from Leuokcyte (https://github.com/NucleoidMC/leukocyte/blob/main/.github/workflows/release.yml)

name: Forge Release

on:
release:
types:
- published
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/cache@v2
with:
path: |
~/.gradle/loom-cache
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
gradle-
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build and publish with Gradle
run: ./gradlew forge:build forge:curseforge forge:modrinth --stacktrace
env:
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

- name: Upload GitHub release
uses: AButler/upload-release-assets@v2.0
with:
files: 'forge/build/libs/*-forge.jar'
repo-token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# TraderNPCs
A Taterzens addon that adds ability to create GUI traders.
A [Taterzens](https://github.com/samolego/Taterzens) addon that adds ability to create GUI traders.

## Features
* simple GUI editing
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "0.10.0-SNAPSHOT" apply false

id 'com.matthewprenger.cursegradle' version '1.4.0'
id "com.modrinth.minotaur" version "1.1.0"
}

architectury {
Expand Down
Binary file added common/src/main/resources/tradersnpcs/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import com.modrinth.minotaur.TaskModrinthUpload

plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"

id 'com.matthewprenger.cursegradle'
id "com.modrinth.minotaur"
}

architectury {
platformSetupLoomIde()
fabric()
}

def ENV = System.getenv();

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
Expand Down Expand Up @@ -76,3 +83,49 @@ publishing {
// Add repositories to publish to here.
}
}


// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle
curseforge {
if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}

project {
id = "550916"
changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}"
releaseType = "release"
addGameVersion "${project.minecraft_version}"
addGameVersion "Fabric"

mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")) {
displayName = "[${project.minecraft_version}] TraderNPCs ${version} [Fabric]"
}

afterEvaluate {
uploadTask.dependsOn("remapJar")
}
}

options {
forgeGradleIntegration = false
}
}

task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) {
onlyIf {
ENV.MODRINTH_TOKEN
}

token = ENV.MODRINTH_TOKEN
projectId = "78ZQG4Et"
versionNumber = project.minecraft_version + "+" + version + "-fabric"
changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}"
versionName = "[${project.minecraft_version}] TraderNPCs ${version} [Fabric]"
releaseType = "release"

uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-fabric.jar")

addGameVersion("${project.minecraft_version}")
addLoader('fabric')
}
54 changes: 54 additions & 0 deletions forge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import com.modrinth.minotaur.TaskModrinthUpload

plugins {
id "com.github.johnrengelman.shadow" version "7.0.0"

id 'com.matthewprenger.cursegradle'
id "com.modrinth.minotaur"
}
loom {
forge {
Expand All @@ -12,6 +17,8 @@ architectury {
forge()
}

def ENV = System.getenv();

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
Expand Down Expand Up @@ -79,3 +86,50 @@ publishing {
// Add repositories to publish to here.
}
}



// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle
curseforge {
if (ENV.CURSEFORGE_API_KEY) {
apiKey = ENV.CURSEFORGE_API_KEY
}

project {
id = "550916"
changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}"
releaseType = "release"
addGameVersion "${project.minecraft_version}"
addGameVersion "Forge"

mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar")) {
displayName = "[${project.minecraft_version}] TraderNPCs ${version} [Forge]"
}

afterEvaluate {
uploadTask.dependsOn("remapJar")
}
}

options {
forgeGradleIntegration = false
}
}

task modrinth(type: TaskModrinthUpload, dependsOn: remapJar) {
onlyIf {
ENV.MODRINTH_TOKEN
}

token = ENV.MODRINTH_TOKEN
projectId = "78ZQG4Et"
versionNumber = project.minecraft_version + "+" + version + "-forge"
changelog = "A changelog can be found at https://github.com/samolego/TraderNPCs/releases/tag/${version}"
versionName = "[${project.minecraft_version}] TraderNPCs ${version} [Forge]"
releaseType = "release"

uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}-forge.jar")

addGameVersion("${project.minecraft_version}")
addLoader('forge')
}

0 comments on commit 5c12a9c

Please sign in to comment.