Skip to content

Commit d961a13

Browse files
Setup publishing (#14)
* Setup publishing * Restore diff dep * Update secrets refs * Add pgp secret * Change artifactName --------- Co-authored-by: ghostbuster91 <ghostbuster91@users.noreply.github.com>
1 parent a7dcaff commit d961a13

8 files changed

Lines changed: 180 additions & 68 deletions

File tree

.github/workflows/scala.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ jobs:
4747
git status
4848
exit 1
4949
fi
50+
51+
- run: ./mill mill.scalalib.SonatypeCentralPublishModule/
52+
env:
53+
MILL_PGP_SECRET_BASE64: ${{ secrets.PGP_SECRET }}
54+
MILL_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
55+
MILL_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}

.mill-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.11
1+
0.12.14

build.sc

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import com.goyeau.mill.git.GitVersionedPublishModule
12
import com.goyeau.mill.scalafix.ScalafixModule
23
import coursier.core.Repository
34
import coursier.maven.MavenRepository
45
import mill._
56
import mill.define.Sources
7+
import mill.javalib.publish._
68
import mill.scalalib._
9+
import mill.scalalib.SonatypeCentralPublishModule
710
import scalalib._
811
import smithy4s.codegen.mill._
912
import smithytraitcodegen.SmithyTraitCodegenPlugin
@@ -14,14 +17,18 @@ val jsonrpcVersion = "0.0.8+41-0a28e99d-SNAPSHOT"
1417
val langoustineVersion = "0.0.24"
1518
val smithyVersion = "1.57.1"
1619

17-
trait CommonScalaModule extends ScalaModule with ScalafixModule {
20+
trait CommonJavaModule extends JavaModule {
1821
override def repositoriesTask: Task[Seq[Repository]] = T.task {
1922
Seq(
2023
MavenRepository("https://s01.oss.sonatype.org/content/repositories/snapshots"),
2124
MavenRepository("https://s01.oss.sonatype.org/content/repositories/releases"),
2225
) ++ super.repositoriesTask()
2326
}
2427

28+
}
29+
30+
trait CommonScalaModule extends ScalaModule with CommonJavaModule with ScalafixModule {
31+
2532
def scalaVersion = "3.3.6"
2633
}
2734

@@ -50,7 +57,7 @@ object lspSmithy extends CommonScalaModule with SmithyTraitCodegenPlugin.SmithyT
5057
}
5158

5259
override def forkEnv: T[Map[String, String]] = T {
53-
Map("TARGET_PATH" -> (os.pwd / "target").toString)
60+
Map("TARGET_PATH" -> (moduleDir / os.up / "target" / "META-INF" / "smithy").toString)
5461
}
5562

5663
def mainClass = Some("org.scala.abusers.lspsmithy.main")
@@ -59,7 +66,6 @@ object lspSmithy extends CommonScalaModule with SmithyTraitCodegenPlugin.SmithyT
5966
ivy"tech.neander::langoustine-meta::$langoustineVersion",
6067
ivy"com.lihaoyi::os-lib:0.11.4",
6168
ivy"software.amazon.smithy:smithy-model:$smithyVersion",
62-
ivy"software.amazon.smithy:smithy-diff:$smithyVersion",
6369
ivy"tech.neander:jsonrpclib-smithy:$jsonrpcVersion",
6470
ivy"com.disneystreaming.alloy:alloy-core:0.3.20",
6571
)
@@ -70,17 +76,51 @@ object lspSmithy extends CommonScalaModule with SmithyTraitCodegenPlugin.SmithyT
7076

7177
object test extends ScalaTests {
7278
def ivyDeps = Agg(
73-
ivy"com.disneystreaming::weaver-cats:0.8.4"
79+
ivy"com.disneystreaming::weaver-cats:0.8.4",
80+
ivy"software.amazon.smithy:smithy-diff:$smithyVersion",
7481
)
7582
def testFramework = "weaver.framework.CatsEffect"
7683
}
7784
}
7885

