Skip to content

Commit

Permalink
use jar url instead of file path on lambda deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Walid Lezzar committed Mar 22, 2020
1 parent 78453a8 commit ad52c59
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 4 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/upload-release-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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

Expand Down
2 changes: 1 addition & 1 deletion zoe-cli/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ tasks {
}
}

compileKotlin {
val processResources by getting(ProcessResources::class) {
dependsOn(generateVersionFile)
}

Expand Down
20 changes: 17 additions & 3 deletions zoe-cli/src/commands/lambda.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down Expand Up @@ -79,9 +82,9 @@ class DeployLambda : CliktCommand(name = "deploy", help = "Deploy zoe core as an
private val ctx by inject<CliContext>()
private val environment by inject<EnvConfig>()

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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit ad52c59

Please sign in to comment.