diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..9c584f6f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,104 @@ +name: Release + +on: + workflow_dispatch: + inputs: + prerelease: + description: "Prerelease" + required: true + type: boolean + draft: + description: "Draft" + required: true + type: boolean + version-increment-type: + description: 'Which part of the version to increment:' + required: true + type: choice + options: + - major + - minor + - patch + default: 'patch' + +permissions: + contents: write + +jobs: + release: + name: Version Bump and Release + runs-on: ubuntu-latest + steps: + # Check out the repo with credentials that can bypass branch protection, and fetch git history instead of just latest commit + - uses: actions/checkout@v3 + with: + token: ${{ secrets.AUTOMATION_USER_TOKEN }} + fetch-depth: 0 + + - uses: DevCycleHQ/release-action/prepare-release@main + id: prepare-release + with: + github-token: ${{ secrets.AUTOMATION_USER_TOKEN }} + prerelease: ${{ github.event.inputs.prerelease }} + draft: ${{ github.event.inputs.draft }} + version-increment-type: ${{ github.event.inputs.version-increment-type }} + + - name: Update Version in code + run: | + sed -i "s/^version = \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/version = \"${{steps.prepare-release.outputs.next-release-tag}}\"/g" android-client-sdk/build.gradle + sed -i "s/^implementation(\"com.devcycle:android-client-sdk:[0-9]\+\.[0-9]\+\.[0-9]\+\")/implementation(\"com.devcycle:android-client-sdk:${{steps.prepare-release.outputs.next-release-tag}}\")/g" README.md + + - name: Commit version change + run: | + git config --global user.email "github-tracker-bot@taplytics.com" + git config --global user.name "DevCycle Automation" + git add ./android-client-sdk/build.gradle + git add ./README.md + git commit -m "Release ${{steps.prepare-release.outputs.next-release-tag}}" + + - name: Push version change + run: | + git push origin HEAD:main + if: inputs.draft != true + + - name: Set up Java 11 + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 11 + cache: 'gradle' + + - name: Build and Publish To Sonatype Staging + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + run: | + ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache + + - name: Release Sonatype Staging Repository + if: inputs.prerelease != true && inputs.draft != true + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }} + ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + run: ./gradlew closeAndReleaseRepository + + - uses: DevCycleHQ/release-action/create-release@main + id: create-release + with: + github-token: ${{ secrets.AUTOMATION_USER_TOKEN }} + tag: ${{ steps.prepare-release.outputs.next-release-tag }} + target: main + prerelease: ${{ github.event.inputs.prerelease }} + draft: ${{ github.event.inputs.draft }} + changelog: ${{ steps.prepare-release.outputs.changelog }} + + - name: Display link to release + run: | + echo "::notice title=Release ID::${{ steps.create-release.outputs.release-id }}" + echo "::notice title=Release URL::${{ steps.create-release.outputs.release-url }}" \ No newline at end of file diff --git a/.github/workflows/semantic-pr.yml b/.github/workflows/semantic-pr.yml new file mode 100644 index 00000000..4b130c32 --- /dev/null +++ b/.github/workflows/semantic-pr.yml @@ -0,0 +1,17 @@ +name: 'Semantic PR' +on: + pull_request_target: + types: + - opened + - edited + - synchronize +permissions: + pull-requests: read +jobs: + main: + name: Semantic PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/track-deploy.yml b/.github/workflows/track-deploy.yml deleted file mode 100644 index b8375729..00000000 --- a/.github/workflows/track-deploy.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Track Deploy -on: - push: - tags: - - '[0-9]+.[0-9]+.[0-9]+*' - -jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Send POST to Sleuth - run: curl -X POST -d api_key=${{ secrets.SLEUTH_API_KEY }} -d environment=production -d sha=${{ github.sha }} https://app.sleuth.io/api/1/deployments/taplytics/android-client-sdk/register_deploy diff --git a/android-client-sdk/build.gradle b/android-client-sdk/build.gradle index d2437438..44dea04c 100644 --- a/android-client-sdk/build.gradle +++ b/android-client-sdk/build.gradle @@ -1,13 +1,20 @@ plugins { id 'com.android.library' id 'kotlin-android' - id 'maven-publish' + id "com.vanniktech.maven.publish" version "0.25.3" id 'de.mannodermaus.android-junit5' } +import com.vanniktech.maven.publish.SonatypeHost + group = "com.devcycle" version = "2.0.0" +mavenPublishing { + coordinates(group, "android-client-sdk", version) + publishToMavenCentral(SonatypeHost.S01) +} + android { compileSdk 33 @@ -20,7 +27,7 @@ android { consumerProguardFiles("proguard-rules.pro") - //Will create field in buildconfig.java for use in code. + //Will create field in buildconfig.java for use in code. buildConfigField 'String', 'VERSION_NAME', "\"$version\"" } @@ -31,21 +38,22 @@ android { } buildTypes { - release { + "release" { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } - debug { + "debug" { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } // "minified" build type to be used for unit tests - minified { + "minified" { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -62,19 +70,26 @@ android { } ext { - PUBLISH_GROUP_ID = 'com.devcycle' - PUBLISH_VERSION = version - PUBLISH_ARTIFACT_ID = 'android-client-sdk' - PUBLISH_DESCRIPTION = 'DevCycle Android SDK' - PUBLISH_URL = 'https://github.com/DevCycleHQ/android-client-sdk' - PUBLISH_LICENSE_NAME = 'MIT License' - PUBLISH_LICENSE_URL = 'https://www.opensource.org/licenses/mit-license.php' - PUBLISH_DEVELOPER_ID = 'SDK' - PUBLISH_DEVELOPER_NAME = 'DevCycle SDK Group' - PUBLISH_DEVELOPER_EMAIL = 'support@devcycle.com' - PUBLISH_SCM_CONNECTION = 'scm:git:github.com/DevCycleHQ/android-client-sdk.git' - PUBLISH_SCM_DEVELOPER_CONNECTION = 'scm:git:ssh://github.com/DevCycleHQ/android-client-sdk.git' - PUBLISH_SCM_URL = 'https://github.com/DevCycleHQ/android-client-sdk' + GROUP='com.devcycle' + POM_VERSION=version + POM_ARTIFACT_ID='android-client-sdk' + POM_NAME='DevCycle Android Client SDK' + POM_DESCRIPTION='The DevCycle Android Client SDK uses our Client SDK APIs to perform all user segmentation and bucketing for the SDK, providing fast response times using our globally distributed edge workers all around the world.' + POM_INCEPTION_YEAR=2022 + POM_URL='https://github.com/DevCycleHQ/android-client-sdk' + repo='https://github.com/DevCycleHQ/android-client-sdk' + + POM_LICENSE_NAME='MIT License' + POM_LICENSE_URL='https://www.opensource.org/licenses/mit-license.php' + POM_LICENSE_DIST=repo + + POM_SCM_URL='https://github.com/DevCycleHQ/android-client-sdk' + POM_SCM_CONNECTION='scm:git:ssh://github.com/DevCycleHQ/android-client-sdk.git' + POM_SCM_DEV_CONNECTION='scm:git:ssh://github.com/DevCycleHQ/android-client-sdk.git' + + POM_DEVELOPER_ID='SDK' + POM_DEVELOPER_NAME='DevCycle SDK Group' + POM_DEVELOPER_URL='https://devcycle.com' androidx_version = '1.8.0' retrofit_version = "2.9.0" @@ -99,8 +114,6 @@ ext { espresso_core_version = "3.4.0" } -apply from: "${rootProject.projectDir}/scripts/publish-module.gradle" - dependencies { implementation("com.squareup.okhttp3:okhttp:$okhttp_version") @@ -140,4 +153,4 @@ dependencies { androidTestImplementation("androidx.test.ext:junit:$androidx_junit_version") androidTestImplementation("androidx.test.espresso:espresso-core:$espresso_core_version") -} \ No newline at end of file +} diff --git a/build.gradle b/build.gradle index ca124ce6..6bf6a7c1 100644 --- a/build.gradle +++ b/build.gradle @@ -6,19 +6,11 @@ buildscript { maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath 'com.android.tools.build:gradle:8.0.2' + classpath 'com.android.tools.build:gradle:8.1.0' classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21' classpath "de.mannodermaus.gradle.plugins:android-junit5:1.8.2.0" - classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files } } - -apply plugin: 'io.github.gradle-nexus.publish-plugin' -apply from: "${rootDir}/scripts/publish-root.gradle" - task clean(type: Delete) { delete rootProject.buildDir } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832..ccebba77 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 7a9dc9b0..42defcc9 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jul 07 11:27:49 EDT 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +networkTimeout=10000 zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb6..79a61d42 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/gradlew.bat b/gradlew.bat index 53a6b238..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/java-example/gradle/wrapper/gradle-wrapper.jar b/java-example/gradle/wrapper/gradle-wrapper.jar index 249e5832..ccebba77 100644 Binary files a/java-example/gradle/wrapper/gradle-wrapper.jar and b/java-example/gradle/wrapper/gradle-wrapper.jar differ diff --git a/java-example/gradle/wrapper/gradle-wrapper.properties b/java-example/gradle/wrapper/gradle-wrapper.properties index cc4badf3..41dfb879 100644 --- a/java-example/gradle/wrapper/gradle-wrapper.properties +++ b/java-example/gradle/wrapper/gradle-wrapper.properties @@ -3,6 +3,3 @@ distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists - -## ENABLE THIS TO MAX OUT R8 MINIFICATION -android.enableR8.fullMode = true \ No newline at end of file diff --git a/java-example/gradlew b/java-example/gradlew index a69d9cb6..79a61d42 100755 --- a/java-example/gradlew +++ b/java-example/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/java-example/gradlew.bat b/java-example/gradlew.bat index 53a6b238..6689b85b 100644 --- a/java-example/gradlew.bat +++ b/java-example/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/kotlin-example/gradle/wrapper/gradle-wrapper.jar b/kotlin-example/gradle/wrapper/gradle-wrapper.jar index 249e5832..ccebba77 100644 Binary files a/kotlin-example/gradle/wrapper/gradle-wrapper.jar and b/kotlin-example/gradle/wrapper/gradle-wrapper.jar differ diff --git a/kotlin-example/gradle/wrapper/gradle-wrapper.properties b/kotlin-example/gradle/wrapper/gradle-wrapper.properties index 170cd33c..41dfb879 100644 --- a/kotlin-example/gradle/wrapper/gradle-wrapper.properties +++ b/kotlin-example/gradle/wrapper/gradle-wrapper.properties @@ -3,7 +3,3 @@ distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists - -## ENABLE THIS TO MAX OUT R8 MINIFICATION -android.enableR8.fullMode = true - diff --git a/kotlin-example/gradlew b/kotlin-example/gradlew index a69d9cb6..79a61d42 100755 --- a/kotlin-example/gradlew +++ b/kotlin-example/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,10 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac diff --git a/kotlin-example/gradlew.bat b/kotlin-example/gradlew.bat index 53a6b238..6689b85b 100644 --- a/kotlin-example/gradlew.bat +++ b/kotlin-example/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle deleted file mode 100644 index 99679e5d..00000000 --- a/scripts/publish-module.gradle +++ /dev/null @@ -1,63 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - -task androidSourcesJar(type: Jar) { - archiveClassifier.set('sources') - from android.sourceSets.main.java.srcDirs -} - -artifacts { - archives androidSourcesJar -} - -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - groupId PUBLISH_GROUP_ID - artifactId PUBLISH_ARTIFACT_ID - version PUBLISH_VERSION - - from components.release - - artifact androidSourcesJar - - pom { - name = PUBLISH_ARTIFACT_ID - description = PUBLISH_DESCRIPTION - url = PUBLISH_URL - licenses { - license { - name = PUBLISH_LICENSE_NAME - url = PUBLISH_LICENSE_URL - } - } - developers { - developer { - id = PUBLISH_DEVELOPER_ID - name = PUBLISH_DEVELOPER_NAME - email = PUBLISH_DEVELOPER_EMAIL - } - } - - scm { - connection = PUBLISH_SCM_CONNECTION - developerConnection = PUBLISH_SCM_DEVELOPER_CONNECTION - url = PUBLISH_SCM_URL - } - } - } - } - } -} - -ext["signing.keyId"] = rootProject.ext["signing.keyId"] -ext["signing.password"] = rootProject.ext["signing.password"] -ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"] - -signing { - sign publishing.publications -} \ No newline at end of file diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle deleted file mode 100644 index 166c3bac..00000000 --- a/scripts/publish-root.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// Create variables with empty default values -ext["signing.keyId"] = '' -ext["signing.password"] = '' -ext["signing.secretKeyRingFile"] = '' -ext["ossrhUsername"] = '' -ext["ossrhPassword"] = '' -ext["sonatypeStagingProfileId"] = '' - -File secretPropsFile = project.rootProject.file('local.properties') -if (secretPropsFile.exists()) { - // Read local.properties file first if it exists - Properties p = new Properties() - new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } - p.each { name, value -> ext[name] = value } -} else { - // Use system environment variables - ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') - ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') - ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') - ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') - ext["signing.password"] = System.getenv('SIGNING_PASSWORD') - ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') -} - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - stagingProfileId = sonatypeStagingProfileId - username = ossrhUsername - password = ossrhPassword - nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) - snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) - } - } -} \ No newline at end of file