Skip to content

Commit a8810a9

Browse files
committed
ci: add ci for release of v.1.0 using gralvm to build executables
1 parent 9ca5250 commit a8810a9

2 files changed

Lines changed: 131 additions & 14 deletions

File tree

.github/workflows/release.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build-linux:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up GraalVM
15+
uses: graalvm/setup-graalvm@v1
16+
with:
17+
java-version: "21"
18+
components: "native-image"
19+
github-token: ${{ secrets.GITHUB_TOKEN }}
20+
21+
- name: Build native executable
22+
run: ./gradlew nativeCompile
23+
24+
- name: Create release directory
25+
run: |
26+
mkdir -p klox-linux
27+
cp build/native/nativeCompile/klox klox-linux/
28+
cp README.md QUICKSTART.md FEATURES.md CUSTOM_FEATURES.md klox-linux/
29+
chmod +x klox-linux/klox
30+
31+
- name: Create archive
32+
run: tar -czf klox-linux-x64.tar.gz klox-linux/
33+
34+
- name: Upload to release
35+
uses: softprops/action-gh-release@v1
36+
with:
37+
files: klox-linux-x64.tar.gz
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
41+
build-macos:
42+
runs-on: macos-latest
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Set up GraalVM
47+
uses: graalvm/setup-graalvm@v1
48+
with:
49+
java-version: "21"
50+
components: "native-image"
51+
github-token: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Build native executable
54+
run: ./gradlew nativeCompile
55+
56+
- name: Create release directory
57+
run: |
58+
mkdir -p klox-macos
59+
cp build/native/nativeCompile/klox klox-macos/
60+
cp README.md QUICKSTART.md FEATURES.md CUSTOM_FEATURES.md klox-macos/
61+
chmod +x klox-macos/klox
62+
63+
- name: Create archive
64+
run: tar -czf klox-macos-arm64.tar.gz klox-macos/
65+
66+
- name: Upload to release
67+
uses: softprops/action-gh-release@v1
68+
with:
69+
files: klox-macos-arm64.tar.gz
70+
env:
71+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72+
73+
build-windows:
74+
runs-on: windows-latest
75+
steps:
76+
- uses: actions/checkout@v4
77+
78+
- name: Set up GraalVM
79+
uses: graalvm/setup-graalvm@v1
80+
with:
81+
java-version: "21"
82+
components: "native-image"
83+
github-token: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Build native executable
86+
run: .\gradlew.bat nativeCompile
87+
88+
- name: Create release directory
89+
run: |
90+
mkdir klox-windows
91+
copy build\native\nativeCompile\klox.exe klox-windows\
92+
copy README.md klox-windows\
93+
copy QUICKSTART.md klox-windows\
94+
copy FEATURES.md klox-windows\
95+
copy CUSTOM_FEATURES.md klox-windows\
96+
97+
- name: Create archive
98+
run: |
99+
cd klox-windows
100+
tar -czf ..\klox-windows-x64.tar.gz *
101+
cd ..
102+
103+
- name: Upload to release
104+
uses: softprops/action-gh-release@v1
105+
with:
106+
files: klox-windows-x64.tar.gz
107+
env:
108+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build.gradle.kts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
import sun.jvmstat.monitor.MonitoredVmUtil.mainClass
2+
13
plugins {
24
kotlin("jvm") version "2.2.20"
5+
id("com.github.johnrengelman.shadow") version "8.1.1"
6+
id("org.graalvm.buildtools.native") version "0.10.1"
37
application
48
}
59

610
group = "com.aymanetech"
7-
version = "1.0-SNAPSHOT"
11+
version = "1.0"
812

913
application {
1014
mainClass.set("com.aymanetech.Lox")
@@ -14,14 +18,6 @@ repositories {
1418
mavenCentral()
1519
}
1620

17-
dependencies {
18-
testImplementation(kotlin("test"))
19-
}
20-
21-
tasks.test {
22-
useJUnitPlatform()
23-
}
24-
2521
kotlin {
2622
jvmToolchain(21)
2723
}
@@ -30,10 +26,23 @@ tasks.named<JavaExec>("run") {
3026
standardInput = System.`in`
3127
}
3228

33-
tasks.jar {
34-
manifest {
35-
attributes["Main-Class"] = "com.aymanetech.Lox"
29+
tasks {
30+
shadowJar {
31+
archiveFileName.set("klox.jar")
32+
archiveClassifier.set("")
3633
}
37-
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
38-
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
3934
}
35+
36+
tasks.build {
37+
dependsOn("shadowJar")
38+
}
39+
40+
graalvmNative {
41+
binaries {
42+
main {
43+
imageName.set("klox")
44+
mainClass.set("com.aymanetech.Lox")
45+
buildArgs.add("-H:+RemoveUnusedSymbols")
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)