Skip to content

Commit

Permalink
Fix for deploy_images.yml (#1945)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls authored Mar 7, 2023
1 parent 3c97b28 commit 73f46e7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 59 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
--build-cache
-Pdetekt.multiplatform.disabled=true
-PsaveCliVersion=${{ env.SAVE_CLI_VERSION }}
-PsaveCliPath=file://${{ github.workspace }}/save/save-cli/build/bin/linuxX64/releaseExecutable
-PsaveCliPath=${{ github.workspace }}/save/save-cli/build/bin/linuxX64/releaseExecutable
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
${{ env.ADDITIONAL_GRADLE_OPTS }}
Expand Down
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import com.saveourtool.save.buildutils.*
@Suppress("DSL_SCOPE_VIOLATION", "RUN_IN_SCRIPT") // https://github.com/gradle/gradle/issues/22797
plugins {
id("com.saveourtool.save.buildutils.versioning-configuration")
id("com.saveourtool.save.buildutils.save-cli-download-configuration")
id("com.saveourtool.save.buildutils.code-quality-convention")
id("com.saveourtool.save.buildutils.publishing-configuration")
alias(libs.plugins.talaiot.base)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ import org.ajoberstar.grgit.gradle.GrgitServicePlugin
import org.ajoberstar.reckon.gradle.ReckonExtension
import org.ajoberstar.reckon.gradle.ReckonPlugin
import org.gradle.api.Project
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.*
import java.util.*

/**
* @return path to the file with save-cli version for current build
*/
@Suppress("CUSTOM_GETTERS_SETTERS")
internal val Project.pathToSaveCliVersion get() = "${rootProject.buildDir}/save-cli.properties"

/**
* Configures reckon plugin for [this] project, should be applied for root project only
Expand Down Expand Up @@ -52,16 +44,6 @@ fun Project.configureVersioning() {
}
}

/**
* @return save-cli version for current build
*/
@Suppress("CUSTOM_GETTERS_SETTERS")
internal fun Project.readSaveCliVersion(): Provider<String> = rootProject.tasks.named("getSaveCliVersion")
.map { getSaveCliVersionTask ->
val file = file(getSaveCliVersionTask.outputs.files.singleFile)
Properties().apply { load(file.reader()) }["version"] as String
}

/**
* @return true if this string denotes a snapshot version
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@

package com.saveourtool.save.buildutils

import de.undercouch.gradle.tasks.download.Download
import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.api.tasks.TaskProvider
import org.gradle.kotlin.dsl.*
import java.io.File

plugins {
kotlin("jvm")
id("de.undercouch.download")
}

val saveCliVersion: String = the<LibrariesForLibs>()
Expand All @@ -22,20 +20,24 @@ val saveCliVersion: String = the<LibrariesForLibs>()
.get()

dependencies {
val isSaveCliProvided = hasProperty("saveCliPath")
if (isSaveCliProvided) {
if (saveCliVersion.isSnapshot()) {
val target = "$buildDir/save-cli"
val saveCliPath = providers.gradleProperty("saveCliPath")
logger.info(
"save-cli version is SNAPSHOT ({}), add {} as a runtime dependency",
saveCliVersion, saveCliPath
)
@Suppress("GENERIC_VARIABLE_WRONG_DECLARATION")
val downloadSaveCliTaskProvider: TaskProvider<Download> = tasks.register<Download>("downloadSaveCli") {
enabled = isSaveCliProvided
src { saveCliPath }
dest { saveCliPath.map { "$buildDir/download/${File(it).name}" } }

overwrite(false)
val copySaveCliTaskProvider: TaskProvider<Copy> = tasks.register<Copy>("copySaveCli") {
from(saveCliPath)
into(target)
eachFile {
duplicatesStrategy = DuplicatesStrategy.WARN
}
}
add("runtimeOnly",
files(layout.buildDirectory.dir("$buildDir/download")).apply {
builtBy(downloadSaveCliTaskProvider)
files(layout.buildDirectory.dir(target)).apply {
builtBy(copySaveCliTaskProvider)
}
)
}
Expand Down

This file was deleted.

8 changes: 6 additions & 2 deletions save-deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ The `save-backend` and `save-sandbox` download newer versions of `save-cli` from
#### Using a `SNAPSHOT` version of `save-cli`

If `save-cli` is set to snapshot version in `lib.version.toml`, we download `save-cli`'s sources and build them in _GitHub_ action: [Build and push Docker images](../.github/workflows/deploy_images.yml).
Then adds the result (_.kexe_) to `save-backend` and `save-sandbox` as a runtime dependency
Then _Gradle_ adds the result (_.kexe_) to `save-backend` and `save-sandbox` as a runtime dependency

**Note:** `libs.version.toml` can contain __blabla-SNAPSHOT__ version, but we will build a version from the latest main in `save-cli`
**Under the hood:** _Gradle_ supports two variables `saveCliVersion` and `saveCliPath`.
The `saveCliVersion` overrides version of `save-cli` from `lib.version.toml`.
The `saveCliPath` specifies a path to `save-cli`'s _.kexe_ and it's required when version of `save-cli` is **SNAPSHOT**.

**Note:** `libs.version.toml` can contain _blabla-SNAPSHOT_ version, but we will build a version from the latest main in `save-cli`
and set the built version of `save-cli` to generated file: `generated/SaveCliVersion.kt`.

## Server deployment
Expand Down

0 comments on commit 73f46e7

Please sign in to comment.