86+
object lspSmithyDefinitions extends CommonJavaModule with SonatypeCentralPublishModule with GitVersionedPublishModule {
87+
88+
def artifactName = "lsp-smithy-definitions"
89+
90+
def pomSettings = PomSettings(
91+
description = "Smithy definitions for Language Server Protocol",
92+
organization = "io.github.simple-scala-tooling",
93+
url = "https://github.com/simple-scala-tooling/lsp-smithy",
94+
licenses = Seq(License.`Apache-2.0`),
95+
versionControl = VersionControl.github("simple-scala-tooling", "lsp-smithy"),
96+
developers = Seq(
97+
Developer(
98+
id = "ghostbuster91",
99+
name = "Kasper Kondzielski",
100+
url = "https://github.com/ghostbuster91",
101+
),
102+
Developer(
103+
id = "kubukoz",
104+
name = "Jakub Kozłowski",
105+
url = "https://github.com/kubukoz",
106+
),
107+
),
108+
)
109+
def resources = T {
110+
Seq(PathRef(moduleDir / os.up / "target"))
111+
}
112+
113+
override def ivyDeps = Agg(
114+
ivy"tech.neander:jsonrpclib-smithy:$jsonrpcVersion",
115+
ivy"com.disneystreaming.alloy:alloy-core:0.3.20",
116+
)
117+
}
118+
79119
object exampleClientSmithy extends CommonScalaModule with Smithy4sModule {
80120

81121
override def smithy4sAllowedNamespaces: T[Option[Set[String]]] = T(Some(Set("lsp")))
82122

83-
override def moduleDeps: Seq[JavaModule] = Seq(lspSmithy)
123+
override def moduleDeps: Seq[JavaModule] = Seq(lspSmithyDefinitions)
84124

85125
def smithy4sInputDirs: Target[Seq[PathRef]] = T.sources {
86126
super.smithy4sInputDirs() ++ Seq(PathRef(moduleDir / os.up / "target"))

lspSmithy/src/org/scala/abusers/lspsmithy/GenerateSmithy.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ def main() = {
2424
val outputPath = targetDir / "lsp.smithy"
2525
os.write.over(outputPath, content, createFolders = true)
2626
}
27+
val manifestContent = "lsp.smithy"
28+
os.write.over(targetDir / "manifest", manifestContent, createFolders = true)
2729
}
2830

2931
private[lspsmithy] def preprocess(metaModel: MetaModel): MetaModel =

mill

Lines changed: 124 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
#!/usr/bin/env sh
22

3-
# This is a wrapper script, that automatically download mill from GitHub release pages
4-
# You can give the required mill version with --mill-version parameter
5-
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
3+
# This is a wrapper script, that automatically selects or downloads Mill from Maven Central or GitHub release pages.
64
#
7-
# Original Project page: https://github.com/lefou/millw
8-
# Script Version: 0.4.12
5+
# This script determines the Mill version to use by trying these sources
6+
# - env-variable `MILL_VERSION`
7+
# - local file `.mill-version`
8+
# - local file `.config/mill-version`
9+
# - `mill-version` from YAML fronmatter of current buildfile
10+
# - if accessible, find the latest stable version available on Maven Central (https://repo1.maven.org/maven2)
11+
# - env-variable `DEFAULT_MILL_VERSION`
12+
#
13+
# If a version has the suffix '-native' a native binary will be used.
14+
# If a version has the suffix '-jvm' an executable jar file will be used, requiring an already installed Java runtime.
15+
# If no such suffix is found, the script will pick a default based on version and platform.
16+
#
17+
# Once a version was determined, it tries to use either
18+
# - a system-installed mill, if found and it's version matches
19+
# - an already downloaded version under ~/.cache/mill/download
20+
#
21+
# If no working mill version was found on the system,
22+
# this script downloads a binary file from Maven Central or Github Pages (this is version dependent)
23+
# into a cache location (~/.cache/mill/download).
24+
#
25+
# Mill Project URL: https://github.com/com-lihaoyi/mill
26+
# Script Version: 1.0.0-M1-49-ac90e3
927
#
1028
# If you want to improve this script, please also contribute your changes back!
29+
# This script was generated from: dist/scripts/src/mill.sh
1130
#
1231
# Licensed under the Apache License, Version 2.0
1332

1433
set -e
1534

1635
if [ -z "${DEFAULT_MILL_VERSION}" ] ; then
17-
DEFAULT_MILL_VERSION=0.12.10
36+
DEFAULT_MILL_VERSION=0.12.14
1837
fi
1938

2039

@@ -31,16 +50,17 @@ fi
3150

3251
# Explicit commandline argument takes precedence over all other methods
3352
if [ "$1" = "--mill-version" ] ; then
34-
shift
35-
if [ "x$1" != "x" ] ; then
36-
MILL_VERSION="$1"
37-
shift
38-
else
39-
echo "You specified --mill-version without a version." 1>&2
40-
echo "Please provide a version that matches one provided on" 1>&2
41-
echo "${MILL_REPO_URL}/releases" 1>&2
42-
false
43-
fi
53+
echo "The --mill-version option is no longer supported." 1>&2
54+
fi
55+
56+
MILL_BUILD_SCRIPT=""
57+
58+
if [ -f "build.mill" ] ; then
59+
MILL_BUILD_SCRIPT="build.mill"
60+
elif [ -f "build.mill.scala" ] ; then
61+
MILL_BUILD_SCRIPT="build.mill.scala"
62+
elif [ -f "build.sc" ] ; then
63+
MILL_BUILD_SCRIPT="build.sc"
4464
fi
4565

4666
# Please note, that if a MILL_VERSION is already set in the environment,
@@ -52,6 +72,8 @@ if [ -z "${MILL_VERSION}" ] ; then
5272
MILL_VERSION="$(tr '\r' '\n' < .mill-version | head -n 1 2> /dev/null)"
5373
elif [ -f ".config/mill-version" ] ; then
5474
MILL_VERSION="$(tr '\r' '\n' < .config/mill-version | head -n 1 2> /dev/null)"
75+
elif [ -n "${MILL_BUILD_SCRIPT}" ] ; then
76+
MILL_VERSION="$(cat ${MILL_BUILD_SCRIPT} | grep '//[|] *mill-version: *' | sed 's;//| *mill-version: *;;')"
5577
fi
5678
fi
5779

@@ -65,7 +87,7 @@ fi
6587
if [ -z "${MILL_VERSION}" ] ; then
6688
# TODO: try to load latest version from release page
6789
echo "No mill version specified." 1>&2
68-
echo "You should provide a version via '.mill-version' file or --mill-version option." 1>&2
90+
echo "You should provide a version via a '//| mill-version: ' comment or a '.mill-version' file." 1>&2
6991

7092
mkdir -p "${MILL_DOWNLOAD_PATH}"
7193
LANG=C touch -d '1 hour ago' "${MILL_DOWNLOAD_PATH}/.expire_latest" 2>/dev/null || (
@@ -102,11 +124,10 @@ if [ -z "${MILL_VERSION}" ] ; then
102124
fi
103125

104126
MILL_NATIVE_SUFFIX="-native"
127+
MILL_JVM_SUFFIX="-jvm"
105128
FULL_MILL_VERSION=$MILL_VERSION
106129
ARTIFACT_SUFFIX=""
107-
case "$MILL_VERSION" in
108-
*"$MILL_NATIVE_SUFFIX")
109-
MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"}
130+
set_artifact_suffix(){
110131
if [ "$(expr substr $(uname -s) 1 5 2>/dev/null)" = "Linux" ]; then
111132
if [ "$(uname -m)" = "aarch64" ]; then
112133
ARTIFACT_SUFFIX="-native-linux-aarch64"
@@ -123,9 +144,39 @@ case "$MILL_VERSION" in
123144
echo "This native mill launcher supports only Linux and macOS." 1>&2
124145
exit 1
125146
fi
147+
}
148+
149+
case "$MILL_VERSION" in
150+
*"$MILL_NATIVE_SUFFIX")
151+
MILL_VERSION=${MILL_VERSION%"$MILL_NATIVE_SUFFIX"}
152+
set_artifact_suffix
153+
;;
154+
155+
*"$MILL_JVM_SUFFIX")
156+
MILL_VERSION=${MILL_VERSION%"$MILL_JVM_SUFFIX"}
157+
;;
158+
159+
*)
160+
case "$MILL_VERSION" in
161+
0.1.*) ;;
162+
0.2.*) ;;
163+
0.3.*) ;;
164+
0.4.*) ;;
165+
0.5.*) ;;
166+
0.6.*) ;;
167+
0.7.*) ;;
168+
0.8.*) ;;
169+
0.9.*) ;;
170+
0.10.*) ;;
171+
0.11.*) ;;
172+
0.12.*) ;;
173+
*)
174+
set_artifact_suffix
175+
esac
176+
;;
126177
esac
127178

