Skip to content

Commit 0b3aab2

Browse files
authored
Merge pull request #1753 from j5ik2o/fix/new-release-process
Fix/new release process
2 parents 3031d9d + 7dfe203 commit 0b3aab2

File tree

6 files changed

+135
-98
lines changed

6 files changed

+135
-98
lines changed

.github/workflows/bump-version.yml

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,68 @@ name: Bump Version
22
on:
33
workflow_dispatch:
44
inputs:
5-
force:
6-
description: 'force release'
7-
required: false
8-
default: '0'
5+
force_bump:
6+
description: 'Force version bump'
7+
required: true
8+
type: boolean
9+
default: false
910
schedule:
1011
- cron: '0 0 * * *'
1112
jobs:
1213
bump-version:
1314
runs-on: ubuntu-latest
1415
steps:
15-
- uses: actions/checkout@v5.0.0
16+
- uses: actions/checkout@v5
1617
with:
1718
fetch-depth: 0
1819
persist-credentials: false
1920
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
2021
- name: Calculate changes from the latest tag to HEAD
2122
id: changes
2223
run: |
23-
LATEST_TAG=$(git describe --abbrev=0 --tags)
24-
echo "latest-tag = $LATEST_TAG"
25-
COUNT=$(git log $LATEST_TAG..HEAD --pretty=format:"%s" --no-merges \
26-
--grep='^build:' \
27-
--grep='^ci:' \
28-
--grep='^feat:' \
29-
--grep='^fix:' \
30-
--grep='^docs:' \
31-
--grep='^style:' \
32-
--grep='^refactor:' \
33-
--grep='^perf:' \
34-
--grep='^test:' \
35-
--grep='^revert:' \
36-
--grep='^chore:' | awk 'END{print NR}')
24+
# タグが存在するか確認
25+
if git tag -l | grep -q .; then
26+
LATEST_TAG=$(git describe --abbrev=0 --tags)
27+
echo "latest-tag = $LATEST_TAG"
28+
# 最新タグから現在までの変更をカウント
29+
COUNT=$(git log $LATEST_TAG..HEAD --pretty=format:"%s" --no-merges \
30+
--grep='^build:' \
31+
--grep='^ci:' \
32+
--grep='^feat:' \
33+
--grep='^fix:' \
34+
--grep='^docs:' \
35+
--grep='^style:' \
36+
--grep='^refactor:' \
37+
--grep='^perf:' \
38+
--grep='^test:' \
39+
--grep='^revert:' \
40+
--grep='^chore:' | awk 'END{print NR}')
41+
else
42+
echo "No tags found - using initial commit as base"
43+
# 初期コミットから現在までの変更をカウント(初回実行時)
44+
FIRST_COMMIT=$(git rev-list --max-parents=0 HEAD)
45+
COUNT=$(git log $FIRST_COMMIT..HEAD --pretty=format:"%s" --no-merges \
46+
--grep='^build:' \
47+
--grep='^ci:' \
48+
--grep='^feat:' \
49+
--grep='^fix:' \
50+
--grep='^docs:' \
51+
--grep='^style:' \
52+
--grep='^refactor:' \
53+
--grep='^perf:' \
54+
--grep='^test:' \
55+
--grep='^revert:' \
56+
--grep='^chore:' | awk 'END{print NR}')
57+
# 初回は必ず1以上にしてタグ付けができるようにする
58+
if [ "$COUNT" -eq "0" ]; then
59+
COUNT=1
60+
fi
61+
fi
3762
echo "steps.changes.outputs.count = $COUNT"
38-
FORCE=${{ inputs.force }}
39-
if [[ "$FORCE" = "1" ]]; then
40-
echo "::set-output name=count::1"
63+
if [[ "${{ inputs.force_bump }}" == "true" ]]; then
64+
echo "count=1" >> $GITHUB_OUTPUT
4165
else
42-
echo "::set-output name=count::$COUNT"
66+
echo "count=$COUNT" >> $GITHUB_OUTPUT
4367
fi
4468
- name: Bump version and push tag
4569
id: tag_version
@@ -56,4 +80,4 @@ jobs:
5680
tag_name: ${{ steps.tag_version.outputs.new_tag }}
5781
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
5882
body: ${{ steps.tag_version.outputs.changelog }}
59-
if: steps.changes.outputs.count > 0
83+
if: steps.changes.outputs.count > 0

