diff --git a/.github/workflows/Main.yml b/.github/workflows/Main.yml index 5615a79d..522fa997 100644 --- a/.github/workflows/Main.yml +++ b/.github/workflows/Main.yml @@ -1,4 +1,4 @@ -name: Android Main CI +name: Multiplatform Main on: push: @@ -9,36 +9,30 @@ on: - 'media/**' jobs: - build: - runs-on: ubuntu-latest + multiplatform-build: + name: Multiplatform Build + runs-on: macos-latest steps: - uses: actions/checkout@v2.5.0 - + - name: set up JDK 17 uses: actions/setup-java@v3.6.0 with: java-version: '17' distribution: 'adopt' - + - name: Setup Gradle uses: gradle/gradle-build-action@v2.4.2 - name: Grant execute permission for gradlew run: chmod +x gradlew - + - name: Build with Gradle - env: - MONSTER_COMPENDIUM_KEYSTORE_PASSWORD: ${{ secrets.MONSTER_COMPENDIUM_KEYSTORE_PASSWORD }} - run: ./gradlew assembleRelease testReleaseUnitTest jvmTest -Pdev + run: ./gradlew testReleaseUnitTest jvmTest assembleRelease :app:packageDmg linkReleaseFrameworkIosSimulatorArm64 -Pdev - name: Verify database migration run: chmod +x ./scripts/sqldelight/verifyDatabaseMigration && ./scripts/sqldelight/verifyDatabaseMigration - - name: Generate AAB - env: - MONSTER_COMPENDIUM_KEYSTORE_PASSWORD: ${{ secrets.MONSTER_COMPENDIUM_KEYSTORE_PASSWORD }} - run: ./gradlew bundleRelease - - name: Upload the test report if: failure() uses: actions/upload-artifact@v3.1.1 @@ -48,21 +42,81 @@ jobs: feature-monster-compendium/build/reports/tests data/build/reports/tests domain/build/reports/tests - + + - name: Upload Dmg + uses: actions/upload-artifact@v3.1.1 + with: + name: MonsterCompendium-dmg + path: app/build/compose/binaries/main/dmg/*.dmg + - name: Upload an APK uses: actions/upload-artifact@v3.1.1 with: - name: app-dev-release.apk + name: app-dev-release-apk path: app/build/outputs/apk/release/app-dev-release.apk - + - name: Upload an APK metadata JSON uses: actions/upload-artifact@v3.1.1 with: - name: output-metadata.json + name: app-output-metadata-json path: app/build/outputs/apk/release/output-metadata.json - name: Upload an AAB uses: actions/upload-artifact@v3.1.1 with: - name: app-release.aab + name: app-release-aab path: app/build/outputs/bundle/release/app-release.aab + + ubuntu-desktop-distribution: + name: Ubuntu Desktop Distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.5.0 + + - name: set up JDK 17 + uses: actions/setup-java@v3.6.0 + with: + java-version: '17' + distribution: 'adopt' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.4.2 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew :app:packageDeb + + - name: Upload Deb + uses: actions/upload-artifact@v3.1.1 + with: + name: MonsterCompendium-deb + path: app/build/compose/binaries/main/deb/*.deb + + windows-desktop-distribution: + name: Windows Desktop Distribution + runs-on: windows-latest + steps: + - uses: actions/checkout@v2.5.0 + + - name: set up JDK 17 + uses: actions/setup-java@v3.6.0 + with: + java-version: '17' + distribution: 'adopt' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.4.2 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew :app:packageMsi + + - name: Upload Msi + uses: actions/upload-artifact@v3.1.1 + with: + name: MonsterCompendium-msi + path: app/build/compose/binaries/main/msi/*.msi diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml index 40342fdb..84354262 100644 --- a/.github/workflows/PR.yml +++ b/.github/workflows/PR.yml @@ -1,4 +1,4 @@ -name: Android PR CI +name: Multiplatform PR on: pull_request: @@ -7,8 +7,9 @@ on: - 'media/**' jobs: - build: - runs-on: ubuntu-latest + multiplatform-build: + name: Multiplatform Build + runs-on: macos-latest steps: - uses: actions/checkout@v2.5.0 @@ -25,7 +26,7 @@ jobs: run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew assembleDebug testDebugUnitTest jvmTest + run: ./gradlew testDebugUnitTest jvmTest assembleDebug :app:packageDmg linkDebugFrameworkIosSimulatorArm64 - name: Verify database migration run: chmod +x ./scripts/sqldelight/verifyDatabaseMigration && ./scripts/sqldelight/verifyDatabaseMigration @@ -39,15 +40,75 @@ jobs: feature-monster-compendium/build/reports/tests data/build/reports/tests domain/build/reports/tests + + - name: Upload Dmg + uses: actions/upload-artifact@v3.1.1 + with: + name: MonsterCompendium-dmg + path: app/build/compose/binaries/main/dmg/*.dmg - name: Upload an APK uses: actions/upload-artifact@v3.1.1 with: - name: app-debug.apk + name: app-debug-apk path: app/build/outputs/apk/debug/app-debug.apk - name: Upload an APK metadata JSON uses: actions/upload-artifact@v3.1.1 with: - name: output-metadata.json + name: app-output-metadata-json path: app/build/outputs/apk/debug/output-metadata.json + + ubuntu-desktop-distribution: + name: Ubuntu Desktop Distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.5.0 + + - name: set up JDK 17 + uses: actions/setup-java@v3.6.0 + with: + java-version: '17' + distribution: 'adopt' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.4.2 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew :app:packageDeb + + - name: Upload Deb + uses: actions/upload-artifact@v3.1.1 + with: + name: MonsterCompendium-deb + path: app/build/compose/binaries/main/deb/*.deb + + windows-desktop-distribution: + name: Windows Desktop Distribution + runs-on: windows-latest + steps: + - uses: actions/checkout@v2.5.0 + + - name: set up JDK 17 + uses: actions/setup-java@v3.6.0 + with: + java-version: '17' + distribution: 'adopt' + + - name: Setup Gradle + uses: gradle/gradle-build-action@v2.4.2 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew :app:packageMsi + + - name: Upload Msi + uses: actions/upload-artifact@v3.1.1 + with: + name: MonsterCompendium-msi + path: app/build/compose/binaries/main/msi/*.msi diff --git a/app/build.gradle.kts b/app/build.gradle.kts index aa3e79bb..45ad9542 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -201,22 +201,24 @@ android { } } -compose.desktop { - application { - mainClass = "MainKt" - - nativeDistributions { - targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) - packageName = "br.alexandregpereira.hunter" - packageVersion = "1.0.0" +compose { + desktop { + application { + mainClass = "MainKt" + + nativeDistributions { + modules("java.sql") + targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) + packageName = "MonsterCompendium" + packageVersion = "1.0.0" + } } } -} - -compose.resources { - publicResClass = false - packageOfResClass = "br.alexandregpereira.hunter.app.ui.resources" - generateResClass = always + resources { + publicResClass = false + packageOfResClass = "br.alexandregpereira.hunter.app.ui.resources" + generateResClass = always + } } composeCompiler { diff --git a/domain/app/data/src/jvmMain/kotlin/br/alexandregpereira/hunter/data/di/JvmSqlDriverFactory.kt b/domain/app/data/src/jvmMain/kotlin/br/alexandregpereira/hunter/data/di/JvmSqlDriverFactory.kt index 0b0b9c3f..e5963f66 100644 --- a/domain/app/data/src/jvmMain/kotlin/br/alexandregpereira/hunter/data/di/JvmSqlDriverFactory.kt +++ b/domain/app/data/src/jvmMain/kotlin/br/alexandregpereira/hunter/data/di/JvmSqlDriverFactory.kt @@ -20,9 +20,16 @@ import br.alexandregpereira.hunter.data.Database import com.squareup.sqldelight.db.SqlDriver import com.squareup.sqldelight.sqlite.driver.JdbcSqliteDriver import org.koin.core.scope.Scope +import java.io.File internal actual fun Scope.createSqlDriver(): SqlDriver { - val driver: SqlDriver = JdbcSqliteDriver("jdbc:sqlite:hunter-database.db") + val userFolder = System.getProperty("user.home") + val appDataFolder = File(userFolder, ".monster-compendium") + if (appDataFolder.exists().not()) { + appDataFolder.mkdirs() + } + val databasePath = File(appDataFolder, "hunter-database.db") + val driver: SqlDriver = JdbcSqliteDriver("jdbc:sqlite:${databasePath.absolutePath}") Database.Schema.create(driver) return driver }