mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Github actions simplification
This commit is contained in:
+110
-46
@@ -167,6 +167,12 @@ tasks.register("lsp-develop"){
|
||||
}
|
||||
|
||||
val version = if(project.version == "unspecified") "1.0.0" else project.version
|
||||
val distributable = { tasks.named<AbstractJPackageTask>("createDistributable").get() }
|
||||
val arch = when (System.getProperty("os.arch")) {
|
||||
"amd64", "x86_64" -> "amd64"
|
||||
"aarch64" -> "arm64"
|
||||
else -> System.getProperty("os.arch")
|
||||
}
|
||||
|
||||
tasks.register<Exec>("installCreateDmg") {
|
||||
onlyIf { OperatingSystem.current().isMacOsX }
|
||||
@@ -176,11 +182,10 @@ tasks.register<Exec>("packageCustomDmg"){
|
||||
onlyIf { OperatingSystem.current().isMacOsX }
|
||||
group = "compose desktop"
|
||||
|
||||
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
|
||||
dependsOn(distributable, "installCreateDmg")
|
||||
dependsOn(distributable(), "installCreateDmg")
|
||||
|
||||
val packageName = distributable.packageName.get()
|
||||
val dir = distributable.destinationDir.get()
|
||||
val packageName = distributable().packageName.get()
|
||||
val dir = distributable().destinationDir.get()
|
||||
val dmg = dir.file("../dmg/$packageName-$version.dmg").asFile
|
||||
val app = dir.file("$packageName.app").asFile
|
||||
|
||||
@@ -235,64 +240,123 @@ tasks.register<Exec>("packageCustomMsi"){
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
tasks.register("generateSnapConfiguration"){
|
||||
onlyIf { OperatingSystem.current().isLinux }
|
||||
|
||||
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
|
||||
dependsOn(distributable)
|
||||
|
||||
val name = findProperty("snapname") as String? ?: rootProject.name
|
||||
val arch = when (System.getProperty("os.arch")) {
|
||||
"amd64", "x86_64" -> "amd64"
|
||||
"aarch64" -> "arm64"
|
||||
else -> System.getProperty("os.arch")
|
||||
}
|
||||
val confinement = findProperty("snapconfinement") as String? ?: "strict"
|
||||
val dir = distributable.destinationDir.get()
|
||||
val base = layout.projectDirectory.file("linux/snapcraft.base.yml")
|
||||
val confinement = (findProperty("snapconfinement") as String?).takeIf { !it.isNullOrBlank() } ?: "strict"
|
||||
val dir = distributable().destinationDir.get()
|
||||
val base = layout.projectDirectory.file("linux/snapcraft.yml")
|
||||
|
||||
doFirst {
|
||||
|
||||
var content = base
|
||||
.asFile
|
||||
.readText()
|
||||
.replace("\$name", name)
|
||||
.replace("\$arch", arch)
|
||||
.replace("\$version", version as String)
|
||||
.replace("\$confinement", confinement)
|
||||
.let {
|
||||
if (confinement != "classic") return@let it
|
||||
// If confinement is not strict, remove the PLUGS section
|
||||
val start = it.indexOf("# PLUGS START")
|
||||
val end = it.indexOf("# PLUGS END")
|
||||
if (start != -1 && end != -1) {
|
||||
val before = it.substring(0, start)
|
||||
val after = it.substring(end + "# PLUGS END".length)
|
||||
return@let before + after
|
||||
}
|
||||
return@let it
|
||||
}
|
||||
dir.file("../snapcraft.yaml").asFile.writeText(content)
|
||||
replaceVariablesInFile(
|
||||
base,
|
||||
dir.file("../snapcraft.yaml"),
|
||||
mapOf(
|
||||
"name" to name,
|
||||
"arch" to arch,
|
||||
"version" to version as String,
|
||||
"confinement" to confinement,
|
||||
"deb" to "deb/${rootProject.name}_${version}-1_${arch}.deb"
|
||||
),
|
||||
if (confinement == "classic") listOf("PLUGS") else emptyList()
|
||||
)
|
||||
}
|
||||
}
|
||||
tasks.register("generateFlatpakConfiguration"){
|
||||
val identifier = findProperty("flathubidentifier") as String? ?: "org.processing.pde"
|
||||
|
||||
val dir = distributable().destinationDir.get()
|
||||
val base = layout.projectDirectory.file("linux/flathub.yml")
|
||||
|
||||
doFirst {
|
||||
replaceVariablesInFile(
|
||||
base,
|
||||
dir.file("../flatpak/$identifier.yml"),
|
||||
mapOf(
|
||||
"identifier" to identifier,
|
||||
"deb" to dir.file("../deb/${rootProject.name}_${version}-1_${arch}.deb").asFile.absolutePath
|
||||
),
|
||||
emptyList()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun replaceVariablesInFile(
|
||||
source: RegularFile,
|
||||
target: RegularFile,
|
||||
variables: Map<String, String>,
|
||||
sections: List<String>
|
||||
){
|
||||
var content = source.asFile.readText()
|
||||
for ((key, value) in variables) {
|
||||
content = content.replace("\$$key", value)
|
||||
}
|
||||
if (sections.isNotEmpty()) {
|
||||
for (section in sections) {
|
||||
val start = content.indexOf("# $section START")
|
||||
val end = content.indexOf("# $section END")
|
||||
if (start != -1 && end != -1) {
|
||||
val before = content.substring(0, start)
|
||||
val after = content.substring(end + "# $section END".length)
|
||||
content = before + after
|
||||
}
|
||||
}
|
||||
}
|
||||
target.asFile.parentFile.mkdirs()
|
||||
target.asFile.writeText(content)
|
||||
}
|
||||
|
||||
tasks.register<Exec>("packageSnap"){
|
||||
onlyIf { OperatingSystem.current().isLinux }
|
||||
dependsOn("packageDeb", "generateSnapConfiguration")
|
||||
dependsOn("generateSnapConfiguration")
|
||||
group = "compose desktop"
|
||||
|
||||
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
|
||||
workingDir = distributable.destinationDir.dir("../").get().asFile
|
||||
workingDir = distributable().destinationDir.dir("../").get().asFile
|
||||
commandLine("snapcraft")
|
||||
}
|
||||
|
||||
tasks.register<Exec>("buildFlatpak"){
|
||||
onlyIf { OperatingSystem.current().isLinux }
|
||||
dependsOn("generateFlatpakConfiguration")
|
||||
group = "compose desktop"
|
||||
|
||||
val dir = distributable().destinationDir.get()
|
||||
val identifier = findProperty("flathubidentifier") as String? ?: "org.processing.pde"
|
||||
|
||||
workingDir = dir.file("../flatpak").asFile
|
||||
commandLine(
|
||||
"flatpak-builder",
|
||||
"--install-deps-from=https://flathub.org/repo/flathub.flatpakrepo",
|
||||
"--user",
|
||||
"--force-clean",
|
||||
"--repo=repo",
|
||||
"output",
|
||||
"$identifier.yml"
|
||||
)
|
||||
}
|
||||
|
||||
tasks.register<Exec>("packageFlatpak"){
|
||||
onlyIf { OperatingSystem.current().isLinux }
|
||||
dependsOn("buildFlatpak")
|
||||
group = "compose desktop"
|
||||
|
||||
val dir = distributable().destinationDir.get()
|
||||
val identifier = findProperty("flathubidentifier") as String? ?: "org.processing.pde"
|
||||
|
||||
workingDir = dir.file("../flatpak").asFile
|
||||
commandLine(
|
||||
"flatpak",
|
||||
"build-bundle",
|
||||
"./repo",
|
||||
"$identifier.flatpak",
|
||||
identifier
|
||||
)
|
||||
}
|
||||
tasks.register<Zip>("zipDistributable"){
|
||||
dependsOn("createDistributable", "setExecutablePermissions")
|
||||
group = "compose desktop"
|
||||
|
||||
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
|
||||
val dir = distributable.destinationDir.get()
|
||||
val packageName = distributable.packageName.get()
|
||||
val dir = distributable().destinationDir.get()
|
||||
val packageName = distributable().packageName.get()
|
||||
|
||||
from(dir){ eachFile{ permissions{ unix("755") } } }
|
||||
archiveBaseName.set(packageName)
|
||||
@@ -318,7 +382,7 @@ afterEvaluate{
|
||||
){
|
||||
dependsOn("notarizeDmg")
|
||||
}
|
||||
dependsOn("packageSnap", "zipDistributable")
|
||||
dependsOn("zipDistributable")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
id: org.processing.pde
|
||||
id: $identifier
|
||||
runtime: org.freedesktop.Platform
|
||||
runtime-version: '24.08'
|
||||
sdk: org.freedesktop.Sdk
|
||||
@@ -22,17 +22,17 @@ modules:
|
||||
- find /app/lib/app/resources/jdk/bin -type f -exec chmod +x {} +
|
||||
|
||||
# Install the desktop file and icon
|
||||
- install -D /app/lib/processing-Processing.desktop /app/share/applications/org.processing.pde.desktop
|
||||
- sed -i 's/^Icon=.*/Icon=org.processing.pde/' /app/share/applications/org.processing.pde.desktop
|
||||
- sed -i 's/^Exec=.*/Exec=\/app\/bin\/Processing/' /app/share/applications/org.processing.pde.desktop
|
||||
- install -D /app/lib/processing-Processing.desktop /app/share/applications/$identifier.desktop
|
||||
- sed -i 's/^Icon=.*/Icon=$identifier/' /app/share/applications/$identifier.desktop
|
||||
- sed -i 's/^Exec=.*/Exec=\/app\/bin\/Processing/' /app/share/applications/$identifier.desktop
|
||||
|
||||
# Install the mimetype info
|
||||
- install -D /app/lib/processing-Processing-MimeInfo.xml /app/share/mime/packages/org.processing.pde.xml
|
||||
- install -D /app/lib/processing-Processing-MimeInfo.xml /app/share/mime/packages/$identifier.xml
|
||||
|
||||
# - install -D /app/lib/Processing.png /app/share/icons/hicolor/512x512/apps/org.processing.pde.png
|
||||
- install -D /app/lib/application-x-processing.png /app/share/icons/hicolor/512x512/mimetypes/org.processing.pde-text-x-processing.png
|
||||
# - install -D /app/lib/Processing.png /app/share/icons/hicolor/512x512/apps/$identifier.png
|
||||
- install -D /app/lib/application-x-processing.png /app/share/icons/hicolor/512x512/mimetypes/$identifier-text-x-processing.png
|
||||
|
||||
sources:
|
||||
- type: file
|
||||
path: ../build/compose/binaries/main/deb/processing_1.0.0-1_amd64.deb
|
||||
path: $deb
|
||||
dest-filename: processing.deb
|
||||
@@ -32,7 +32,7 @@ apps:
|
||||
parts:
|
||||
processing:
|
||||
plugin: dump
|
||||
source: deb/processing_$version-1_$arch.deb
|
||||
source: $deb
|
||||
source-type: deb
|
||||
stage-packages:
|
||||
- openjdk-17-jre
|
||||
Reference in New Issue
Block a user