Skip to content

Commit

Permalink
Cleanup part two: CI/CD overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgrose committed Oct 20, 2024
1 parent fdef7aa commit 7e011ae
Show file tree
Hide file tree
Showing 28 changed files with 221 additions and 163 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
max_line_length = 120
insert_final_newline = true

[{*.kt,*.kts}]
Expand All @@ -10,3 +13,6 @@ ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
ij_kotlin_packages_to_use_import_on_demand = unset

[*.yml]
indent_size = 2
24 changes: 9 additions & 15 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ jobs:
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK 17
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Set gradlew execution permission
run: chmod u+x gradlew
# https://github.com/marketplace/actions/build-with-gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

# https://github.com/marketplace/actions/generate-version
- name: Get release version
Expand All @@ -36,26 +37,19 @@ jobs:
version-file: gradle.properties
version-file-extraction-pattern: '(?<=version=).+'

# https://github.com/marketplace/actions/semver-parser
- name: Parse release version
uses: apexskier/github-semver-parse@v1
id: semver
with:
version: ${{ env.RELEASE_VERSION }}
- name: Get changelog
run: ./gradlew getChangelog --console=plain -q --no-header --no-summary > LATEST_CHANGES.md

# https://github.com/marketplace/actions/gradle-build-action
- name: Build artifacts
uses: gradle/actions/setup-gradle@v3
with:
arguments: shadowJar
run: ./gradlew shadowJar

# https://github.com/marketplace/actions/create-release
- name: Create release
uses: ncipollo/release-action@v1
with:
name: Gateway ${{ env.RELEASE_VERSION }}
tag: v${{ env.RELEASE_VERSION }}
generateReleaseNotes: true
bodyFile: 'LATEST_CHANGES.md'
artifacts: 'build/libs/*.jar'
prerelease: ${{ !!steps.semver.outputs.prerelease }}
prerelease: ${{ !!env.RELEASE_VERSION_PRERELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}
45 changes: 17 additions & 28 deletions .github/workflows/pull_request_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches:
- stable
- develop
- dev

paths:
- '**/*.kt'
Expand All @@ -19,47 +19,36 @@ jobs:
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK 17
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin

- name: Set gradlew execution permission
run: chmod u+x gradlew
# https://github.com/marketplace/actions/build-with-gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

# https://github.com/marketplace/actions/gradle-build-action
- name: Build artifacts
uses: gradle/actions/setup-gradle@v3
with:
arguments: shadowJar
run: ./gradlew shadowJar

ktlint:
detekt:
runs-on: ubuntu-latest

steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/run-ktlint-with-reviewdog
- uses: ScaCap/[email protected]
# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK
uses: actions/setup-java@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
ktlint_version: '1.3.1'
reporter: github-pr-review
fail_on_error: true

detekt:
runs-on: ubuntu-latest
java-version: 21
distribution: temurin

steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v4
# https://github.com/marketplace/actions/build-with-gradle
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

# https://github.com/marketplace/actions/run-detekt-with-reviewdog
- name: Run detekt with reviewdog
uses: alaegin/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
detekt_config: config/detekt/detekt.yml
detekt_build_upon_default_config: true
- name: Run Detekt
run: ./gradlew detekt
7 changes: 7 additions & 0 deletions .idea/detekt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/developer-tools.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.6.4 - 2024-10-20

### Added

- A better changelog (this)
- Quality of life enhancements for development

### Changed

- Some minor fixes to Discord commands to have consistent punctuation
- Moved Discord strings to a new location to support future i18n
- Updated Kordex and relevant plugins

### Removed

- Unnecessary plugin build steps
75 changes: 30 additions & 45 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import dev.kordex.gradle.plugins.kordex.DataCollection
import io.github.klahap.dotenv.DotEnvBuilder.Companion.dotEnv
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kordex)
alias(libs.plugins.shadow)
alias(libs.plugins.dotenv)
alias(libs.plugins.run.paper)
alias(libs.plugins.ktlint)
alias(libs.plugins.detekt)
alias(libs.plugins.qodana)
alias(libs.plugins.changelog)
}

val version: String by project
Expand All @@ -20,54 +21,47 @@ val jvmTargetVersion: String by project
val kotlinTargetVersion: String by project
val minecraftTestVersion: String by project

val ktlintVersion: String by project
val detektVersion: String by project

project.group = group
project.version = version

kordEx {
jvmTarget = jvmTargetVersion.toInt()

bot {
// See https://docs.kordex.dev/data-collection.html
dataCollection(DataCollection.Standard)
}

i18n {
classPackage = "gateway.i18n"
translationBundle = "discord.strings"
}
}

repositories {
mavenCentral()
gradlePluginPortal()
maven("https://repo.kordex.dev/snapshots/")
maven("https://repo.papermc.io/repository/maven-public/")
maven("https://jitpack.io")
}

dependencies {
detektPlugins(libs.detekt.formatting)
compileOnly(libs.paper.api)
implementation(libs.bundles.hoplite)
implementation(libs.kaml)
implementation(libs.tegral)
}

detekt {
config.from("config/detekt/detekt.yml")
buildUponDefaultConfig = true
toolVersion = detektVersion
}

ktlint {
version = ktlintVersion
}

kordEx {
jvmTarget = jvmTargetVersion.toInt()

bot {
// See https://docs.kordex.dev/data-collection.html
dataCollection(DataCollection.Standard)

mainClass = "com.rose.gateway.discord.bot.DiscordBotKt"
}
config.from("config/detekt/detekt.yml")
}

tasks {
compileKotlin {
compilerOptions {
jvmTarget = JvmTarget.fromTarget(jvmTargetVersion)
apiVersion = KotlinVersion.fromVersion(kotlinTargetVersion)
languageVersion = KotlinVersion.fromVersion(kotlinTargetVersion)
}
}

Expand All @@ -79,30 +73,21 @@ tasks {
}
}

jar.configure {
onlyIf { false }
}

shadowJar {
archiveBaseName.set(rootProject.name)
archiveClassifier.set("")
archiveVersion.set(rootProject.version.toString())
archiveBaseName = rootProject.name
archiveClassifier = ""
archiveVersion = rootProject.version.toString()
mergeServiceFiles()
}

runServer {
this.minecraftVersion(minecraftTestVersion)
}

detekt.configure {
mustRunAfter(ktlintFormat)
}

create("runLints") {
dependsOn(ktlintFormat, detekt)
}

clean {
delete("build")
version = minecraftTestVersion

// Adding environment variables useful for testing
environment(
dotEnv {
addFile("$rootDir/dev.env")
},
)
}
}
2 changes: 2 additions & 0 deletions dev.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Kordex look at this
ENVIRONMENT=dev
10 changes: 2 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Project info
version=1.6.3
version=1.6.4
group=com.rose.gateway
# Target versions for compiled app
# Target version for compiled app
jvmTargetVersion=21
kotlinTargetVersion=2.0
# Version to use for testing
minecraftTestVersion=1.21.1
# Code style configuration
# https://github.com/pinterest/ktlint
ktlintVersion=1.3.1
# https://detekt.dev/
detektVersion=1.23.7
Loading

0 comments on commit 7e011ae

Please sign in to comment.