diff --git a/action.yml b/action.yml index 270dfe3e09..e9badbd35e 100644 --- a/action.yml +++ b/action.yml @@ -31,7 +31,7 @@ runs: shell: bash - id: download_flank run: | - ./flankScripts github download_flank --version=${{ inputs.version }} --token=${{ secrets.GITHUB_TOKEN }} + ./flankScripts github download_flank --version=${{ inputs.version }} shell: bash - id: authentication run: | diff --git a/flank-scripts/src/main/kotlin/flank/scripts/cli/github/DownloadFlankCommand.kt b/flank-scripts/src/main/kotlin/flank/scripts/cli/github/DownloadFlankCommand.kt index fe4532789a..744e9fb0d8 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/cli/github/DownloadFlankCommand.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/cli/github/DownloadFlankCommand.kt @@ -1,7 +1,6 @@ package flank.scripts.cli.github import com.github.ajalt.clikt.core.CliktCommand -import com.github.ajalt.clikt.parameters.options.default import com.github.ajalt.clikt.parameters.options.option import flank.scripts.ops.github.downloadFlank import kotlinx.coroutines.runBlocking @@ -17,9 +16,7 @@ object DownloadFlankCommand : CliktCommand( help = "If the version not set, the latest version will be used." ) - private val token by option(help = "Git Token").default("") - override fun run() = runBlocking { - downloadFlank(version, token) + downloadFlank(version) } } diff --git a/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DownloadFlank.kt b/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DownloadFlank.kt index 3148336f13..8d789fa521 100644 --- a/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DownloadFlank.kt +++ b/flank-scripts/src/main/kotlin/flank/scripts/ops/github/DownloadFlank.kt @@ -5,12 +5,12 @@ import com.google.common.annotations.VisibleForTesting import flank.common.downloadFile import flank.scripts.data.github.getLatestReleaseTag -suspend fun downloadFlank(version: String?, token: String) = - version.getVersion(token).prepareDownloadUrl().downloadFlank() +suspend fun downloadFlank(version: String?) = + version.getVersion().prepareDownloadUrl().downloadFlank() @VisibleForTesting -internal suspend fun String?.getVersion(token: String): String = - takeUnless { it.isNullOrBlank() } ?: getLatestReleaseTag(token).map { it.tag }.get() +internal suspend fun String?.getVersion(): String = + takeUnless { it.isNullOrBlank() } ?: getLatestReleaseTag("").map { it.tag }.get() private fun String.prepareDownloadUrl() = "https://github.com/Flank/flank/releases/download/$this/$FLANK_JAR" diff --git a/flank-scripts/src/test/kotlin/flank/scripts/ops/github/DownloadFlankTest.kt b/flank-scripts/src/test/kotlin/flank/scripts/ops/github/DownloadFlankTest.kt index a4d025f7f6..4b0b72c57a 100644 --- a/flank-scripts/src/test/kotlin/flank/scripts/ops/github/DownloadFlankTest.kt +++ b/flank-scripts/src/test/kotlin/flank/scripts/ops/github/DownloadFlankTest.kt @@ -10,15 +10,15 @@ class DownloadFlankTest { @Test fun `Should return latest tag if version is null`() { - val downloadedVersion = runBlocking { null.getVersion(token) } - val latestVersion = runBlocking { getLatestReleaseTag(token).map { it.tag }.get() } + val downloadedVersion = runBlocking { null.getVersion() } + val latestVersion = runBlocking { getLatestReleaseTag("").map { it.tag }.get() } Assert.assertEquals(downloadedVersion, latestVersion) } @Test fun `Should return latest tag if version is empty`() { - val downloadedVersion = runBlocking { "".getVersion(token) } - val latestVersion = runBlocking { getLatestReleaseTag(token).map { it.tag }.get() } + val downloadedVersion = runBlocking { "".getVersion() } + val latestVersion = runBlocking { getLatestReleaseTag("").map { it.tag }.get() } Assert.assertEquals(downloadedVersion, latestVersion) } @@ -26,12 +26,8 @@ class DownloadFlankTest { fun `Should return specified release tag`() { val expectedReleaseTag = "v.1.1.1" - val downloadedVersion = runBlocking { expectedReleaseTag.getVersion(token) } + val downloadedVersion = runBlocking { expectedReleaseTag.getVersion() } Assert.assertEquals(downloadedVersion, expectedReleaseTag) } - - companion object { - private const val token = "" - } }