Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ on:
- ".github/workflows/build.yml"
- "!**.md"
pull_request:
# GITHUB_TOKEN が作った PR は push / pull_request を起こさないため、CD が出す版更新の PR には
# 必須チェックが報告されない。その PR のブランチを指定して手で起動するための入口
workflow_dispatch:

permissions:
contents: read
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,48 @@ jobs:
path: build/dokka/html
- id: deploy
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0

# 公開した版は消費済みのため、開発版(次パッチの -SNAPSHOT)へ戻す PR を出す。
# 直接 push しないのは、既定ブランチが PR 経由の更新を必須としているため。
# 配布物を説明する文書の版表記はここでは変わらない(同期の対象はリリース版を宣言している間に限るため、
# 公開済みの版を指したまま据え置かれる)
next-version:
needs: publish
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
pull-requests: write
steps:
# タグではなく既定ブランチを起点にする(タグの指す位置が既定ブランチの先端とは限らない)
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: main
- name: Open version bump pull request
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
current=$(sed -n 's/^enumizerVersion=//p' gradle.properties)
case "$current" in
*-SNAPSHOT)
echo "::notice::$current is already a development version"
exit 0
;;
esac
IFS=. read -r major minor patch <<< "$current"
next="$major.$minor.$((patch + 1))-SNAPSHOT"
branch="chore/next-version-$next"
sed -i "s/^enumizerVersion=.*/enumizerVersion=$next/" gradle.properties
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git switch -c "$branch"
git commit -q -am "build: 開発版を $next へ進める"
git push -q origin "$branch"
gh pr create --base main --head "$branch" \
--title "build: 開発版を $next へ進める" \
--body "$(printf '%s\n' \
"${GITHUB_REF_NAME#v} の公開に伴い、開発版を次のパッチへ進める。" \
"" \
"配布物を説明する文書の版表記は公開済みの版を指したまま据え置かれる。" \
"次のリリースで -SNAPSHOT を外す際にまとめて追随する。")"
38 changes: 24 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ fun minorOf(version: String) = version.split(".").take(2).joinToString(".")

val kotlinCurrent = libs.versions.kotlin.get()
val mavenCurrent = libs.versions.maven.get()
val enumizerReleaseVersion =
providers.gradleProperty("enumizerVersion").get().removeSuffix("-SNAPSHOT")
val enumizerDeclaredVersion = providers.gradleProperty("enumizerVersion").get()
val enumizerReleaseVersion = enumizerDeclaredVersion.removeSuffix("-SNAPSHOT")
// リリース版を宣言している状態か(開発中は -SNAPSHOT が付く)。配布物を説明する文書の同期対象を切り替える
val isReleaseVersion = enumizerDeclaredVersion == enumizerReleaseVersion
val gradleWrapperVersion =
providers
.fileContents(layout.projectDirectory.file("gradle/wrapper/gradle-wrapper.properties"))
Expand Down Expand Up @@ -155,19 +157,27 @@ val versionMentionRules: List<Pair<Regex, String>> =
Regex("""(?<=Maven )\d+\.\d+(?![\d.+])""") to minorOf(mavenCurrent),
)

// 対象箇所: README(セットアップ例・互換表・検証済みビルド環境)・概要 §7(版形式の現行例)・
// 実装ノート / テスト戦略 / エッジケースへの対応方針(実測・テスト環境の宣言)・kotlinc.xml。
// 現行版への言及を持つ資料を増やした場合はここへ追加する。
// ただし過去の版を記録する文書(CHANGELOG)は対象にしない。履歴の版が現行版へ書き換えられてしまう
val versionMentionTargets =
// 対象は文書の性質で 2 群に分ける。現行版への言及を持つ資料を増やした場合は該当する群へ追加する。
// ただし過去の版を記録する文書(CHANGELOG)はどちらにも入れない。履歴の版が現行版へ書き換えられてしまう。
//
// 配布物を説明する文書(README のセットアップ例・互換表・概要 §7 の版形式)。表記が指すのは
// 利用者が実際に入手できる版であり、開発中に追随させると未公開の版を案内してしまう。
// このためリリース版を宣言している間だけ対象とし、開発中は据え置く
val releaseVersionMentionTargets = listOf("README.md", "docs/概要.md")

// 現在の開発・検証環境を記録する文書と、IDE が同期時に書き戻す設定。
// カタログやラッパーの更新へ即座に追随させる(追随しないと作業ツリーへ差分が残る)
val environmentVersionMentionTargets =
listOf(
"README.md",
"docs/概要.md",
"docs/実装ノート.md",
"docs/test/テスト戦略.md",
"docs/エッジケースへの対応方針.md",
".idea/kotlinc.xml",
)
"docs/実装ノート.md",
"docs/test/テスト戦略.md",
"docs/エッジケースへの対応方針.md",
".idea/kotlinc.xml",
)

val versionMentionTargets =
(environmentVersionMentionTargets +
releaseVersionMentionTargets.takeIf { isReleaseVersion }.orEmpty())
.map { it to layout.projectDirectory.file(it).asFile }

tasks.register("syncVersionMentions") {
Expand Down