Skip to content

Commit a0e77f2

Browse files
committed
CI: Add GitHub Actions workflow for building desktop app
This commit introduces a GitHub Actions workflow to automate the build process for the ModernADB desktop application. The workflow will: - Trigger on push and pull request events to the `main` and `cicd` branches. - Build the application on `ubuntu-latest`, `windows-latest`, and `macos-latest` runners. - Set up JDK 21 and Gradle. - Execute the `./gradlew packageRelease` command to build the native distribution. - Upload the resulting binaries as artifacts, named `ModernADB-${{ matrix.os }}`. Additionally, this commit: - Adds RPM as a target format in `composeApp/build.gradle.kts`. - Introduces a new Gradle task `packageAll` that depends on `packageMsi`, `packageDmg`, `packageDeb`, and `packageRpm` to build all native distribution packages.
1 parent 4b3a44f commit a0e77f2

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build Desktop App
2+
3+
on:
4+
push:
5+
branches: [ main, cicd ] # Or whatever your main branch is
6+
pull_request:
7+
branches: [ main, cicd ]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
# Define the operating systems to build on
14+
os: [ubuntu-latest, windows-latest, macos-latest]
15+
runs-on: ${{ matrix.os }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up JDK 21
22+
uses: actions/setup-java@v4
23+
with:
24+
java-version: '21'
25+
distribution: 'temurin' # A standard, full JDK
26+
27+
- name: Setup Gradle
28+
uses: gradle/actions/setup-gradle@v3
29+
30+
- name: Build with Gradle
31+
# This command will run the appropriate packaging task for the current OS
32+
run: ./gradlew packageRelease
33+
34+
- name: Upload Artifacts
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: ModernADB-${{ matrix.os }}
38+
path: composeApp/build/compose/binaries/main/release/

composeApp/build.gradle.kts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,24 @@ compose.desktop {
3939
mainClass = "id.neotica.modernadb.MainKt"
4040

4141
nativeDistributions {
42-
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
42+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb, TargetFormat.Rpm)
4343
packageName = "id.neotica.modernadb"
4444
packageVersion = "1.0.0"
4545
}
4646
}
4747
}
48+
49+
// This creates a new custom task named "packageAll"
50+
tasks.register("packageAll") {
51+
// Optional: This puts your task in a "distribution" folder in the Gradle tool window
52+
group = "distribution"
53+
description = "Builds all native distribution packages (MSI, DMG, DEB, RPM)."
54+
55+
// This is the key part: it tells Gradle to run these tasks first
56+
val packageTasks = listOf("packageMsi", "packageDmg", "packageDeb", "packageRpm")
57+
packageTasks.forEach { taskName ->
58+
tasks.findByName(taskName)?.let {
59+
dependsOn(it)
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)