Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterofbread committed Aug 17, 2024
2 parents 8ec03b2 + 3690096 commit d008040
Show file tree
Hide file tree
Showing 36 changed files with 483 additions and 252 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,11 @@ jobs:
- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Install desktop-file-utils, appstream
uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: desktop-file-utils appstream

- name: Download appimagetool
run: wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool

- name: Grant execute permission for appimagetool
run: chmod +x /usr/local/bin/appimagetool

- name: Build AppImage
run: ./gradlew desktopApp:packageReleaseAppImage
- name: Build tarball
run: ./gradlew desktopApp:packageReleaseTarball

- name: Upload AppImage artifact
- name: Upload tarball artifact
uses: actions/upload-artifact@v3
with:
name: spmp-linux-release
path: desktopApp/build/compose/binaries/main-release/appimage/*.appimage
path: desktopApp/build/outputs/*.tar.gz
8 changes: 4 additions & 4 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ jobs:
- name: Set up Gradle
uses: gradle/gradle-build-action@v3

- name: Build exe
run: .\gradlew.bat desktopApp:packageReleaseExe
- name: Build zip
run: .\gradlew.bat desktopApp:packageReleaseZip

- name: Upload exe artifact
- name: Upload zip artifact
uses: actions/upload-artifact@v3
with:
name: spmp-windows-release
path: desktopApp/build/compose/binaries/main-release/exe/*.exe
path: desktopApp/build/outputs/*.zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local.properties
.vscode
*.log
/.kotlin
/kotlin-js-store

app/debug/
app/release/
Expand Down
2 changes: 1 addition & 1 deletion androidApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ android {
}

lint {
// What is this needed for?
disable.add("ByteOrderMark")
disable.add("Instantiatable")
}

sourceSets.getByName("main") {
Expand Down
6 changes: 5 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ plugins {

repositories {
gradlePluginPortal()
maven("https://jitpack.io")
}

dependencies {
implementation("com.github.gmazzo.buildconfig:plugin:5.3.5")
implementation("com.github.gmazzo.buildconfig:plugin:5.4.0")
implementation("xmlpull:xmlpull:1.1.3.1")
implementation("com.github.kobjects:kxml2:2.4.1")
}


tasks.withType(JavaCompile::class) {
options.release.set(21)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.gradle.api.file.Directory
import plugin.shared.Command
import plugin.spmp.ProjectConfigValues
import java.util.Properties
Expand Down Expand Up @@ -85,8 +84,10 @@ fun Task.buildConfig(debug_mode: Boolean) {
)

buildConfig {
buildConfigField("GIT_COMMIT_HASH", Command.getCurrentGitCommitHash())
buildConfigField("GIT_TAG", Command.getCurrentGitTag())
val tag_override: String? = project.properties["GIT_TAG_OVERRIDE"] as String?
val git_tag: String? = (tag_override ?: Command.getCurrentGitTag())?.ifBlank { null }
buildConfigField("GIT_TAG", git_tag)
buildConfigField("GIT_COMMIT_HASH", if (git_tag != null) null else Command.getCurrentGitCommitHash())
buildConfigField("IS_DEBUG", debug_mode)
}
}
Expand Down
3 changes: 2 additions & 1 deletion buildSrc/src/main/kotlin/plugins/shared/Command.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class CommandClass(project: Project): Project by project {

fun getCurrentGitTag(): String? {
try {
return cmd("git", "tag", "--points-at", "HEAD").ifBlank { null }
val tags: List<String> = cmd("git", "tag", "--points-at", "HEAD").split('\n')
return tags.lastOrNull()
}
catch (e: Throwable) {
return null
Expand Down
144 changes: 144 additions & 0 deletions buildSrc/src/main/kotlin/plugins/shared/DesktopUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
package plugins.shared

import org.xmlpull.v1.XmlPullParser
import org.xmlpull.v1.XmlPullParserFactory
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.jvm.tasks.Jar
import plugin.spmp.SpMpDeps
import plugin.spmp.getDeps
import java.io.File
import java.io.InputStreamReader

object DesktopUtils {
fun runChecks(project: Project) {
if (System.getenv("NIX_PATH") != null && !project.hasProperty("BUILD_ON_NIX")) {
throw GradleException("It appears you're trying to build in a Nix environment. Desktop binaries built on Nix do not function on other systems. To build anyway, run Gradle with '-PBUILD_ON_NIX'.")
}
}

fun getOutputDir(project: Project): File =
project.layout.buildDirectory.asFile.get().resolve("outputs")

fun getOutputFilename(project: Project): String {
val platform: String =
if (Os.isFamily(Os.FAMILY_WINDOWS)) "windows-x86_64"
else "linux-x86_64"

return project.rootProject.name.lowercase() + "-v" + project.getString("version_string") + "-$platform"
}

fun getUnneededLibraries(): List<String> =
listOf("javacpp", "ffmpeg")

fun getUnneededPlatforms(is_windows: Boolean): List<String> =
listOf(
if (is_windows) "linux-x86_64"
else "windows-x86_64",
"linux-arm64",
"linux-ppc64le",
"android-arm64",
"android-x86_64",
"macosx-arm64",
"macosx-x86_64",
"ios-arm64",
"ios-x86_64"
)

const val LOCAL_PROPERTIES_PATH: String = "local.properties"
val Project.strings_file: File get() = rootProject.file("shared/src/commonMain/resources/assets/values/strings.xml")

fun Project.getString(key: String): String {
val reader: InputStreamReader = strings_file.reader()
val parser: XmlPullParser = XmlPullParserFactory.newInstance().newPullParser()
parser.setInput(reader)

while (parser.eventType != XmlPullParser.END_DOCUMENT) {
if (parser.eventType != XmlPullParser.START_TAG) {
parser.next()
continue
}

if (parser.getAttributeValue(null, "name") != key) {
parser.next()
continue
}

val ret: String = parser.nextText()
reader.close()
return ret
}

reader.close()
throw NoSuchElementException(key)
}

fun Jar.excludeUnneededFiles() {
val is_windows: Boolean = Os.isFamily(Os.FAMILY_WINDOWS)
val platforms: List<String> = DesktopUtils.getUnneededPlatforms(is_windows = is_windows)
val libraries: List<String> = listOf("javacpp", "ffmpeg")

exclude(platforms.flatMap { platform -> libraries.map { library -> "/org/bytedeco/$library/$platform/*" } })

val unneeded_sqlite_architectures: List<String> =
listOf(
"arm",
"armv6",
"armv7",
"aarch64",
"x86",
"ppc64"
)
val unneeded_sqlite_platforms: List<String> =
listOf(
if (is_windows) "Linux"
else "Windows",
"Linux-Android",
"Linux-Musl",
"FreeBSD",
"Mac"
)

exclude(
unneeded_sqlite_architectures.flatMap { arch ->
unneeded_sqlite_platforms.map { platform ->
"/org/sqlite/native/$platform/$arch/*"
}
}
)
}

fun File.removeUnneededJarsFromDir(
project: Project,
is_windows: Boolean,
deps: SpMpDeps = project.getDeps()
) {
check(isDirectory) { "Directory passed to removeUnneededJarsFromDir does not exist ($absolutePath)" }

val ffmpeg_version: String = deps.getVersion("org.bytedeco:ffmpeg-platform")
val javacpp_version: String = ffmpeg_version.split('-', limit = 2)[1]

val platforms: List<String> = DesktopUtils.getUnneededPlatforms(is_windows = is_windows)
val jar_prefixes: List<String> = platforms.flatMap { platform ->
DesktopUtils.getUnneededLibraries().map { library ->
val version: String =
when (library) {
"javacpp" -> javacpp_version
"ffmpeg" -> ffmpeg_version
else -> throw NotImplementedError(library)
}
return@map "$library-$version-$platform"
}
}

for (file in this.listFiles().orEmpty()) {
for (prefix in jar_prefixes) {
if (file.name.startsWith(prefix) && file.name.endsWith(".jar")) {
file.delete()
project.logger.lifecycle("Removing lib/app/${file.name}")
}
}
}
}
}
16 changes: 8 additions & 8 deletions buildSrc/src/main/kotlin/plugins/spmp/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ class SpMpDeps(extra: Map<String, Any>) {
val dependencies: Map<String, DependencyInfo> =
mapOf(
"dev.toastbits:spms" to DependencyInfo(
version = "0.4.0-alpha4",
version = "0.4.0-beta2",
name = "spmp-server",
author = "toasterofbread",
url = "https://github.com/toasterofbread/spmp-server",
license = "GPL-2.0",
license = "GPL-3.0",
license_url = "https://github.com/toasterofbread/spmp-server/blob/6dde651ffc102d604ac7ecd5ac7471b1572fd2e6/LICENSE"
),
"dev.toastbits.composekit" to DependencyInfo(
version = "a2a8731f32",
version = "2d2f8d5e68",
name = "ComposeKit",
author = "toasterofbread",
url = "https://github.com/toasterofbread/composekit",
license = "GPL-3.0",
license_url = "https://github.com/toasterofbread/ComposeKit/blob/136f216e65395660255d3270af9b79c90ae2254c/LICENSE"
),
"dev.toastbits.ytmkt" to DependencyInfo(
version = "0.2.3",
version = "0.3.0",
name = "ytm-kt",
author = "toasterofbread",
url = "https://github.com/toasterofbread/ytm-kt",
Expand Down Expand Up @@ -199,7 +199,7 @@ class SpMpDeps(extra: Map<String, Any>) {
license_url = "https://github.com/Kamel-Media/Kamel/blob/6eb1dd7fea43beb2e30d8e5d162b2b5e212e5950/LICENSE"
),
"io.ktor" to DependencyInfo(
version = "2.3.9",
version = "3.0.0-beta-2",
name = "Ktor",
author = "JetBrains",
url = "https://github.com/ktorio/ktor",
Expand Down Expand Up @@ -250,15 +250,15 @@ class SpMpDeps(extra: Map<String, Any>) {
license_url = "https://github.com/anggrayudi/SimpleStorage/blob/cdab9945ccaeb6deae3906db3af98a87bc450e5f/LICENSE"
),
"io.github.jan-tennert.supabase:functions-kt" to DependencyInfo(
version = "1.3.2",
version = "2.5.3-wasm0",
name = "supabase-kt",
author = " jan-tennert",
url = "https://github.com/supabase-community/supabase-kt",
license = "MIT",
license_url = "https://github.com/supabase-community/supabase-kt/blob/d198a112ba7e1b11d83cd28eba74fdd863d259c3/LICENSE"
),
"dev.toastbits.compose-webview-multiplatform" to DependencyInfo(
version = "2d39439922",
"com.github.toasterofbread.compose-webview-multiplatform" to DependencyInfo(
version = "21331f37c1",
name = "WebView for JetBrains Compose Multiplatform",
author = "KevinnZou",
url = "https://github.com/KevinnZou/compose-webview-multiplatform",
Expand Down
36 changes: 0 additions & 36 deletions desktopApp/appimage-runtime/LICENSE

This file was deleted.

Binary file removed desktopApp/appimage-runtime/runtime-x86_64
Binary file not shown.
Loading

0 comments on commit d008040

Please sign in to comment.