-
Notifications
You must be signed in to change notification settings - Fork 4
/
release.main.kts
executable file
·47 lines (43 loc) · 1.9 KB
/
release.main.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env kotlin
@file:DependsOn("io.github.typesafegithub:github-workflows-kt:1.8.0")
import io.github.typesafegithub.workflows.actions.actions.CheckoutV4
import io.github.typesafegithub.workflows.actions.actions.SetupJavaV4
import io.github.typesafegithub.workflows.actions.azure.DockerLoginV1
import io.github.typesafegithub.workflows.actions.docker.BuildPushActionV5
import io.github.typesafegithub.workflows.actions.gradle.GradleBuildActionV2
import io.github.typesafegithub.workflows.domain.RunnerType.UbuntuLatest
import io.github.typesafegithub.workflows.domain.triggers.Push
import io.github.typesafegithub.workflows.dsl.expressions.Contexts
import io.github.typesafegithub.workflows.dsl.expressions.expr
import io.github.typesafegithub.workflows.dsl.workflow
import io.github.typesafegithub.workflows.yaml.writeToFile
val version = expr { github.ref_name }
val DOCKER_HUB_USERNAME by Contexts.secrets
val DOCKER_HUB_TOKEN by Contexts.secrets
val dockerNamespace = "jopiterapp/jopiter-backend"
workflow(
name = "Release",
on = listOf(Push(tags = listOf("*"))),
sourceFile = __FILE__.toPath()
) {
job(id = "Release", runsOn = UbuntuLatest) {
uses(
name = "Setup JDK",
action = SetupJavaV4(javaVersion = "17", distribution = SetupJavaV4.Distribution.Adopt)
)
uses(name = "Checkout", action = CheckoutV4())
uses(name = "Create ShadowJar", action = GradleBuildActionV2(arguments = ":bootJar"))
uses(
name = "Login to DockerHub",
action = DockerLoginV1(username = expr { DOCKER_HUB_USERNAME }, password = expr { DOCKER_HUB_TOKEN })
)
uses(
name = "Build and Push",
action = BuildPushActionV5(
context = ".",
push = true,
tags = listOf("$dockerNamespace:latest", "$dockerNamespace:$version")
)
)
}
}.writeToFile()