Skip to content

Commit ba97f23

Browse files
committed
Snapcraft Distribution
[skip ci]
1 parent dfc1e5a commit ba97f23

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

.github/workflows/release-gradle.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
version:
88
runs-on: ubuntu-latest
99
outputs:
10-
build_number: ${{ steps.tag_info.outputs.build_number }}
10+
revision: ${{ steps.tag_info.outputs.revision }}
1111
version: ${{ steps.tag_info.outputs.version }}
1212
steps:
1313
- name: Extract version and revision
@@ -149,6 +149,8 @@ jobs:
149149
ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.appleID: ${{ secrets.PROCESSING_APPLE_ID }}
150150
ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.password: ${{ secrets.PROCESSING_APP_PASSWORD }}
151151
ORG_GRADLE_PROJECT_compose.desktop.mac.notarization.teamID: ${{ secrets.PROCESSING_TEAM_ID }}
152+
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.PROCESSING_SNAPCRAFT_TOKEN }}
153+
ORG_GRADLE_PROJECT_snapname: ${{ vars.SNAP_NAME }}
152154

153155
- name: Upload portables to release
154156
uses: svenstaro/upload-release-action@v2

app/build.gradle.kts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,22 +174,25 @@ tasks.register<Exec>("packageCustomMsi"){
174174
)
175175
}
176176

177+
val snapname = findProperty("snapname") ?: rootProject.name
178+
val snaparch = when (System.getProperty("os.arch")) {
179+
"amd64", "x86_64" -> "amd64"
180+
"aarch64" -> "arm64"
181+
else -> System.getProperty("os.arch")
182+
}
177183
tasks.register("generateSnapConfiguration"){
178184
onlyIf { org.gradle.internal.os.OperatingSystem.current().isLinux }
179185
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
180186
dependsOn(distributable)
181187

182-
val arch = when (System.getProperty("os.arch")) {
183-
"amd64", "x86_64" -> "amd64"
184-
"aarch64" -> "arm64"
185-
else -> System.getProperty("os.arch")
186-
}
188+
187189

188190
val version = if(version == "unspecified") "1.0.0" else version
189191

192+
190193
val dir = distributable.destinationDir.get()
191194
val content = """
192-
name: ${rootProject.name}
195+
name: $snapname
193196
version: $version
194197
base: core22
195198
summary: A creative coding editor
@@ -210,13 +213,14 @@ tasks.register("generateSnapConfiguration"){
210213
parts:
211214
processing:
212215
plugin: dump
213-
source: deb/processing_$version-1_$arch.deb
216+
source: deb/processing_$version-1_$snaparch.deb
214217
source-type: deb
215218
stage-packages:
216219
- openjdk-17-jdk
217220
override-prime: |
218221
snapcraftctl prime
219222
chmod -R +x opt/processing/lib/app/resources/jdk-*
223+
rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts
220224
""".trimIndent()
221225
dir.file("../snapcraft.yaml").asFile.writeText(content)
222226
}
@@ -230,6 +234,17 @@ tasks.register<Exec>("packageSnap"){
230234
workingDir = distributable.destinationDir.dir("../").get().asFile
231235

232236
commandLine("snapcraft")
237+
commandLine("cp ${snapname}_${version}_${snaparch}.snap ${name}_${version}_${snaparch}.snap")
238+
}
239+
tasks.register<Exec>("uploadSnap"){
240+
onlyIf { org.gradle.internal.os.OperatingSystem.current().isLinux }
241+
dependsOn("packageSnap")
242+
group = "compose desktop"
243+
244+
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
245+
workingDir = distributable.destinationDir.dir("../").get().asFile
246+
247+
commandLine("snapcraft upload ${snapname}_${version}_${snaparch}.snap")
233248
}
234249
tasks.register<Zip>("zipDistributable"){
235250
dependsOn("createDistributable")
@@ -262,7 +277,7 @@ afterEvaluate{
262277
if(compose.desktop.application.nativeDistributions.macOS.notarization.appleID.isPresent){
263278
dependsOn("notarizeDmg")
264279
}
265-
dependsOn("packageSnap")
280+
dependsOn("packageSnap", "uploadSnap")
266281
}
267282
}
268283

0 commit comments

Comments
 (0)