Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Android release structure to maven central #161

Merged
merged 9 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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 }}"
17 changes: 17 additions & 0 deletions .github/workflows/semantic-pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 0 additions & 12 deletions .github/workflows/track-deploy.yml

This file was deleted.

55 changes: 34 additions & 21 deletions android-client-sdk/build.gradle
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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\""
}

Expand All @@ -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
Expand All @@ -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 = '[email protected]'
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"
Expand All @@ -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")

Expand Down Expand Up @@ -140,4 +153,4 @@ dependencies {

androidTestImplementation("androidx.test.ext:junit:$androidx_junit_version")
androidTestImplementation("androidx.test.espresso:espresso-core:$espresso_core_version")
}
}
10 changes: 1 addition & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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/.
Expand All @@ -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"'
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand Down
Binary file modified java-example/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 0 additions & 3 deletions java-example/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 8 additions & 4 deletions java-example/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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/.
Expand All @@ -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"'
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions java-example/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%

Expand Down
Binary file modified kotlin-example/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 0 additions & 4 deletions kotlin-example/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

JamieSinn marked this conversation as resolved.
Show resolved Hide resolved
## ENABLE THIS TO MAX OUT R8 MINIFICATION
android.enableR8.fullMode = true

Loading