diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-08-30 14:36:35 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-30 14:36:35 +0900 |
| commit | c9fc607df4c20b840d804ba6d8cfcfd8750a45c7 (patch) | |
| tree | 83de49ac98b2e6bf49783278a096304c7be9179c | |
| parent | 44132f3a73651fbd334a314fbc4ab47f5f1bbd5b (diff) | |
| parent | adb97b712043253afdfb8debcb413a676b7d9c2f (diff) | |
| download | LunaticChat-c9fc607df4c20b840d804ba6d8cfcfd8750a45c7.tar.gz LunaticChat-c9fc607df4c20b840d804ba6d8cfcfd8750a45c7.tar.bz2 LunaticChat-c9fc607df4c20b840d804ba6d8cfcfd8750a45c7.zip | |
Merge pull request #295 from m1sk9/fix/nightly-tags
fix: mark nightly builds with a `-nightly.<hash>` version and flatten CI artifacts
| -rw-r--r-- | .github/workflows/ci.yaml | 18 | ||||
| -rw-r--r-- | platform-paper/build.gradle.kts | 27 | ||||
| -rw-r--r-- | platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfo.kt | 9 | ||||
| -rw-r--r-- | platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfoTest.kt | 16 | ||||
| -rw-r--r-- | platform-velocity/build.gradle.kts | 26 | ||||
| -rw-r--r-- | website/src/docs/developers/resource.md | 6 | ||||
| -rw-r--r-- | website/src/docs/features/admin.md | 1 | ||||
| -rw-r--r-- | website/src/ja/docs/developers/resource.md | 6 | ||||
| -rw-r--r-- | website/src/ja/docs/features/admin.md | 1 | ||||
| -rwxr-xr-x | x | 6 |
10 files changed, 82 insertions, 34 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2acf15..740c521 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,14 +46,22 @@ jobs: - name: Build with shadowJar run: ./gradlew :platform-paper:shadowJar :platform-velocity:shadowJar -PisNightly=true --parallel --no-daemon - - name: Upload build artifacts + # One artifact per platform: a single glob path makes upload-artifact root the archive + # at libs/, so the JAR lands at the top level instead of nested build directories. + - name: Upload Paper build artifact uses: actions/upload-artifact@v7 if: success() with: - name: LunaticChat-${{ github.sha }} - path: | - platform-paper/build/libs/LunaticChat-*.jar - platform-velocity/build/libs/LunaticChat-*-velocity.jar + name: LunaticChat-paper-${{ github.sha }} + path: platform-paper/build/libs/LunaticChat-*.jar + retention-days: 7 + + - name: Upload Velocity build artifact + uses: actions/upload-artifact@v7 + if: success() + with: + name: LunaticChat-velocity-${{ github.sha }} + path: platform-velocity/build/libs/LunaticChat-*-velocity.jar retention-days: 7 build_dokka: diff --git a/platform-paper/build.gradle.kts b/platform-paper/build.gradle.kts index b62737a..2c95750 100644 --- a/platform-paper/build.gradle.kts +++ b/platform-paper/build.gradle.kts @@ -6,7 +6,22 @@ plugins { id("org.jetbrains.dokka") } -version = findProperty("paperVersion")?.toString() ?: "0.0.0" +val gitCommitHash: String = + providers + .exec { + commandLine("git", "rev-parse", "--short", "HEAD") + }.standardOutput + .asText + .get() + .trim() + +val isNightly: Boolean = providers.gradleProperty("isNightly").orNull?.toBoolean() ?: false + +// The nightly marker belongs in the version itself, not only in build-info.properties: +// a JAR named after the bare release version is indistinguishable from that release +// in the server log, /plugins and bug reports. +val baseVersion = findProperty("paperVersion")?.toString() ?: "0.0.0" +version = if (isNightly) "$baseVersion-nightly.$gitCommitHash" else baseVersion repositories { maven("https://repo.papermc.io/repository/maven-public/") { @@ -47,16 +62,6 @@ tasks { } processResources { - val gitCommitHash = - providers - .exec { - commandLine("git", "rev-parse", "--short", "HEAD") - }.standardOutput - .asText - .get() - .trim() - - val isNightly = providers.gradleProperty("isNightly").orNull?.toBoolean() ?: false val props = mapOf( "version" to project.version, diff --git a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfo.kt b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfo.kt index bac9107..41b2378 100644 --- a/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfo.kt +++ b/platform-paper/src/main/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfo.kt @@ -19,5 +19,12 @@ object BuildInfo { val isNightly: Boolean get() = channel == "nightly" - fun versionWithCommit(): String = "$version ($commitHash)" + fun versionWithCommit(): String = formatVersion(version, commitHash) + + // A nightly version already ends with the commit hash, so appending it again would + // make the copied version string repeat itself. + internal fun formatVersion( + version: String, + commitHash: String, + ): String = if (version.endsWith(commitHash)) version else "$version ($commitHash)" } diff --git a/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfoTest.kt b/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfoTest.kt new file mode 100644 index 0000000..65018a0 --- /dev/null +++ b/platform-paper/src/test/kotlin/dev/m1sk9/lunaticChat/paper/BuildInfoTest.kt @@ -0,0 +1,16 @@ +package dev.m1sk9.lunaticChat.paper + +import kotlin.test.Test +import kotlin.test.assertEquals + +class BuildInfoTest { + @Test + fun `stable version is shown with the commit hash appended`() { + assertEquals("1.3.0 (44132f3)", BuildInfo.formatVersion("1.3.0", "44132f3")) + } + + @Test + fun `nightly version already carrying the commit hash is shown as is`() { + assertEquals("1.3.0-nightly.44132f3", BuildInfo.formatVersion("1.3.0-nightly.44132f3", "44132f3")) + } +} diff --git a/platform-velocity/build.gradle.kts b/platform-velocity/build.gradle.kts index 07f5b13..c259fc3 100644 --- a/platform-velocity/build.gradle.kts +++ b/platform-velocity/build.gradle.kts @@ -4,7 +4,21 @@ plugins { id("com.gradleup.shadow") } -version = findProperty("velocityVersion")?.toString() ?: "0.0.0" +val gitCommitHash: String = + providers + .exec { + commandLine("git", "rev-parse", "--short", "HEAD") + }.standardOutput + .asText + .get() + .trim() + +val isNightly: Boolean = providers.gradleProperty("isNightly").orNull?.toBoolean() ?: false + +// Velocity carries no build-info.properties, so the version is the only place a nightly +// build can announce itself. +val baseVersion = findProperty("velocityVersion")?.toString() ?: "0.0.0" +version = if (isNightly) "$baseVersion-nightly.$gitCommitHash" else baseVersion repositories { maven("https://repo.papermc.io/repository/maven-public/") { @@ -36,16 +50,6 @@ tasks { } processResources { - val gitCommitHash = - providers - .exec { - commandLine("git", "rev-parse", "--short", "HEAD") - }.standardOutput - .asText - .get() - .trim() - - val isNightly = providers.gradleProperty("isNightly").orNull?.toBoolean() ?: false val props = mapOf( "version" to project.version, diff --git a/website/src/docs/developers/resource.md b/website/src/docs/developers/resource.md index 543365d..67e6d57 100644 --- a/website/src/docs/developers/resource.md +++ b/website/src/docs/developers/resource.md @@ -14,7 +14,9 @@ A Gradle multi-module setup shares `engine` while building and releasing Paper / - `platform-velocity` — `version = velocityVersion`. `api(project(":engine"))`. velocity-api as `compileOnly`. Output is **`LunaticChat-<ver>-velocity.jar`** (distinguished by classifier) - `dokka` — aggregates engine/paper/velocity and includes the README in the HTML -Both platforms' `processResources` compute `version` / `gitCommitHash` / `channel` from the git short hash and `isNightly`, and token-expand them into `paper-plugin.yml` / `velocity-plugin.json` and `build-info.properties`. +Both platforms derive their version from `isNightly`: with `-PisNightly=true` the base version gains a `-nightly.<git short hash>` suffix, so a development build is never mistakable for the release of the same base version (`LunaticChat-1.3.0-nightly.44132f3.jar`). Without the flag the version stays the bare `paperVersion` / `velocityVersion`, which is what the release workflows build. + +`processResources` then token-expands `version` / `gitCommitHash` / `channel` into `paper-plugin.yml` / `velocity-plugin.json` and `build-info.properties`. ## Independent versioning @@ -44,7 +46,7 @@ The release target switches based on the tag pattern. `ci.yaml` runs on push to main / PR / manual dispatch. -- `build_plugin` — ktlintCheck → test + jacocoTestReport → upload to Codecov → nightly shadowJar (`-PisNightly=true`) → retain artifacts +- `build_plugin` — ktlintCheck → test + jacocoTestReport → upload to Codecov → nightly shadowJar (`-PisNightly=true`) → retain artifacts as `LunaticChat-paper-<sha>` / `LunaticChat-velocity-<sha>` (one per platform, each holding the JAR at the archive root) - `build_dokka` / `deploy_dokka` — generate Dokka → deploy to GitHub Pages (main push only) - `build_docs` — format/lint/build `website/` with bun → deploy to Cloudflare Workers (wrangler) (main push only) diff --git a/website/src/docs/features/admin.md b/website/src/docs/features/admin.md index 531f2e0..aa298ba 100644 --- a/website/src/docs/features/admin.md +++ b/website/src/docs/features/admin.md @@ -72,6 +72,7 @@ checkForUpdates: true Builds produced from the `main` branch outside of a release are marked as nightly, and the plugin says so rather than letting it go unnoticed. +- The version carries a `-nightly.<commit hash>` suffix (`1.3.0-nightly.44132f3`), so the JAR file name, `/plugins` and `/lc status` all tell it apart from the 1.3.0 release - Every player is warned on join that the build may be unstable, along with a pointer to GitHub Issues - `/lc status` shows the same warning, and displays the release channel in yellow instead of green diff --git a/website/src/ja/docs/developers/resource.md b/website/src/ja/docs/developers/resource.md index 0eea858..7bcc6c9 100644 --- a/website/src/ja/docs/developers/resource.md +++ b/website/src/ja/docs/developers/resource.md @@ -14,7 +14,9 @@ Gradle マルチモジュール構成で,engine を共有しつつ Paper / Vel - `platform-velocity` — `version = velocityVersion`.`api(project(":engine"))`.velocity-api を `compileOnly`.成果物は **`LunaticChat-<ver>-velocity.jar`** (classifier で区別) - `dokka` — engine/paper/velocity を集約し HTML に README を include -両プラットフォームの `processResources` は git short hash と `isNightly` から `version` / `gitCommitHash` / `channel` を算出し,`paper-plugin.yml` / `velocity-plugin.json` と `build-info.properties` にトークン展開します. +両プラットフォームのバージョンは `isNightly` から導出されます.`-PisNightly=true` を付けるとベースバージョンに `-nightly.<git short hash>` が付き (`LunaticChat-1.3.0-nightly.44132f3.jar`),開発ビルドを同じベースバージョンのリリースと取り違えることがなくなります.フラグを付けない場合は `paperVersion` / `velocityVersion` そのままで,リリースワークフローはこちらをビルドします. + +`processResources` はこの `version` と `gitCommitHash` / `channel` を `paper-plugin.yml` / `velocity-plugin.json` と `build-info.properties` にトークン展開します. ## 独立バージョニング @@ -44,7 +46,7 @@ Paper と Velocity は別々のバージョン番号を持ち,独立にリリã `ci.yaml` は main への push / PR / 手動実行で動きます. -- `build_plugin` — ktlintCheck → test + jacocoTestReport → Codecov アップロード → nightly shadowJar (`-PisNightly=true`) → artifact 保持 +- `build_plugin` — ktlintCheck → test + jacocoTestReport → Codecov アップロード → nightly shadowJar (`-PisNightly=true`) → `LunaticChat-paper-<sha>` / `LunaticChat-velocity-<sha>` としてプラットフォームごとに artifact 保持 (JAR は artifact 直下) - `build_dokka` / `deploy_dokka` — Dokka 生成 → GitHub Pages デプロイ (main push のみ) - `build_docs` — `website/` を bun で format/lint/build → Cloudflare Workers (wrangler) へデプロイ (main push のみ) diff --git a/website/src/ja/docs/features/admin.md b/website/src/ja/docs/features/admin.md index f6c86b8..17e08f8 100644 --- a/website/src/ja/docs/features/admin.md +++ b/website/src/ja/docs/features/admin.md @@ -72,6 +72,7 @@ checkForUpdates: true リリース以外で `main` ブランチから作られたビルドは nightly として扱われ,プラグインがその旨を明示します. +- バージョンに `-nightly.<コミットハッシュ>` が付き (`1.3.0-nightly.44132f3`),JAR のファイル名・`/plugins`・`/lc status` のいずれからも 1.3.0 リリースと区別できます - すべてのプレイヤーに対して,ログイン時に不安定な可能性があることと GitHub Issues への案内が警告として表示されます - `/lc status` にも同じ警告が表示され,リリースチャンネルが緑ではなく黄色で表示されます @@ -68,10 +68,12 @@ Examples: EOF } +# The version suffix is derived in build.gradle.kts from -PisNightly; passing -Pversion here +# has no effect, since each module assigns its own version from paperVersion/velocityVersion. setup_nightly() { SHORT_HASH=$(git rev-parse --short HEAD) - GRADLE_EXTRA_ARGS="-Pversion=1.0.0-nightly.${SHORT_HASH} -PisNightly=true" - echo "==> Nightly build: 1.0.0-nightly.${SHORT_HASH}" + GRADLE_EXTRA_ARGS="-PisNightly=true" + echo "==> Nightly build: nightly.${SHORT_HASH}" } ensure_plugin_dir() { |