.github/workflows/publish.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: publish
2+
on:
3+
push:
4+
tags: [ 'v*' ]
5+
branches: [ main ]
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
env:
10+
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
11+
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
12+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
13+
steps:
14+
- uses: actions/checkout@v5
15+
with: { fetch-depth: 0 }
16+
- uses: actions/setup-java@v5
17+
with:
18+
distribution: temurin
19+
java-version: 17
20+
cache: sbt
21+
- uses: sbt/setup-sbt@v1
22+
- name: Configure Sonatype credentials
23+
run: |
24+
mkdir -p ~/.sbt/1.0
25+
cat > ~/.sbt/1.0/sonatype_credentials <<EOF
26+
realm=Sonatype Nexus Repository Manager
27+
host=central.sonatype.com
28+
user=$SONATYPE_USERNAME
29+
password=$SONATYPE_PASSWORD
30+
EOF
31+
- name: Import GPG key
32+
run: |
33+
echo "${{ secrets.PGP_SECRET }}" | base64 -d | gpg --batch --import
34+
- name: Publish Release JAR
35+
if: startsWith(github.ref,'refs/tags/v')
36+
run: |
37+
sbt \
38+
'set every publishTo := { val d = baseDirectory.value / "central-bundle"; Some("bundle" at s"file://${d.getAbsolutePath}") }' \
39+
+publishSigned
40+
PROJECT=$(basename "$GITHUB_REPOSITORY")
41+
VERSION=${GITHUB_REF_NAME##v}
42+
DATE_TIME=$(date +%Y%m%d-%H%M%S)
43+
ZIP_FILE="${PROJECT}-v${VERSION}-${DATE_TIME}.zip"
44+
(cd central-bundle && zip -rq ../"$ZIP_FILE" .)
45+
curl --fail-with-body -sS \
46+
-u "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" \
47+
-F bundle=@"$ZIP_FILE" \
48+
-w "\nHTTP %{http_code}\n" \
49+
"https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC"
50+
- name: Publish Snapshot JAR
51+
if: github.ref == 'refs/heads/main'
52+
run: |
53+
sbt \
54+
'set every publishTo := Some("central-snapshots" at "https://central.sonatype.com/repository/maven-snapshots/")' \
55+
+publishSigned

.github/workflows/release.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/snapshot.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

build.sbt

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
import Dependencies._
22

3+
// ThisBuild settings for publishing
4+
ThisBuild / organization := "io.github.j5ik2o"
5+
ThisBuild / organizationName := "io.github.j5ik2o"
6+
ThisBuild / homepage := Some(url("https://github.com/j5ik2o/docker-controller-scala"))
7+
ThisBuild / licenses := List("The MIT License" -> url("http://opensource.org/licenses/MIT"))
8+
ThisBuild / developers := List(
9+
Developer(
10+
id = "j5ik2o",
11+
name = "Junichi Kato",
12+
email = "[email protected]",
13+
url = url("https://blog.j5ik2o.me")
14+
)
15+
)
16+
ThisBuild / scmInfo := Some(
17+
ScmInfo(
18+
url("https://github.com/j5ik2o/docker-controller-scala"),
19+
"scm:[email protected]:j5ik2o/docker-controller-scala.git"
20+
)
21+
)
22+
ThisBuild / dynverSonatypeSnapshots := true
23+
ThisBuild / dynverSeparator := "-"
24+
ThisBuild / publishMavenStyle := true
25+
ThisBuild / pomIncludeRepository := (_ => false)
26+
ThisBuild / credentials += Credentials(Path.userHome / ".sbt" / "1.0" / "sonatype_credentials")
27+
328
def crossScalacOptions(scalaVersion: String): Seq[String] = CrossVersion.partialVersion(scalaVersion) match {
429
case Some((3L, _)) =>
530
Seq(
@@ -17,17 +42,6 @@ def crossScalacOptions(scalaVersion: String): Seq[String] = CrossVersion.partial
1742
}
1843

1944
lazy val baseSettings = Seq(
20-
organization := "com.github.j5ik2o",
21-
homepage := Some(url("https://github.com/j5ik2o/docker-controller-scala")),
22-
licenses := List("The MIT License" -> url("http://opensource.org/licenses/MIT")),
23-
developers := List(
24-
Developer(
25-
id = "j5ik2o",
26-
name = "Junichi Kato",
27-
email = "[email protected]",
28-
url = url("https://blog.j5ik2o.me")
29-
)
30-
),
3145
scalaVersion := Versions.scala213Version,
3246
crossScalaVersions := Seq(Versions.scala212Version, Versions.scala213Version, Versions.scala3Version),
3347
javacOptions ++= Seq("-source", "17", "-target", "17"),
@@ -258,7 +272,10 @@ val `docker-controller-scala-localstack` = (project in file("docker-controller-s
258272

259273
val `docker-controller-scala-root` = (project in file("."))
260274
.settings(baseSettings)
261-
.settings(name := "docker-controller-scala-root")
275+
.settings(
276+
name := "docker-controller-scala-root",
277+
publish / skip := true
278+
)
262279
.aggregate(
263280
`docker-controller-scala-core`,
264281
`docker-controller-scala-scalatest`,

project/plugins.sbt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5")
22

3-
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.2")
3+
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
4+
5+
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.1")
46

57
addSbtPlugin("pl.project13.scala" % "sbt-jmh" % "0.4.7")
68

0 commit comments

Comments
 (0)