1+ #! / usr/ bin/ env kotlin
2+
3+ @file:Repository(" https://repo.maven.apache.org/maven2/" )
4+ @file:DependsOn(" io.github.typesafegithub:github-workflows-kt:4.0.0" )
5+ @file:Repository(" https://bindings.krzeminski.it" )
6+ @file:DependsOn(" actions:checkout:v7" )
7+ @file:DependsOn(" actions:setup-java:v6" )
8+ @file:DependsOn(" actions:upload-artifact:v7" )
9+ @file:DependsOn(" gradle:actions__setup-gradle:v6" )
10+
11+ import io.github.typesafegithub.workflows.actions.actions.Checkout
12+ import io.github.typesafegithub.workflows.actions.actions.SetupJava
13+ import io.github.typesafegithub.workflows.actions.actions.UploadArtifact
14+ import io.github.typesafegithub.workflows.actions.gradle.ActionsSetupGradle
15+ import io.github.typesafegithub.workflows.domain.JobOutputs
16+ import io.github.typesafegithub.workflows.domain.Mode
17+ import io.github.typesafegithub.workflows.domain.Permission
18+ import io.github.typesafegithub.workflows.domain.RunnerType
19+ import io.github.typesafegithub.workflows.domain.triggers.Push
20+ import io.github.typesafegithub.workflows.domain.triggers.Release
21+ import io.github.typesafegithub.workflows.dsl.JobBuilder
22+ import io.github.typesafegithub.workflows.dsl.WorkflowBuilder
23+ import io.github.typesafegithub.workflows.dsl.workflow
24+ import io.github.typesafegithub.workflows.yaml.ConsistencyCheckJobConfig
25+
26+ val content: WorkflowBuilder .() -> Unit = {
27+ publish(
28+ runsOn = RunnerType .WindowsLatest ,
29+ system = " windows" ,
30+ arch = " amd64" ,
31+ publishes = listOf (
32+ " uberjar" to " UberJarForCurrentOS" to " jars" ,
33+ " portable" to " AppImage" to " binaries/main-release/app" ,
34+ " installer-msi" to " Msi" to " binaries/main-release/msi" ,
35+ " installer-exe" to " Exe" to " binaries/main-release/exe" ,
36+ ),
37+ )
38+ publish(
39+ runsOn = RunnerType .Custom (" windows-11-arm" ),
40+ system = " windows" ,
41+ arch = " aarch64" ,
42+ publishes = listOf (
43+ " uberjar" to " UberJarForCurrentOS" to " jars" ,
44+ " portable" to " AppImage" to " binaries/main-release/app" ,
45+ " installer-msi" to " Msi" to " binaries/main-release/msi" ,
46+ " installer-exe" to " Exe" to " binaries/main-release/exe" ,
47+ ),
48+ )
49+ /* publish(
50+ runsOn = RunnerType.UbuntuLatest,
51+ system = "linux",
52+ arch = "amd64",
53+ publishes = listOf(
54+ "uberjar" to "UberJarForCurrentOS" to "jars",
55+ "portable" to "AppImage" to "binaries/main-release/app",
56+ "installer-deb" to "Deb" to "binaries/main-release/deb",
57+ "installer-rpm" to "Rpm" to "binaries/main-release/rpm",
58+ ),
59+ )
60+ publish(
61+ runsOn = RunnerType.Custom("ubuntu-22.04-arm"),
62+ system = "linux",
63+ arch = "aarch64",
64+ publishes = listOf(
65+ "uberjar" to "UberJarForCurrentOS" to "jars",
66+ "portable" to "AppImage" to "binaries/main-release/app",
67+ "installer-deb" to "Deb" to "binaries/main-release/deb",
68+ "installer-rpm" to "Rpm" to "binaries/main-release/rpm",
69+ ),
70+ )
71+ publish(
72+ runsOn = RunnerType.MacosLatest,
73+ system = "macos",
74+ arch = "aarch64",
75+ publishes = listOf(
76+ "uberjar" to "UberJarForCurrentOS" to "jars",
77+ "installer-dmg" to "Dmg" to "binaries/main-release/dmg",
78+ ),
79+ )*/
80+ }
81+
82+ workflow(
83+ name = " Package snapshot" ,
84+ on = listOf (
85+ Push (
86+ pathsIgnore = listOf (" README.md" ),
87+ ),
88+ ),
89+ sourceFile = __FILE__ ,
90+ targetFileName = " package_snapshot.yml" ,
91+ consistencyCheckJobConfig = ConsistencyCheckJobConfig .Disabled ,
92+ block = content,
93+ )
94+
95+ workflow(
96+ name = " Package release" ,
97+ on = listOf (
98+ Release (
99+ types = listOf (Release .EventType .Created ),
100+ ),
101+ ),
102+ sourceFile = __FILE__ ,
103+ targetFileName = " package_release.yml" ,
104+ consistencyCheckJobConfig = ConsistencyCheckJobConfig .Disabled ,
105+ block = content,
106+ )
107+
108+ infix fun <T1 , T2 , T3 > Pair <T1 , T2 >.to (third : T3 ): Triple <T1 , T2 , T3 > = Triple (this .first, this .second, third)
109+
110+ fun WorkflowBuilder.publish (runsOn : RunnerType , system : String , arch : String , publishes : List <Triple <String , String , String >>) {
111+ job(
112+ id = " package-$system -$arch " ,
113+ runsOn = runsOn,
114+ permissions = mapOf (
115+ Permission .Contents to Mode .Read ,
116+ Permission .Packages to Mode .Write ,
117+ )
118+ ) {
119+ uses(
120+ action = Checkout (),
121+ )
122+ uses(
123+ action = SetupJava (
124+ javaVersion = " 25" ,
125+ distribution = SetupJava .Distribution .Zulu ,
126+ ),
127+ )
128+ uses(
129+ action = ActionsSetupGradle (),
130+ )
131+ run (
132+ command = """
133+ chmod +x ./gradlew
134+ ./gradlew :generateComposeResClass
135+ ./gradlew :generateResourceAccessorsForCommonMain
136+ ./gradlew :generateExpectResourceCollectorsForCommonMain
137+ ./gradlew :generateActualResourceCollectorsForJvmMain
138+ ./gradlew :assembleJvmMainResources
139+ """ .trimIndent(),
140+ )
141+ publishes.forEach { publish ->
142+ publish(
143+ name = " $system -${publish.first} -$arch " ,
144+ task = publish.second,
145+ path = publish.third,
146+ )
147+ }
148+ }
149+ }
150+
151+ fun JobBuilder<JobOutputs.EMPTY>.publish (name : String , task : String , path : String ) {
152+ run (
153+ name = " package $name " ,
154+ command = " ./gradlew :packageRelease$task " ,
155+ )
156+ uses(
157+ action = UploadArtifact (
158+ name = " InFalsusTools-$name " ,
159+ path = listOf (" build/compose/$path /*" ),
160+ ),
161+ )
162+ }
0 commit comments