Skip to content
Open
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
9 changes: 5 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ jobs:
release: # fixme wait for test-release it goes in parallel: https://github.com/kiemlicz/shelm/actions/runs/8270700884
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v5
with:
java-version: 17
java-version: 21
distribution: 'temurin'
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
- name: Release
run: |
echo "$PGP_KEY" | gpg --import
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
sbt publishSigned sonatypeRelease
sbt publishSigned sonaUpload sonaRelease
env:
MVN_USERNAME: ${{ secrets.MVN_USERNAME }}
MVN_TOKEN: ${{ secrets.MVN_TOKEN }}
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ on:
- "master"
pull_request:
workflow_call:
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.runner }}
name: ${{ matrix.java }}
strategy:
matrix:
java: [11, 17]
java: [17, 21, 25]
runner: [ubuntu-latest] # macos-latest disabled due to inability to run docker and connect to it
helm: [3, 4]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v5
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Setup sbt launcher
uses: sbt/setup-sbt@v1
- name: Setup Docker for Linux
Expand All @@ -31,9 +34,9 @@ jobs:
docker compose -f src/test/resources/registries/compose.yaml up --build -d
- name: Setup Helm binary
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-${{ matrix.helm }}
chmod 700 get_helm.sh
./get_helm.sh --version 3.14.2
./get_helm.sh
helm repo add stable https://charts.helm.sh/stable
helm repo update
echo "Helm setup complete, running Helm version:"
Expand Down
32 changes: 7 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lazy val root = (project in file("."))

def mavenCentralSettings(): Seq[Def.Setting[_]] = {
val shelmRepoUrl = "https://github.com/kiemlicz/shelm"
val sonatypeHost = "s01.oss.sonatype.org"
val sonatypeHost = "central.sonatype.com"
Seq(
credentials += {
for {
Expand All @@ -61,33 +61,15 @@ def mavenCentralSettings(): Seq[Def.Setting[_]] = {
)
},
pgpSigningKey := sys.env.get("PGP_KEY_ID"),
publishTo := sonatypePublishTo.value,
publishTo := {
val centralSnapshots = "https://central.sonatype.com/repository/maven-snapshots/"
if (isSnapshot.value) Some("central-snapshots" at centralSnapshots)
else localStaging.value
},
sonatypeCredentialHost := sonatypeHost,
pomIncludeRepository := (_ => false),
publishMavenStyle := true,
sbtPluginPublishLegacyMavenStyle := false,
scmInfo := Some(ScmInfo(url(shelmRepoUrl), s"scm:https://github.com/kiemlicz/${name.value}.git"))
)
}

def githubSettings(): Seq[Def.Setting[_]] = {
//Dedicated access token must be provided for every user of this package
val ghRepoUrl: String = s"https://maven.pkg.github.com/kiemlicz/shelm"
val ghRepo: MavenRepository = "GitHub Package Registry".at(ghRepoUrl)
Seq(
credentials += sys.env
.get("GITHUB_TOKEN")
.map(token =>
Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"_",
token,
)
),
publishTo := Some(ghRepo),
pomIncludeRepository := (_ => false),
publishMavenStyle := true,
resolvers ++= Seq(ghRepo),
scmInfo := Some(ScmInfo(url(ghRepoUrl), s"scm:git@github.com:kiemlicz/${name.value}.git"))
)
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sbt.version = 1.9.8
sbt.version = 1.11.7
# 1.3.13 https://github.com/sbt/sbt/issues/5308
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ logLevel := Level.Warn

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("com.rallyhealth.sbt" % "sbt-git-versioning" % "1.6.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.3.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.12.2")
18 changes: 9 additions & 9 deletions src/main/scala/io/github/kiemlicz/shelm/ChartDownloader.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ object ChartDownloader {
def apply(uri: URI): CacheKey = CacheKey(sanitizeRepositoryName(uri.toString))
}

def download(chartLocation: ChartLocation, downloadDir: File, cacheDir: File, sbtLogger: Logger): File = {
def download(chartLocation: ChartLocation, downloadDir: File, cacheDir: File, helmPath: String, sbtLogger: Logger): File = {
val cachedChartKey = chartLocation match {
case ChartLocation.Remote(_, uri) => Some(CacheKey(FilenameUtils.getName(uri.getPath)))
case ChartLocation.AddedRepository(name, ChartRepositoryName(repoName), Some(chartVersion)) => Some(
CacheKey(repoName, name, chartVersion)
)
case ChartLocation.RemoteRepository(name, uri, _, Some(chartVersion)) => Some(CacheKey(name, chartVersion, uri))
case ChartLocation.RemoteOciRegistry(name, uri, Some(chartVersion)) => Some(CacheKey(name, chartVersion, uri))
case ChartLocation.RemoteOciRegistry(name, uri, Some(chartVersion), _) => Some(CacheKey(name, chartVersion, uri))
case _ => Option.empty
}
cachedChartKey match {
Expand All @@ -57,13 +57,13 @@ object ChartDownloader {
f / chartLocation.chartName.name
case f =>
sbtLogger.info(s"Cache miss for: ${chartLocation.chartName}")
download(chartLocation, f, sbtLogger)
download(chartLocation, f, helmPath, sbtLogger)
}
}
)
IO.copyDirectory(chartInCacheLocation, downloadDir / chartLocation.chartName.name)
downloadDir / chartLocation.chartName.name
case None => download(chartLocation, downloadDir, sbtLogger)
case None => download(chartLocation, downloadDir, helmPath, sbtLogger)
}
}

