Skip to content

Commit 9d257de

Browse files
committed
Only on Linux
Snap Distribution Fix missing snapcraft Fix missing lxd Fix missing lxd
1 parent f1cd662 commit 9d257de

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/build-gradle.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ jobs:
4141
architecture: ${{ matrix.arch }}
4242
- name: Setup Gradle
4343
uses: gradle/actions/setup-gradle@v4
44+
- name: Install Snapcraft
45+
if: runner.os == 'Linux'
46+
uses: samuelmeuli/action-snapcraft@v3
47+
- name: Install LXD
48+
if: runner.os == 'Linux'
49+
uses: canonical/setup-lxd@main
4450
- name: Build with Gradle
4551
run: ./gradlew packageDistributionForCurrentOS
4652
- name: Add instructions
@@ -56,4 +62,5 @@ jobs:
5662
./app/build/compose/binaries/main/dmg/INSTRUCTIONS_FOR_TESTING.txt
5763
./app/build/compose/binaries/main/msi/Processing-*.msi
5864
./app/build/compose/binaries/main/deb/processing*.deb
65+
./app/build/compose/binaries/main/processing*.snap
5966
retention-days: 1

app/build.gradle.kts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,61 @@ tasks.register<Exec>("packageCustomMsi"){
157157
)
158158
}
159159

160+
tasks.register("generateSnapConfiguration"){
161+
onlyIf { org.gradle.internal.os.OperatingSystem.current().isLinux }
162+
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
163+
dependsOn(distributable)
164+
165+
val arch = when (System.getProperty("os.arch")) {
166+
"amd64", "x86_64" -> "amd64"
167+
else -> System.getProperty("os.arch")
168+
}
169+
170+
val dir = distributable.destinationDir.get()
171+
val content = """
172+
name: ${rootProject.name}
173+
version: ${rootProject.version}
174+
base: core22
175+
summary: A creative coding editor
176+
description: |
177+
Processing is a flexible software sketchbook and a programming language designed for learning how to code.
178+
confinement: strict
179+
180+
apps:
181+
processing:
182+
command: opt/processing/bin/Processing
183+
desktop: opt/processing/lib/processing-Processing.desktop
184+
plugs:
185+
- desktop
186+
- desktop-legacy
187+
- wayland
188+
- x11
189+
190+
parts:
191+
processing:
192+
plugin: dump
193+
source: deb/processing_$version-1_$arch.deb
194+
source-type: deb
195+
stage-packages:
196+
- openjdk-17-jdk
197+
override-prime: |
198+
snapcraftctl prime
199+
chmod -R +x opt/processing/lib/app/resources/jdk-*
200+
""".trimIndent()
201+
dir.file("../snapcraft.yaml").asFile.writeText(content)
202+
}
203+
204+
tasks.register<Exec>("packageSnap"){
205+
onlyIf { org.gradle.internal.os.OperatingSystem.current().isLinux }
206+
dependsOn("packageDeb", "generateSnapConfiguration")
207+
group = "compose desktop"
208+
209+
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
210+
workingDir = distributable.destinationDir.dir("../").get().asFile
211+
212+
commandLine("snapcraft")
213+
}
214+
160215
afterEvaluate{
161216
tasks.named("packageDmg").configure{
162217
dependsOn("packageCustomDmg")
@@ -168,6 +223,9 @@ afterEvaluate{
168223
group = "compose desktop"
169224
actions = emptyList()
170225
}
226+
tasks.named("packageDistributionForCurrentOS").configure {
227+
dependsOn("packageSnap")
228+
}
171229
}
172230

173231

0 commit comments

Comments
 (0)