128-
MILL="${MILL_DOWNLOAD_PATH}/${FULL_MILL_VERSION}"
179+
MILL="${MILL_DOWNLOAD_PATH}/$MILL_VERSION$ARTIFACT_SUFFIX"
129180

130181
try_to_use_system_mill() {
131182
if [ "$(uname)" != "Linux" ]; then
@@ -198,49 +249,59 @@ EOF
198249
try_to_use_system_mill
199250

200251
# If not already downloaded, download it
201-
if [ ! -s "${MILL}" ] ; then
202-
203-
# support old non-XDG download dir
204-
MILL_OLD_DOWNLOAD_PATH="${HOME}/.mill/download"
205-
OLD_MILL="${MILL_OLD_DOWNLOAD_PATH}/${MILL_VERSION}"
206-
if [ -x "${OLD_MILL}" ] ; then
207-
MILL="${OLD_MILL}"
252+
if [ ! -s "${MILL}" ] || [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
253+
case $MILL_VERSION in
254+
0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* )
255+
DOWNLOAD_SUFFIX=""
256+
DOWNLOAD_FROM_MAVEN=0
257+
;;
258+
0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* )
259+
DOWNLOAD_SUFFIX="-assembly"
260+
DOWNLOAD_FROM_MAVEN=0
261+
;;
262+
*)
263+
DOWNLOAD_SUFFIX="-assembly"
264+
DOWNLOAD_FROM_MAVEN=1
265+
;;
266+
esac
267+
case $MILL_VERSION in
268+
0.12.0 | 0.12.1 | 0.12.2 | 0.12.3 | 0.12.4 | 0.12.5 | 0.12.6 | 0.12.7 | 0.12.8 | 0.12.9 | 0.12.10 | 0.12.11 )
269+
DOWNLOAD_EXT="jar"
270+
;;
271+
0.12.* )
272+
DOWNLOAD_EXT="exe"
273+
;;
274+
0.* )
275+
DOWNLOAD_EXT="jar"
276+
;;
277+
*)
278+
DOWNLOAD_EXT="exe"
279+
;;
280+
esac
281+
282+
DOWNLOAD_FILE=$(mktemp mill.XXXXXX)
283+
if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then
284+
DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.${DOWNLOAD_EXT}"
208285
else
209-
case $MILL_VERSION in
210-
0.0.* | 0.1.* | 0.2.* | 0.3.* | 0.4.* )
211-
DOWNLOAD_SUFFIX=""
212-
DOWNLOAD_FROM_MAVEN=0
213-
;;
214-
0.5.* | 0.6.* | 0.7.* | 0.8.* | 0.9.* | 0.10.* | 0.11.0-M* )
215-
DOWNLOAD_SUFFIX="-assembly"
216-
DOWNLOAD_FROM_MAVEN=0
217-
;;
218-
*)
219-
DOWNLOAD_SUFFIX="-assembly"
220-
DOWNLOAD_FROM_MAVEN=1
221-
;;
222-
esac
223-
224-
DOWNLOAD_FILE=$(mktemp mill.XXXXXX)
225-
226-
if [ "$DOWNLOAD_FROM_MAVEN" = "1" ] ; then
227-
DOWNLOAD_URL="https://repo1.maven.org/maven2/com/lihaoyi/mill-dist${ARTIFACT_SUFFIX}/${MILL_VERSION}/mill-dist${ARTIFACT_SUFFIX}-${MILL_VERSION}.jar"
228-
else
229-
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
230-
DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
231-
unset MILL_VERSION_TAG
232-
fi
233-
234-
# TODO: handle command not found
235-
echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2
236-
${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}"
237-
chmod +x "${DOWNLOAD_FILE}"
238-
mkdir -p "${MILL_DOWNLOAD_PATH}"
239-
mv "${DOWNLOAD_FILE}" "${MILL}"
286+
MILL_VERSION_TAG=$(echo "$MILL_VERSION" | sed -E 's/([^-]+)(-M[0-9]+)?(-.*)?/\1\2/')
287+
DOWNLOAD_URL="${GITHUB_RELEASE_CDN}${MILL_REPO_URL}/releases/download/${MILL_VERSION_TAG}/${MILL_VERSION}${DOWNLOAD_SUFFIX}"
288+
unset MILL_VERSION_TAG
289+
fi
240290

