From 380d03f3f6a6df7be4c3335d283972e1d35f9735 Mon Sep 17 00:00:00 2001 From: F4bioo Date: Mon, 17 Jun 2024 00:07:33 -0300 Subject: [PATCH 1/2] Fix: Release workflows --- .github/workflows/publish-library.yml | 53 +++++++ .github/workflows/release-build.yml | 129 +++++++----------- .gitignore | 1 + .../{BubbleSetup.kt => TooltipSetup.kt} | 0 .../component/extension/PathExtension.kt | 39 +++++- buildSrc/src/main/java/Config.kt | 7 +- gradle/libs.versions.toml | 2 +- tourtip/build.gradle.kts | 92 +++++-------- tourtip/gradle.properties | 8 +- 9 files changed, 184 insertions(+), 147 deletions(-) create mode 100644 .github/workflows/publish-library.yml rename app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/{BubbleSetup.kt => TooltipSetup.kt} (100%) diff --git a/.github/workflows/publish-library.yml b/.github/workflows/publish-library.yml new file mode 100644 index 0000000..280fa37 --- /dev/null +++ b/.github/workflows/publish-library.yml @@ -0,0 +1,53 @@ +name: Publish Library + +on: + push: + tags: + - 'v*.*.*' + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Cache Gradle dependencies + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-gradle- + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'adopt' + + - name: Grant Gradlew Permission + run: chmod +x gradlew + + - name: Create KeyRingFile File + run: | + echo "$PGP_PRIVATE_KEY" | gpg --dearmor > secring.gpg + if ! test -f secring.gpg; then + echo "secring.gpg not found" + exit 1 + fi + env: + PGP_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }} + + - name: Publish Library to Maven Central + run: ./gradlew publishAndReleaseToMavenCentral --no-configuration-cache + env: + mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + signing.keyId: ${{ secrets.PGP_KEY_ID }} + signing.password: ${{ secrets.PGP_PRIVATE_KEY }} + signing.secretKeyRingFile: secring.gpg + + - name: Delete KeyRingFile File + run: rm -f secring.gpg diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index e5cbd7f..28be261 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -91,7 +91,7 @@ jobs: - name: Create APK Build Artifacts Folder run: mkdir -p apk-build-artifacts - - name: Move APK Builds Files to apk-build-artifacts + - name: Move APK Build File to apk-build-artifacts run: mv app/build/outputs/apk/release/app-release-unsigned.apk apk-build-artifacts/app-release-unsigned.apk - name: List Upload APK Build Artifacts @@ -104,14 +104,21 @@ jobs: name: apk-build path: apk-build-artifacts - aar-build: + lib-build: needs: lib-version - name: AAR Build + name: LIB Build runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v3 + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-maven-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: ${{ runner.os }}-maven- + - name: Cache Gradle dependencies uses: actions/cache@v2 with: @@ -130,66 +137,44 @@ jobs: - name: Grant Gradlew Permission run: chmod +x gradlew - - name: Build AAR Library - run: ./gradlew publishReleasePublicationToMavenLocal - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - PGP_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }} - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - - - name: Create AAR Build Artifacts Folder - run: mkdir -p aar-build-artifacts - - - name: Move AAR Builds Files to aar-build-artifacts - run: mv tourtip/build/outputs/aar/tourtip-release.aar aar-build-artifacts/tourtip-release.aar - - - name: List Upload AAR Build Artifacts - run: ls -l aar-build-artifacts - - - name: Upload AAR Build Artifacts - uses: actions/upload-artifact@v3 + - name: Download LIB Version Artifacts + uses: actions/download-artifact@v3 with: - retention-days: 1 - name: aar-build - path: aar-build-artifacts + name: lib-version + path: lib-version-artifacts - sign-pgp: - needs: aar-build - name: Sign PGP - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 + - name: List Download LIB Version Artifacts + run: ls -l lib-version-artifacts - - name: Download AAR Build Artifacts - uses: actions/download-artifact@v3 - with: - name: aar-build - path: aar-build-artifacts + - name: Read Release Tag File + run: echo "RELEASE_TAG=$(cat lib-version-artifacts/release_tag.txt)" >> $GITHUB_ENV - - name: List Download AAR Build Artifacts - run: ls -l aar-build-artifacts + - name: Build LIB files + run: ./gradlew publishMavenPublicationToMavenLocal + env: + PGP_KEY_ID: ${{ secrets.PGP_KEY_ID }} + PGP_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }} + PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} - - name: Import PGP Key - run: echo "${{ secrets.PGP_PRIVATE_KEY }}" | gpg --batch --import + - name: Create LIB Build Artifacts Folder + run: mkdir -p lib-build-artifacts - - name: Sign AAR with PGP - run: echo "${{ secrets.PGP_PASSPHRASE }}" | gpg --batch --yes --pinentry-mode loopback --passphrase-fd 0 --armor --detach-sign aar-build-artifacts/tourtip-release.aar + - name: Move LIB Build Files to lib-build-artifacts + run: cp ~/.m2/repository/com/fappslab/tourtip/tourtip/${{ env.RELEASE_TAG }}/* lib-build-artifacts/ - - name: List PGP Sign AAR Build Artifacts - run: ls -l aar-build-artifacts + - name: List Upload LIB Build Artifacts + run: ls -l lib-build-artifacts - - name: Upload PGP Sign Build Artifacts + - name: Upload LIB Build Artifacts uses: actions/upload-artifact@v3 with: retention-days: 1 - name: sign-pgp - path: aar-build-artifacts + name: lib-build + path: lib-build-artifacts - lib-deploy: - needs: sign-pgp - name: App Deploy + create-release: + needs: [apk-build, lib-build] + name: Create Release runs-on: ubuntu-latest steps: - name: Checkout repository @@ -227,11 +212,11 @@ jobs: name: apk-build path: apk-build-artifacts - - name: Download AAR Build Artifacts + - name: Download LIB Build Artifacts uses: actions/download-artifact@v3 with: - name: sign-pgp - path: aar-build-artifacts + name: lib-build + path: lib-build-artifacts - name: List Download LIB Version Artifacts run: ls -l lib-version-artifacts @@ -239,8 +224,8 @@ jobs: - name: List Download APK Build Artifacts run: ls -l apk-build-artifacts - - name: List Download AAR Build Artifacts - run: ls -l aar-build-artifacts + - name: List Download LIB Build Artifacts + run: ls -l lib-build-artifacts - name: Read Release Tag File run: echo "RELEASE_TAG=$(cat lib-version-artifacts/release_tag.txt)" >> $GITHUB_ENV @@ -281,30 +266,20 @@ jobs: asset_name: tourtip-sample-v${{ env.RELEASE_TAG }}-unsigned.apk asset_content_type: application/vnd.android.package-archive - - name: Upload AAR Release Asset + - name: Upload LIB Release Assets uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: aar-build-artifacts/tourtip-release.aar - asset_name: tourtip-v${{ env.RELEASE_TAG }}.aar - asset_content_type: application/java-archive + asset_path: lib-build-artifacts/ + asset_name: tourtip-v${{ env.RELEASE_TAG }} + asset_content_type: application/zip - - name: Upload PGP Signature Release Asset for AAR - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: aar-build-artifacts/tourtip-release.aar.asc - asset_name: tourtip-v${{ env.RELEASE_TAG }}.aar.asc - asset_content_type: application/pgp-signature - - - name: Publish Library to Maven Central - run: ./gradlew publishReleasePublicationToSonatypeRepository - env: - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - PGP_PRIVATE_KEY: ${{ secrets.PGP_PRIVATE_KEY }} - PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} + - name: Delete Release Artifacts + run: | + rm -rf lib-version-artifacts + rm -rf apk-build-artifacts + rm -rf lib-build-artifacts + rm -f FINAL_RELEASE_NOTES.md + rm -f TEMP_RELEASE_NOTES.md diff --git a/.gitignore b/.gitignore index 3161a61..30a506d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ render.experimental.xml *.jks *.keystore *.asc +*.gpg *.properties secrets/ diff --git a/app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/BubbleSetup.kt b/app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/TooltipSetup.kt similarity index 100% rename from app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/BubbleSetup.kt rename to app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/TooltipSetup.kt diff --git a/app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/extension/PathExtension.kt b/app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/extension/PathExtension.kt index d6391e8..b2947b3 100644 --- a/app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/extension/PathExtension.kt +++ b/app/src/main/java/com/fappslab/tourtip/sample/presentation/compose/component/extension/PathExtension.kt @@ -3,6 +3,18 @@ package com.fappslab.tourtip.sample.presentation.compose.component.extension import androidx.compose.ui.geometry.Rect import androidx.compose.ui.graphics.Path +/** + * This file contains examples of how to create custom highlight types for the Tourtip library. + * + * The `drawZigzagRect` and `drawWavyRect` functions are used to create custom shapes for the highlight. + * These functions are used in the `TooltipSetup.kt` file to create custom highlight types for the tooltips. + * + * `drawZigzagRect` creates a zigzag rectangle shape, and `drawWavyRect` creates a wavy rectangle shape. + * These shapes are then used as the highlight for the tooltips in the `TooltipSetup.kt` file. + * + * You can use these functions as a starting point to create your own custom highlight types. + */ + fun Path.drawZigzagRect(bounds: Rect, zigzagSize: Float = 10f) { val zigzagPath = Path() val stepsX = (bounds.width / zigzagSize).toInt() @@ -64,7 +76,7 @@ fun Path.drawWavyRect(bounds: Rect, waveLength: Float = 20f, waveHeight: Float = wavyPath.lineTo(startX, startY) } if (endX <= bounds.right) { - wavyPath.quadraticTo(midX, midY, endX, startY) + quadraticTo(wavyPath, startX, startY, midX, midY, endX, startY) } } @@ -78,7 +90,7 @@ fun Path.drawWavyRect(bounds: Rect, waveLength: Float = 20f, waveHeight: Float = wavyPath.lineTo(startX, startY) if (endY <= bounds.bottom) { - wavyPath.quadraticTo(midX, midY, startX, endY) + quadraticTo(wavyPath, startX, startY, midX, midY, startX, endY) } } @@ -92,7 +104,7 @@ fun Path.drawWavyRect(bounds: Rect, waveLength: Float = 20f, waveHeight: Float = wavyPath.lineTo(startX, startY) if (endX >= bounds.left) { - wavyPath.quadraticTo(midX, midY, endX, startY) + quadraticTo(wavyPath, startX, startY, midX, midY, endX, startY) } } @@ -106,10 +118,29 @@ fun Path.drawWavyRect(bounds: Rect, waveLength: Float = 20f, waveHeight: Float = wavyPath.lineTo(startX, startY) if (endY >= bounds.top) { - wavyPath.quadraticTo(midX, midY, startX, endY) + quadraticTo(wavyPath, startX, startY, midX, midY, startX, endY) } } wavyPath.close() this.addPath(wavyPath) } + +private fun quadraticTo( + path: Path, + startX: Float, + startY: Float, + midX: Float, + midY: Float, + endX: Float, + endY: Float +) { + path.cubicTo( + (startX + 2 * midX) / 3, + (startY + 2 * midY) / 3, + (2 * midX + endX) / 3, + (2 * midY + endY) / 3, + endX, + endY + ) +} diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index f4b8465..1d1d997 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -7,12 +7,11 @@ object Config { const val MIN_SDK: Int = 21 const val TARGET_SDK: Int = 34 // Do not bump manually, it's managed by CI - const val versionCode: Int = 1 + const val versionCode: Int = 0 // Do not bump manually, it's managed by CI const val versionName: String = "1.06" // Library configuration - val ARTEFACT_ID: String = PACKAGE_NAME.substringAfterLast(delimiter = ".") - const val VERSION: String = "$versionName.$versionCode-SNAPSHOT" - const val GROUP_ID: String = PACKAGE_NAME + private const val SNAPSHOT: String = "" //"-SNAPSHOT" + const val VERSION: String = "$versionName.$versionCode$SNAPSHOT" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3867a76..7aaffa3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -10,7 +10,7 @@ activityCompose = "1.9.0" composeBom = "2024.06.00" appcompat = "1.7.0" material = "1.12.0" -material3 = "1.3.0-beta03" +material3 = "1.2.1" mavenPublish = "0.28.0" [libraries] diff --git a/tourtip/build.gradle.kts b/tourtip/build.gradle.kts index 7e6d781..2325394 100644 --- a/tourtip/build.gradle.kts +++ b/tourtip/build.gradle.kts @@ -1,7 +1,10 @@ +import com.vanniktech.maven.publish.SonatypeHost +import org.gradle.configurationcache.extensions.capitalized + plugins { alias(libs.plugins.androidLibrary) alias(libs.plugins.jetbrainsKotlinAndroid) - id("maven-publish") + alias(libs.plugins.vanniktechMavenPublish) id("signing") } apply(from = "$rootDir/plugins/android-build.gradle") @@ -18,74 +21,53 @@ android { } } -publishing { - publications { - create("release") { - afterEvaluate { - from(components["release"]) - } - artifactId = Config.ARTEFACT_ID - groupId = Config.GROUP_ID - version = Config.VERSION +mavenPublishing { + coordinates( + artifactId = findPropertyByName("POM_ARTEFACT_ID"), + groupId = findPropertyByName("POM_GROUP_ID"), + version = Config.VERSION + ) - pom { - name.set(findPropertyByName("POM_PROJECT_NAME")) - description.set(findPropertyByName("POM_PROJECT_DESCRIPTION")) - inceptionYear.set(findPropertyByName("POM_PROJECT_INCEPTION_YEAR")) - url.set(findPropertyByName("POM_PROJECT_URL")) - licenses { - license { - name.set(findPropertyByName("POM_LICENSE_NAME")) - url.set(findPropertyByName("POM_LICENSE_URL")) - distribution.set(findPropertyByName("POM_LICENSE_URL")) - } - } - developers { - developer { - id.set(findPropertyByName("POM_DEVELOPER_ID")) - name.set(findPropertyByName("POM_DEVELOPER_NAME")) - email.set(findPropertyByName("POM_DEVELOPER_EMAIL")) - } - } - issueManagement { - system.set("GitHub") - url.set(findPropertyByName("POM_PROJECT_URL") + "issues") - } - scm { - url.set(findPropertyByName("POM_PROJECT_URL") + "tree/master") - connection.set(findPropertyByName("POM_SCM_CONNECTION")) - developerConnection.set(findPropertyByName("POM_SCM_DEVELOPER_CONNECTION")) - } + pom { + name.set(findPropertyByName("POM_ARTEFACT_ID").capitalized()) + description.set(findPropertyByName("POM_PROJECT_DESCRIPTION")) + inceptionYear.set(findPropertyByName("POM_PROJECT_INCEPTION_YEAR")) + url.set(findPropertyByName("POM_PROJECT_URL")) + licenses { + license { + name.set(findPropertyByName("POM_LICENSE_NAME")) + url.set(findPropertyByName("POM_LICENSE_URL")) + distribution.set(findPropertyByName("POM_LICENSE_URL")) } } - } - repositories { - maven { - name = "sonatype" - - val url = if (Config.VERSION.endsWith("SNAPSHOT")) { - findPropertyByName("OSSRH_SNAPSHOT_URL") - } else findPropertyByName("OSSRH_RELEASE_URL") - setUrl(url) - - credentials { - username = System.getenv("OSSRH_USERNAME") - password = System.getenv("OSSRH_PASSWORD") + developers { + developer { + id.set(findPropertyByName("POM_DEVELOPER_ID")) + name.set(findPropertyByName("POM_DEVELOPER_NAME")) + email.set(findPropertyByName("POM_DEVELOPER_EMAIL")) } } - maven { - name = "local" - url = uri(layout.buildDirectory.dir("test-repo")) + issueManagement { + system.set("GitHub") + url.set(findPropertyByName("POM_PROJECT_URL") + "issues") + } + scm { + url.set(findPropertyByName("POM_PROJECT_URL") + "tree/master") + connection.set(findPropertyByName("POM_SCM_CONNECTION")) + developerConnection.set(findPropertyByName("POM_SCM_DEVELOPER_CONNECTION")) } } + + publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = false) + signAllPublications() } signing { useInMemoryPgpKeys( + System.getenv("PGP_KEY_ID"), System.getenv("PGP_PRIVATE_KEY"), System.getenv("PGP_PASSPHRASE") ) - sign(publishing.publications["release"]) } val resolvedImplementation: Configuration by configurations.creating { diff --git a/tourtip/gradle.properties b/tourtip/gradle.properties index 8faa4ce..52cd03a 100644 --- a/tourtip/gradle.properties +++ b/tourtip/gradle.properties @@ -1,5 +1,6 @@ # pom configuration -POM_PROJECT_NAME=Tourtip +POM_ARTEFACT_ID=tourtip +POM_GROUP_ID=com.fappslab.tourtip POM_PROJECT_DESCRIPTION=A guided tour library for Android applications, built using Jetpack Compose. POM_PROJECT_INCEPTION_YEAR=2024 POM_PROJECT_URL=https://github.com/F4bioo/Tourtip/ @@ -14,8 +15,3 @@ POM_SCM_DEVELOPER_CONNECTION=scm:git:ssh://git@github.com/F4bioo/Tourtip.git # ossrh configuration OSSRH_SNAPSHOT_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/ OSSRH_RELEASE_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ -OSSRH_LOCAL_USERNAME=*** -OSSRH_LOCAL_PASSWORD=*** -# signing configuration -PGP_LOCAL_PRIVATE_KEY=*** -PGP_LOCAL_PASSPHRASE=*** From f02f9a7f18ed8dffb979db4f2196de2067961825 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 17 Jun 2024 03:08:37 +0000 Subject: [PATCH 2/2] Changed: Bump app version v1.06 build 1 --- buildSrc/src/main/java/Config.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/java/Config.kt b/buildSrc/src/main/java/Config.kt index 1d1d997..f5368fc 100644 --- a/buildSrc/src/main/java/Config.kt +++ b/buildSrc/src/main/java/Config.kt @@ -7,7 +7,7 @@ object Config { const val MIN_SDK: Int = 21 const val TARGET_SDK: Int = 34 // Do not bump manually, it's managed by CI - const val versionCode: Int = 0 + const val versionCode: Int = 1 // Do not bump manually, it's managed by CI const val versionName: String = "1.06"