mirror of
https://codeberg.org/moonleay/Gimble.git
synced 2024-11-23 07:12:50 +00:00
chore/add-ci (#3)
Added ci for dev and release builds. Reviewed-on: https://codeberg.org/moonleay/Gimbal/pulls/3 Co-authored-by: moonleay <contact@moonleay.net> Co-committed-by: moonleay <contact@moonleay.net>
This commit is contained in:
parent
68e9eeceb6
commit
302f486f1c
4 changed files with 141 additions and 11 deletions
42
.forgejo/workflows/build-dev.yml
Normal file
42
.forgejo/workflows/build-dev.yml
Normal file
|
@ -0,0 +1,42 @@
|
|||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- refs/tags/
|
||||
|
||||
jobs:
|
||||
dev:
|
||||
runs-on: nodebullshit
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
name: Checkout
|
||||
|
||||
- name: Set short git commit reference
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: https://github.com/actions/setup-java@v4
|
||||
name: Setup Java
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- uses: https://github.com/gradle/actions/setup-gradle@v3
|
||||
name: Setup Gradle
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
- run: ./gradlew runDatagen
|
||||
name: Generate assets
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
- run: ./gradlew build
|
||||
name: Build project
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
- run: ./gradlew publish
|
||||
name: Upload
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
PACKAGE_REPO_KEY: ${{ secrets.PACKAGE_REPO_KEY }}
|
54
.forgejo/workflows/build-release.yml
Normal file
54
.forgejo/workflows/build-release.yml
Normal file
|
@ -0,0 +1,54 @@
|
|||
on:
|
||||
release:
|
||||
types:
|
||||
- released
|
||||
- prereleased
|
||||
- created
|
||||
- published
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: nodebullshit
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
name: Checkout
|
||||
|
||||
- name: Fetch the full git repository
|
||||
run: git fetch --prune --unshallow
|
||||
|
||||
- name: Set short git commit reference
|
||||
id: vars
|
||||
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: https://github.com/actions/setup-java@v4
|
||||
name: Setup Java
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
- uses: https://github.com/gradle/actions/setup-gradle@v3
|
||||
name: Setup Gradle
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
- run: ./gradlew runDatagen
|
||||
name: Generate assets
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
- run: ./gradlew build
|
||||
name: Build project
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
|
||||
- run: ./gradlew publish
|
||||
name: Upload
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
PACKAGE_REPO_KEY: ${{ secrets.PACKAGE_REPO_KEY }}
|
||||
|
||||
- run: ./gradlew modrinth
|
||||
name: Publish to Modrinth
|
||||
env:
|
||||
GIT_SHA_SHORT: ${{ steps.vars.outputs.sha_short }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
|
@ -27,10 +27,13 @@ plugins {
|
|||
`maven-publish`
|
||||
eclipse
|
||||
id("org.jetbrains.gradle.plugin.idea-ext")
|
||||
id("com.modrinth.minotaur") version "2.+"
|
||||
}
|
||||
|
||||
val mavenVersion = System.getenv("CI_COMMIT_TAG") ?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
||||
?: "0.3.0" //"0.0.0-SNAPSHOT"
|
||||
val ver = if ((System.getenv("GITHUB_REF") ?: "local").startsWith("refs/tags/"))
|
||||
System.getenv("GITHUB_REF_NAME") ?: "err" else System.getenv("GIT_SHA_SHORT") ?: "0.0.0"
|
||||
|
||||
val mavenVersion = ver
|
||||
val modId: String by project
|
||||
val modName: String by project
|
||||
|
||||
|
@ -184,17 +187,18 @@ publishing {
|
|||
}
|
||||
|
||||
repositories {
|
||||
if (System.getenv("CI_JOB_TOKEN") != null) {
|
||||
if (System.getenv("CI") != null) {
|
||||
maven {
|
||||
name = "GitLab"
|
||||
val projectId = System.getenv("CI_PROJECT_ID")
|
||||
val apiV4 = System.getenv("CI_API_V4_URL")
|
||||
url = uri("$apiV4/projects/$projectId/packages/maven")
|
||||
name = "Codeberg"
|
||||
val repoOwner = System.getenv("GITHUB_REPOSITORY_OWNER")
|
||||
val serverUrl = System.getenv("GITHUB_SERVER_URL")
|
||||
val accessToken = System.getenv("PACKAGE_REPO_KEY")
|
||||
url = uri("$serverUrl/api/packages/$repoOwner/maven")
|
||||
authentication {
|
||||
create("token", HttpHeaderAuthentication::class.java) {
|
||||
credentials(HttpHeaderCredentials::class.java) {
|
||||
name = "Job-Token"
|
||||
value = System.getenv("CI_JOB_TOKEN")
|
||||
create("header", HttpHeaderAuthentication::class.java) {
|
||||
credentials(HttpHeaderCredentials::class) {
|
||||
name = "Authorization"
|
||||
value = "token $accessToken"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,6 +207,33 @@ publishing {
|
|||
}
|
||||
}
|
||||
|
||||
// build.gradle.kts
|
||||
modrinth {
|
||||
token.set(System.getenv("MODRINTH_TOKEN")) // Remember to have the MODRINTH_TOKEN environment variable set or else this will fail - just make sure it stays private!
|
||||
projectId.set(modId) // This can be the project ID or the slug. Either will work!
|
||||
versionNumber.set(mavenVersion) // You don't need to set this manually. Will fail if Modrinth has this version already
|
||||
versionName.set("$modName $mavenVersion for $minecraftVersion")
|
||||
versionType.set("alpha") // This is the default -- can also be `beta` or `alpha`
|
||||
uploadFile.set(tasks.remapJar) // With Loom, this MUST be set to `remapJar` instead of `jar`!
|
||||
gameVersions.addAll(listOf(project.ext["minecraft.version"] as String)) // Must be an array, even with only one version
|
||||
loaders.add("fabric") // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
|
||||
changelog.set(
|
||||
"Changelog v$mavenVersion\n\nCheckout the changelog [on codeberg](${System.getenv("GITHUB_SERVER_URL") ?: ""}/${
|
||||
System.getenv(
|
||||
"GITHUB_REPOSITORY"
|
||||
) ?: ""
|
||||
}/releases/tag/${System.getenv("GITHUB_REF_NAME") ?: ""})"
|
||||
)
|
||||
dependencies { // A special DSL for creating dependencies
|
||||
// scope.type
|
||||
// The scope can be `required`, `optional`, `incompatible`, or `embedded`
|
||||
// The type can either be `project` or `version`
|
||||
required.project("fabric-api") // Creates a new required dependency on Fabric API
|
||||
required.project("fabric-language-kotlin")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rootProject.idea.project {
|
||||
this as ExtensionAware
|
||||
configure<ProjectSettings> {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
"authors": [
|
||||
"moonleay"
|
||||
],
|
||||
"contributors": [
|
||||
"Cookieso"
|
||||
],
|
||||
"icon": "assets/${modId}/logo.png",
|
||||
"contact": {
|
||||
"email": "contact@moonleay.net",
|
||||
|
|
Loading…
Reference in a new issue