diff --git a/.github/workflows/upload-release-assets.yml b/.github/workflows/upload-release-assets.yml index bfab455..5962afe 100644 --- a/.github/workflows/upload-release-assets.yml +++ b/.github/workflows/upload-release-assets.yml @@ -6,6 +6,57 @@ on: jobs: + publish-zoe-core-jar: + name: Publis zoe core jar + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: '100' + + - name: set upload url + id: fetch_release_data + run: | + UPLOAD_URL=$(jq -r '.release.upload_url' ${GITHUB_EVENT_PATH}) + echo "::set-output name=upload_url::$UPLOAD_URL" + + - name: Setup Java JDK + uses: actions/setup-java@v1.3.0 + with: + java-version: 11 + java-package: jdk + architecture: x64 + + - name: Build + run: ./gradlew clean zoe-core:shadowJar + + - name: Package + id: package + run: | + ./dev/scripts/packages-without-runtime.sh + + # retrieve jar + zoe_jar_path=$(ls -t zoe-core/build/libs/zoe-core-*.jar | head -n 1) + + # ensure jar is generated + [[ -z "${zoe_jar_path}" ]] && \ + { echo "zoe core jar not found : ${zoe_jar_path}"; exit 1; } + + echo "::set-output name=zoe_jar_path::${zoe_jar_path}" + echo "::set-output name=zoe_jar_name::$(basename ${zoe_jar_path})" + + - name: Upload zip package + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.fetch_release_data.outputs.upload_url }} + asset_path: ${{ steps.package.outputs.zoe_jar_path }} + asset_name: ${{ steps.package.outputs.zoe_jar_name }} + asset_content_type: application/zip + release-runtimeless: name: Publish packages without runtime diff --git a/zoe-cli/build.gradle.kts b/zoe-cli/build.gradle.kts index ab413e0..9a625d4 100644 --- a/zoe-cli/build.gradle.kts +++ b/zoe-cli/build.gradle.kts @@ -89,7 +89,7 @@ tasks { } } - compileKotlin { + val processResources by getting(ProcessResources::class) { dependsOn(generateVersionFile) } diff --git a/zoe-cli/src/commands/lambda.kt b/zoe-cli/src/commands/lambda.kt index d7b13a5..c0e35c5 100644 --- a/zoe-cli/src/commands/lambda.kt +++ b/zoe-cli/src/commands/lambda.kt @@ -27,6 +27,7 @@ import com.amazonaws.services.lambda.AWSLambda import com.amazonaws.services.lambda.model.* import com.github.ajalt.clikt.core.CliktCommand import com.github.ajalt.clikt.core.subcommands +import com.github.ajalt.clikt.parameters.options.convert import com.github.ajalt.clikt.parameters.options.flag import com.github.ajalt.clikt.parameters.options.option import com.github.ajalt.clikt.parameters.options.required @@ -36,7 +37,9 @@ import kotlinx.coroutines.FlowPreview import org.koin.core.KoinComponent import org.koin.core.inject import java.io.File +import java.net.URL import java.nio.ByteBuffer +import java.nio.file.Files class LambdaCommand : CliktCommand(name = "lambda", help = "Manage zoe lambda function") { companion object { @@ -79,9 +82,9 @@ class DeployLambda : CliktCommand(name = "deploy", help = "Deploy zoe core as an private val ctx by inject() private val environment by inject() - private val jar - by option("--jar", help = "Path to the zoe jar file", hidden = true, envvar = "ZOE_JAR_PATH") - .file(mustExist = true, canBeFile = true, mustBeReadable = true) + private val jarUrl + by option("--jar-url", help = "Url to the zoe jar file", hidden = true, envvar = "ZOE_JAR_URL") + .convert { URL(it) } .required() private val dryRun: Boolean by option("--dry-run", help = "Dry run mode").flag(default = false) @@ -118,6 +121,17 @@ class DeployLambda : CliktCommand(name = "deploy", help = "Deploy zoe core as an val deployConfig = environment.runners.config.lambda.deploy ?: userError("you must specify a deploy config !") + val jar = kotlin.run { + val file = + Files + .createTempFile("zoe-jar", null) + .toFile() + .also(File::deleteOnExit) + + file.outputStream().use { out -> jarUrl.openStream().use { inp -> inp.copyTo(out) } } + file + } + val lambda = aws.lambda.createOrUpdateLambda( name = LambdaZoeRunner.LambdaFunctionName, concurrency = deployConfig.concurrency,