Skip to content

Commit

Permalink
Merge pull request #77 from Konyaco/sync_master_target
Browse files Browse the repository at this point in the history
Sync master target
  • Loading branch information
Konyaco authored Nov 7, 2024
2 parents 3033df6 + be6df56 commit eeb0d18
Show file tree
Hide file tree
Showing 87 changed files with 2,583 additions and 918 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Deploy Github Pages
on:
push:
branches: [ "master" ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Run gradle wasmJsBrowserDistribution task
build:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Set up Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
with:
cache-disabled: true
- name: Build wasm target
run: ./gradlew :gallery:wasmJsBrowserDistribution
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload dist
path: ./gallery/build/dist/wasmJs/productionExecutable

# Single deploy job since we're just deploying
deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,28 @@
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Snapshot Build
name: Multiplatform Snapshot Build

on:
push:
branches:
- dev

pull_request_review:
types: submitted

jobs:
build:

strategy:
matrix:
type: [PublishLibrary, Android, Windows, Linux, macOS]
type: [PublishLibrary, Android, Windows, Linux, macOS, iOS, WasmJs, Js]
include:
- type: PublishLibrary
publish: release
os: macos-latest
- type: Android
android: apk
os: macos-latest
os: ubuntu-latest
- type: Windows
desktop: msi
os: windows-latest
Expand All @@ -34,8 +36,18 @@ jobs:
- type: macOS
desktop: dmg
os: macos-latest
- type: iOS
iOS: ipa
os: macos-latest
- type: WasmJs
js: wasmJs
os: windows-latest
- type: Js
js: js
os: ubuntu-latest

runs-on: ${{ matrix.os }}
if: ${{ github.event_name != 'pull_request_review' || github.event.review.state == 'approved' }}
permissions:
contents: read
packages: write
Expand All @@ -56,8 +68,9 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

# Publish Snapshot Library
- name: Publish Library
if: ${{ matrix.publish }}
if: ${{ github.event_name == 'push' && matrix.type == 'PublishLibrary' }}
run: |
./gradlew publishToMavenLocal
./gradlew publish
Expand All @@ -69,12 +82,13 @@ jobs:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

- name: Upload Library Artifact
if: ${{ matrix.publish }}
if: ${{ github.event_name == 'push' && matrix.type == 'PublishLibrary' }}
uses: actions/upload-artifact@v4
with:
name: Repository-${{ github.run_id }}
path: ~/.m2/repository

# Android Build Action
- name: Build Gallery for ${{ matrix.type }}
if: ${{ matrix.android }}
run: |
Expand All @@ -94,6 +108,7 @@ jobs:
name: Gallery-${{ matrix.type }}-${{ github.run_id }}
path: ${{github.workspace}}/gallery/build/outputs/**/*.${{ matrix.android }}

# Desktop Build Action
- name: Build Gallery for ${{ matrix.type }}
if: ${{ matrix.desktop }}
run: |
Expand All @@ -105,3 +120,35 @@ jobs:
with:
name: Gallery-${{ matrix.type }}-${{ github.run_id }}
path: ${{github.workspace}}/gallery/build/compose/binaries/main-release/${{ matrix.desktop }}/*.${{ matrix.desktop }}

# iOS Build Action, Note: Due to the long build time, the iOS build only build the debug version.
- name: Set up Xcode
if: ${{ matrix.iOS }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 'latest-stable'

- name: Build Gallery for iOS
if: ${{ matrix.iOS }}
run: |
xcodebuild -scheme iosApp -configuration Debug -sdk iphoneos -archivePath gallery/iosApp/build/Gallery.xcarchive archive -workspace gallery/iosApp/iosApp.xcodeproj/project.xcworkspace CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
- name: Upload iOS Artifact
if: ${{ matrix.iOS }}
uses: actions/upload-artifact@v4
with:
name: Gallery-${{ matrix.type }}-${{ github.run_id }}
path: ${{ github.workspace }}/gallery/iosApp/build/

# Js and WasmJs Build Action
- name: Build Gallery for ${{ matrix.type }}
if: ${{ matrix.js }}
run: |
./gradlew :gallery:${{ matrix.js }}BrowserDistribution
- name: Upload ${{ matrix.type }} build artifacts
if: ${{ matrix.js }}
uses: actions/upload-artifact@v4
with:
name: Gallery-${{ matrix.type }}-${{ github.run_id }}
path: ./gallery/build/dist/${{ matrix.js }}/productionExecutable
18 changes: 14 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
.gradle/
.idea/
build/
local.properties
*.iml
.gradle
.idea
.kotlin
.DS_Store
build
*/build
captures
.externalNativeBuild
.cxx
local.properties
xcuserdata/
Pods/
*.jks
*yarn.lock
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The copyright of the icon assets (in `com.konyaco.fluent.icons` package) belongs
### Compound Components

- [x] CalendarView (Simple)
> If you need running on the Android 7.1 and below, you should enable [core library desugar](https://developer.android.com/studio/write/java8-support#library-desugaring) to avoid crash.
- [x] DateTimePicker (Simple)
- [x] Color Picker
- [ ] Navigation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,15 @@ object BuildConfig {

const val packageName = "$group.fluent"

private const val snapshotLibraryVersion = "0.1.0-SNAPSHOT"
internal const val snapshotLibraryVersion = "0.1.0-SNAPSHOT"

val isRelease = System.getenv("PROJECT_BUILD_TYPE") == "release"

val gitTag = Runtime
.getRuntime()
.exec("git describe --abbrev=0 --tags")
.inputReader()
.readLine()
var libraryVersion: String = snapshotLibraryVersion
internal set

val relativeCommitCount = Runtime
.getRuntime()
.exec("git describe --tags")
.inputReader()
.readLine()
.removePrefix(gitTag)
.let {
if (it.isNotEmpty()) {
it.split("-")[1].toInt()
} else {
0
}
}

val libraryVersion = when {
isRelease -> gitTag
else -> snapshotLibraryVersion
}

val integerVersionName = libraryVersion
.removePrefix("v")
.removeSuffix("-SNAPSHOT")
.substringBefore("-dev")
.let {
val parts = it.split(".")
var major = parts.getOrNull(0) ?: "0"
var minor = parts.getOrNull(1) ?: "0"
if (major.startsWith("0")) {
major = "1"
minor = "0"
}
when(parts.size) {
1, 2 -> "${major}.$minor.$relativeCommitCount"
else -> {
val patchVersion = parts[2].toIntOrNull() ?: 0
"${major}.${minor}.${patchVersion * 200 + relativeCommitCount}"
}
}
}
var integerVersionName: String = ""
internal set

object Android {
const val compileSdkVersion = 34
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
package com.konyaco.fluent.plugin.build

import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree

@OptIn(ExperimentalWasmDsl::class, ExperimentalKotlinGradlePluginApi::class)
fun KotlinMultiplatformExtension.applyTargets(publish: Boolean = true) {
jvm("desktop")
androidTarget {
if (publish) publishLibraryVariants("release")
}
jvmToolchain(BuildConfig.Jvm.jvmToolchainVersion)
wasmJs { browser() }
js { browser() }
iosX64()
iosArm64()
iosSimulatorArm64()

applyHierarchyTemplate {
sourceSetTrees(KotlinSourceSetTree.main, KotlinSourceSetTree.test)

common {
group("skiko") {
withCompilations {
it.target.platformType != KotlinPlatformType.androidJvm
}
}

group("desktopAndAndroid") {
withJvm()
withAndroidTarget()
}

group("jsAndWasm") {
withJs()
withWasmJs()
}

group("apple") {
withApple()
}

group("ios") {
withIos()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.konyaco.fluent.plugin.build

import com.konyaco.fluent.plugin.build.BuildConfig.isRelease
import com.konyaco.fluent.plugin.build.BuildConfig.libraryVersion
import com.konyaco.fluent.plugin.build.BuildConfig.snapshotLibraryVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.publish.PublishingExtension
Expand All @@ -14,6 +17,9 @@ import org.gradle.plugins.signing.SigningExtension

class BuildPlugin : Plugin<Project> {
override fun apply(target: Project) {

setupLibraryVersion(target)

target.allprojects.forEach { project ->
project.afterEvaluate {

Expand Down Expand Up @@ -91,4 +97,53 @@ class BuildPlugin : Plugin<Project> {
}
}
}



private fun setupLibraryVersion(target: Project) {
val providers = target.providers

val gitTag = providers.exec {
commandLine("git", "describe", "--abbrev=0", "--tags")
isIgnoreExitValue = true
}.standardOutput.asText.get().trim()
val relativeCommitCount = providers.exec {
commandLine("git", "describe", "--tags")
isIgnoreExitValue = true
}.standardOutput.asText.get().trim()
.removePrefix(gitTag)
.let {
if (it.isNotEmpty()) {
it.split("-")[1].toInt()
} else {
0
}
}

libraryVersion = when {
isRelease -> gitTag
else -> snapshotLibraryVersion
}

BuildConfig.integerVersionName = libraryVersion
.removePrefix("v")
.removeSuffix("-SNAPSHOT")
.substringBefore("-dev")
.let {
val parts = it.split(".")
var major = parts.getOrNull(0) ?: "0"
var minor = parts.getOrNull(1) ?: "0"
if (major.startsWith("0")) {
major = "1"
minor = "0"
}
when (parts.size) {
1, 2 -> "${major}.$minor.$relativeCommitCount"
else -> {
val patchVersion = parts[2].toIntOrNull() ?: 0
"${major}.${minor}.${patchVersion * 200 + relativeCommitCount}"
}
}
}
}
}
Loading

0 comments on commit eeb0d18

Please sign in to comment.