Skip to content

Commit

Permalink
Added the current bot version to /about; Changed CI to create relea…
Browse files Browse the repository at this point in the history
…ses when pushing to `root` branch.
  • Loading branch information
Laxystem committed Dec 14, 2023
1 parent 463ea23 commit 6e84c79
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 34 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ on:
- develop

pull_request:
branches-ignore:
- root

jobs:
build:
Expand All @@ -22,20 +24,12 @@ jobs:
java-version: 17
distribution: temurin

- name: Gradle (Build)
- name: Build
uses: gradle/gradle-build-action@v2

with:
arguments: build

- name: Upload artifacts (Main JAR)
uses: actions/upload-artifact@v3

with:
name: Main JAR
path: build/libs/*-all.jar
if-no-files-found: error

- name: Upload artifacts (JARs)
uses: actions/upload-artifact@v3

Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,12 @@ jobs:
java-version: 17
distribution: temurin

- name: Gradle (Build)
- name: Build
uses: gradle/gradle-build-action@v2

with:
arguments: build

- name: Upload artifacts (Main JAR)
uses: actions/upload-artifact@v3

with:
name: Main JAR
path: build/libs/*-all.jar
if-no-files-found: error

- name: Upload artifacts (JARs)
uses: actions/upload-artifact@v3

Expand Down
35 changes: 25 additions & 10 deletions .github/workflows/root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-tags: true

- name: Set up Java
uses: actions/setup-java@v4
Expand All @@ -19,25 +21,38 @@ jobs:
java-version: 17
distribution: temurin

- name: Gradle (Build)
- name: Build
uses: gradle/gradle-build-action@v2

with:
arguments: build
dependency-graph: generate-and-submit

- name: Upload artifacts (Main JAR)
uses: actions/upload-artifact@v3

with:
name: Main JAR
path: build/libs/*-all.jar
if-no-files-found: error

- name: Upload artifacts (JARs)
- name: Upload artifacts
uses: actions/upload-artifact@v3

with:
name: JARs
path: build/libs/*.jar
if-no-files-found: warn

- name: Validate version
id: version
run: |
VERSION=$(cat .version)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
if git show-ref --tags --verify --quiet "refs/tags/${VERSION}"; then
echo "Version ${VERSION} was already released"
exit 0
fi
- name: Release artifacts
uses: marvinpinto/action-automatic-releases@v1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
automatic_release_tag: ${{ steps.version.outputs.version }}
files: |
build/libs/*.jar
LICENSE.md
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.0-alpha
23 changes: 18 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "quest.laxla"
version = "0.0.1"
version = file(".version").readText()

repositories {
google()
Expand Down Expand Up @@ -43,14 +43,23 @@ dependencies {
runtimeOnly("ch.qos.logback:logback-classic:$logback")
}

val generatedResources = layout.buildDirectory.dir("generated/resources")

tasks.processResources {
from(generatedResources)

doFirst {
generatedResources.orNull?.run {
asFile.mkdirs()
file(".version").asFile.writeText(version.toString())
}
}
}

application {
mainClass = "quest.laxla.trouper.AppKt"
}

val jvm: String by project

tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = jvm }

tasks.jar {
manifest {
attributes(
Expand All @@ -59,6 +68,10 @@ tasks.jar {
}
}

val jvm: String by project

tasks.withType<KotlinCompile> { kotlinOptions.jvmTarget = jvm }

java {
val java = JavaVersion.toVersion(jvm)
sourceCompatibility = java
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/quest/laxla/trouper/AboutExtension.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AboutExtension : TrouperExtension() {
allowedMentions()

embed {
title = "About ${self.effectiveName}"
title = "About ${self.effectiveName}" + if (version == null) "" else " `$version`"
thumbnail { url = avatar }

if (isDevelopmentEnvironment) field {
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/quest/laxla/trouper/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ val license = envOrNull("LICENSE")
val licenseUrl = envOrNull("LICENSE_URL")
val donateUrl = envOrNull("DONATE_URL")
val repoUrl = envOrNull("REPO_URL")
val version = AboutExtension::class.java.getResourceAsStream("/.version")?.bufferedReader()?.use { it.readText() }

fun main() = runBlocking {
ExtensibleBot(token) {
Expand Down

0 comments on commit 6e84c79

Please sign in to comment.