241-
unset DOWNLOAD_FILE
242-
unset DOWNLOAD_SUFFIX
291+
if [ "$MILL_TEST_DRY_RUN_LAUNCHER_SCRIPT" = "1" ] ; then
292+
echo $DOWNLOAD_URL
293+
echo $MILL
294+
exit 0
243295
fi
296+
# TODO: handle command not found
297+
echo "Downloading mill ${MILL_VERSION} from ${DOWNLOAD_URL} ..." 1>&2
298+
${CURL_CMD} -f -L -o "${DOWNLOAD_FILE}" "${DOWNLOAD_URL}"
299+
chmod +x "${DOWNLOAD_FILE}"
300+
mkdir -p "${MILL_DOWNLOAD_PATH}"
301+
mv "${DOWNLOAD_FILE}" "${MILL}"
302+
303+
unset DOWNLOAD_FILE
304+
unset DOWNLOAD_SUFFIX
244305
fi
245306

246307
if [ -z "$MILL_MAIN_CLI" ] ; then
@@ -260,6 +321,7 @@ unset OLD_MILL
260321
unset MILL_VERSION
261322
unset MILL_REPO_URL
262323

324+
# -D mill.main.cli is for compatibility with Mill 0.10.9 - 0.13.0-M2
263325
# We don't quote MILL_FIRST_ARG on purpose, so we can expand the empty value without quotes
264326
# shellcheck disable=SC2086
265-
exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"
327+
exec "${MILL}" $MILL_FIRST_ARG -D "mill.main.cli=${MILL_MAIN_CLI}" "$@"

mill-build/build.sc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ object `package` extends MillBuildRootModule {
1010
ivy"software.amazon.smithy:smithy-build:1.56.0",
1111
ivy"software.amazon.smithy:smithy-trait-codegen:1.56.0",
1212
ivy"com.goyeau::mill-scalafix::0.5.0",
13+
ivy"com.goyeau::mill-git::0.2.7",
1314
ivy"com.disneystreaming.smithy4s::smithy4s-mill-codegen-plugin::0.18.0-8-0c1ad4d",
1415
)
1516

target/META-INF/smithy/manifest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lsp.smithy

0 commit comments

Comments
 (0)