Expand All @@ -72,7 +72,7 @@ object ChartDownloader {
* @param chartLocation Chart reference
* @return directory containing Chart
*/
private def download(chartLocation: ChartLocation, downloadDir: File, sbtLogger: Logger): File = {
private def download(chartLocation: ChartLocation, downloadDir: File, helmPath: String, sbtLogger: Logger): File = {
sbtLogger.info(s"Downloading Helm Chart from: ${chartLocation}")
chartLocation match {
case ChartLocation.Local(_, f) =>
Expand All @@ -90,20 +90,20 @@ object ChartDownloader {
case ChartLocation.AddedRepository(ChartName(name), ChartRepositoryName(repoName), chartVersion) =>
val options = s"$repoName/$name -d $downloadDir${chartVersion.map(v => s" --version $v").getOrElse("")} --untar"
IO.delete(downloadDir)
pullChart(options, sbtLogger)
pullChart(options, false, helmPath, sbtLogger)
downloadDir / name
case ChartLocation.RemoteRepository(ChartName(name), uri, auth, chartVersion) =>
val authOpts = HelmPlugin.chartRepositoryCommandFlags(auth)
val allOptions = s"--repo $uri $name $authOpts -d $downloadDir${
chartVersion.map(v => s" --version $v").getOrElse("")
} --untar"
IO.delete(downloadDir)
pullChart(allOptions, sbtLogger)
pullChart(allOptions, false, helmPath, sbtLogger)
downloadDir / name
case ChartLocation.RemoteOciRegistry(ChartName(name), uri, chartVersion) =>
case ChartLocation.RemoteOciRegistry(ChartName(name), uri, chartVersion, insecure) =>
val allOptions = s"$uri -d $downloadDir${chartVersion.map(v => s" --version $v").getOrElse("")} --untar"
IO.delete(downloadDir)
pullChart(allOptions, sbtLogger)
pullChart(allOptions, insecure, helmPath, sbtLogger)
downloadDir / name
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/main/scala/io/github/kiemlicz/shelm/ChartLocation.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.kiemlicz.shelm

import io.circe.{Decoder, Encoder, Json}
import sbt.librarymanagement.VersionNumber

import java.io.File
import java.net.URI
Expand Down Expand Up @@ -72,6 +73,7 @@ object ChartLocation {
chartName: ChartName,
uri: URI,
chartVersion: Option[String] = None,
insecure: Boolean = false,
) extends ChartLocation

}
Expand Down Expand Up @@ -159,11 +161,21 @@ object ChartMuseumRepository {
case class OciChartRegistry(
uri: URI,
auth: ChartRepositoryAuth = ChartRepositoryAuth.NoAuth,
insecure: Boolean = false,
loginCommandDropsScheme: Boolean = true
) extends ChartHosting {
require(uri.getScheme.startsWith("oci"), "OciChartRegistry URI must start with oci:// scheme")

def loginUri: URI = if (loginCommandDropsScheme) new URI(uri.toString.replaceFirst("^oci://", "")) else uri
def loginArg(helmVer: VersionNumber): URI = {
helmVer match {
case VersionNumber(Seq(major, _, _@_*), _, _) if major == 4 =>
val host = uri.getHost
val port = if (uri.getPort == -1) "" else s":${uri.getPort}"
new URI(s"$host$port")
case VersionNumber(Seq(major, _, _@_*), _, _) if major == 3 =>
if (loginCommandDropsScheme) new URI(uri.toString.replaceFirst("^oci://", "")) else uri
}
}
}

/**
Expand Down Expand Up @@ -251,3 +263,7 @@ object ChartSettings {
}

case class PackagedChartInfo(chartName: ChartName, version: SemVer2, location: File)

case class HelmSettings(
binaryPath: String,
)
Loading