Skip to content

Commit

Permalink
添加 growingio sdk bom-platform (#163)
Browse files Browse the repository at this point in the history
* add growingio sdk bom-platform

* support CI manual publish with select module
  • Loading branch information
cpacm authored Jul 29, 2022
1 parent ab7c82e commit 103e19e
Show file tree
Hide file tree
Showing 15 changed files with 483 additions and 255 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/publish_module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Publish SDK Module manual

on:
workflow_dispatch:
inputs:
module:
description: 'select publish module'
required: true
default: 'autotracker_bom'
type: choice
options:
- autotracker_bom
- hybrid
- okhttp3
- volley
- urlconnection
- database
- debugger
- circler
- json
- protobuf
- encoder
- oaid
version:
description: 'input publish version'
required: false
default: 'DEFAULT'
type: string


jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

# Gradle 缓存配置
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

# 给 gradlew 文件授权
- name: Grant Permission to Execute
run: |
chmod +x gradlew
chmod +x gradle/publishAllToMavenLocal.sh
# 解码秘钥
- name: Decode
run: |
echo "${{secrets.SIGNING_SECRET_KEY_RING_FILE}}" > ~/.gradle/secring.gpg.b64
base64 -d ~/.gradle/secring.gpg.b64 > ~/.gradle/secring.gpg
- name: Publish to Sonatype
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: ./gradlew publish -PCI_SELECT_MODULE="${{ inputs.module }}" -PCI_SELECT_VERSION="${{ inputs.version }}" -PNEXUS_USERNAME="${NEXUS_USERNAME}" -PNEXUS_PASSWORD="${NEXUS_PASSWORD}" -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.gpg)

- name: Close And Release Package
env:
NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
run: ./gradlew tryCloseAndReleaseRepository -PNEXUS_USERNAME="${NEXUS_USERNAME}" -PNEXUS_PASSWORD="${NEXUS_PASSWORD}"
216 changes: 0 additions & 216 deletions CHANGELOG.md

This file was deleted.

86 changes: 64 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,40 @@ buildscript {
]

releaseConfiguration = [

// bom version
bomVersion : "0.0.0.1",
bomVersionCode : 00001,

releaseVersion : "3.4.0",
releaseVersionCode: 30400,

pluginVersion : "3.4.0",

trackerVersion : "3.4.0",
autotrackerVersion: "3.4.0",

trackerCore : "3.4.0",
autotrackerCore : "3.4.0",

hybrid : "3.4.0",
okhttp3 : "3.4.0",
urlconnection : "3.4.0",
volley : "3.4.0",
database : "3.4.0",
debugger : "3.4.0",
circler : "3.4.0",
json : "3.4.0",
protobuf : "3.4.0",
encoder : "3.4.0",

analyticsFa : "3.4.0",
analyticsGa : "3.4.0",
analyticsSa : "3.4.0",
oaid : "3.4.0",
crash : "3.4.0",

annotationVersion : "3.4.0",
]

versions = [
Expand Down Expand Up @@ -43,29 +75,39 @@ buildscript {
],

'growingio': [
'gmonitor' : 'com.growingio.android:gmonitor:1.5.0',
'tracker_core' : "com.growingio.android:tracker-core:$releaseConfiguration.releaseVersion",
'tracker' : "com.growingio.android:tracker:$releaseConfiguration.releaseVersion",
'tracker_cdp' : "com.growingio.android:tracker-cdp:$releaseConfiguration.releaseVersion",
'autotracker_core': "com.growingio.android:autotracker-core:$releaseConfiguration.releaseVersion",
'autotracker' : "com.growingio.android:autotracker:$releaseConfiguration.releaseVersion",
'autotracker_cdp' : "com.growingio.android:autotracker-cdp:$releaseConfiguration.releaseVersion",
'annotation' : "com.growingio.android:annotation:$releaseConfiguration.releaseVersion",
'compiler' : "com.growingio.android:compiler:$releaseConfiguration.releaseVersion",

'hybrid' : "com.growingio.android:hybrid:$releaseConfiguration.releaseVersion",
'okhttp3' : "com.growingio.android:okhttp3:$releaseConfiguration.releaseVersion",
'database' : "com.growingio.android:database:$releaseConfiguration.releaseVersion",
'volley' : "com.growingio.android:volley:$releaseConfiguration.releaseVersion",
'urlconnection' : "com.growingio.android:urlconnection:$releaseConfiguration.releaseVersion",
'debugger' : "com.growingio.android:debugger:$releaseConfiguration.releaseVersion",
'circler' : "com.growingio.android:circler:$releaseConfiguration.releaseVersion",
'json' : "com.growingio.android:json:$releaseConfiguration.releaseVersion",
'protobuf' : "com.growingio.android:protobuf:$releaseConfiguration.releaseVersion",
'encoder' : "com.growingio.android:encoder:$releaseConfiguration.releaseVersion",
'crash' : "com.growingio.android:crash:$releaseConfiguration.releaseVersion",
'oaid' : "com.growingio.android:oaid:$releaseConfiguration.releaseVersion",
// growingio autotrack bom platform
'autotracker_bom' : "com.growingio.android:autotracker-bom:$releaseConfiguration.bomVersion",

// sdk
'tracker' : "com.growingio.android:tracker:$releaseConfiguration.trackerVersion",
'tracker_cdp' : "com.growingio.android:tracker-cdp:$releaseConfiguration.trackerVersion",
'autotracker' : "com.growingio.android:autotracker:$releaseConfiguration.autotrackerVersion",
'autotracker_cdp' : "com.growingio.android:autotracker-cdp:$releaseConfiguration.autotrackerVersion",

'tracker_core' : "com.growingio.android:tracker-core:$releaseConfiguration.trackerCore",
'autotracker_core': "com.growingio.android:autotracker-core:$releaseConfiguration.autotrackerCore",

'annotation' : "com.growingio.android:annotation:$releaseConfiguration.annotationVersion",
'compiler' : "com.growingio.android:compiler:$releaseConfiguration.annotationVersion",

'hybrid' : "com.growingio.android:hybrid:$releaseConfiguration.hybrid",
'okhttp3' : "com.growingio.android:okhttp3:$releaseConfiguration.okhttp3",
'volley' : "com.growingio.android:volley:$releaseConfiguration.volley",
'urlconnection' : "com.growingio.android:urlconnection:$releaseConfiguration.urlconnection",
'database' : "com.growingio.android:database:$releaseConfiguration.database",
'debugger' : "com.growingio.android:debugger:$releaseConfiguration.debugger",
'circler' : "com.growingio.android:circler:$releaseConfiguration.circler",
'json' : "com.growingio.android:json:$releaseConfiguration.json",
'protobuf' : "com.growingio.android:protobuf:$releaseConfiguration.protobuf",
'encoder' : "com.growingio.android:encoder:$releaseConfiguration.encoder",
'oaid' : "com.growingio.android:oaid:$releaseConfiguration.oaid",
'analytics_fa' : "com.growingio.android:analytics-fa:$releaseConfiguration.analyticsFa",
'analytics_ga' : "com.growingio.android:analytics-ga:$releaseConfiguration.analyticsGa",
'analytics_sa' : "com.growingio.android:analytics-ga:$releaseConfiguration.analyticsSa",

'crash' : "com.growingio.android:crash:$releaseConfiguration.crash",
'snappy' : "com.growingio.android:snappy:1.1.0",
'gmonitor' : 'com.growingio.android:gmonitor:1.5.0',
],

'google' : [
Expand Down
8 changes: 0 additions & 8 deletions changelog-option.js

This file was deleted.

3 changes: 1 addition & 2 deletions demos/demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ buildscript {
maven {url "https://s01.oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
classpath "com.growingio.android:autotracker-gradle-plugin:${releaseConfiguration.releaseVersion}"
//classpath "com.growingio.android:autotracker-gradle-plugin:3.4.0"
classpath "com.growingio.android:autotracker-gradle-plugin:${releaseConfiguration.pluginVersion}"
}
}

Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ BINTARY_DESC=GrowingIO Tracker Android SDK
GROUP=com.growingio.android
POM_DESCRIPTION=GrowingIO Android SDK Library.
POM_DEVELOPER_EMAIL=sdk-integration@growingio.com
POM_COMPANY=Groiwngio, Inc.
POM_OFFICIAL_WEBSITE=https://www.growingio.com
POM_URL=https://github.com/growingio/growingio-sdk-android-autotracker
POM_SCM_URL=https://github.com/growingio/growingio-sdk-android-autotracker
POM_SCM_CONNECTION=scm:git@github.com:growingio/growingio-sdk-android-autotracker.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:growingio/growingio-sdk-android-autotracker.git
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_LICENCE_DIST=repo
POM_SCM_ISSUES=https://github.com/growingio/growingio-sdk-android-autotracker/issues
POM_DEVELOPER_ID=GrowingIo Sdk
POM_DEVELOPER_NAME=GrowingIo Sdk
96 changes: 96 additions & 0 deletions gradle/existDenpendices.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* Copyright 2022 Cpacm
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import okhttp3.OkHttpClient
import okhttp3.Request

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.squareup.okhttp3:okhttp:4.9.3"
}
}

def getModuleVersion(moduleId) {
def version = 'SNAPSHOT'
libraries.growingio.each { key, value ->
def library = value.split(":")
def libraryId = library[1]
if (moduleId.equals(libraryId)) {
version = library[2]
return true
}
}
return version
}

//tasks.withType(PublishToMavenLocal) {
tasks.withType(PublishToMavenRepository) {
onlyIf {
def moduleId = POM_ARTIFACT_ID
def version = getModuleVersion(moduleId)
if (project.hasProperty('CI_SELECT_MODULE') && project.hasProperty("CI_SELECT_VERSION")) {
def cmdModuleId = CI_SELECT_MODULE
if (cmdModuleId != moduleId) return {
println("can't match module:" + cmdModuleId)
false
}
if (CI_SELECT_VERSION != "DEFAULT") version = CI_SELECT_VERSION
moduleId = cmdModuleId
} else if (project.hasProperty('CI_SELECT_MODULE') || project.hasProperty("CI_SELECT_VERSION")) {
println("illegal ci params!!")
return false
}

// SNAPSHOT always should publish
if (version.endsWith('SNAPSHOT')) {
return true
}
// publish when library not in maven repository
if (checkMavenAarExist(moduleId, version)) {
println String.format("%s:%s already exist in release maven repository, you should't publish it.", moduleId, version)
return false
}
return true

}
}

static def getReleaseMavenRepositoryUrl(moduleId, version) {
return String.format("https://repo.maven.apache.org/maven2/com/growingio/android/%s/%s/", moduleId, version)
}

static def checkMavenAarExist(moduleId, version) {
try {
def client = new OkHttpClient()
def request = new Request.Builder().url(getReleaseMavenRepositoryUrl(moduleId, version)).head().build()
def response = client.newCall(request).execute()
//println response.headers()
//println response.code()
if (response.code() == 404) {
response.close()
return false
} else {
response.close()
return true
}
} catch (IOException e) {
println "Something error:" + e.toString()
return true
}
}
1 change: 1 addition & 0 deletions gradle/publishAllToMavenLocal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export IS_EXCLUDE_DEMOS=true
&& ./gradlew :gio-sdk:tracker-cdp:publishMavenAgentPublicationToMavenLocal \
&& ./gradlew :gio-sdk:autotracker:publishMavenAgentPublicationToMavenLocal \
&& ./gradlew :gio-sdk:autotracker-cdp:publishMavenAgentPublicationToMavenLocal \
&& ./gradlew :growingio-sdk-bom:publishBomPublicationToMavenLocal \
&& ./gradlew clean
export IS_EXCLUDE_DEMOS=false
37 changes: 33 additions & 4 deletions gradle/publishMaven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,29 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

version = releaseConfiguration.releaseVersion
version = getPublishVersion()
group = GROUP

def getPublishVersion() {
def moduleId = POM_ARTIFACT_ID
def version = '3.0.0-SNAPSHOT'
if (project.hasProperty('CI_SELECT_MODULE') && project.hasProperty("CI_SELECT_VERSION")) {
def cmdModuleId = CI_SELECT_MODULE
if (cmdModuleId == moduleId && CI_SELECT_VERSION != "DEFAULT") {
return CI_SELECT_VERSION
}
}
libraries.growingio.each { key, value ->
def library = value.split(":")
def libraryId = library[1]
if (moduleId.equals(libraryId)) {
version = library[2]
return true
}
}
return version
}

@SuppressWarnings("GrMethodMayBeStatic")
def isReleaseBuild() {
return !version.contains("SNAPSHOT")
Expand Down Expand Up @@ -72,6 +92,11 @@ def configurePom(pom) {
}
}

pom.issueManagement {
system = 'GitHub Issues'
url = POM_SCM_ISSUES
}

pom.developers {
developer {
id = POM_DEVELOPER_ID
Expand Down Expand Up @@ -188,9 +213,11 @@ afterEvaluate { project ->
def groupId = it.group
def artifactId = it.name
if (it instanceof ProjectDependency) {
def properties = it.getDependencyProject().getProperties()
groupId = properties.get("GROUP")
artifactId = properties.get("POM_ARTIFACT_ID")
// skip eg:implementation project(:module)
// def properties = it.getDependencyProject().getProperties()
// groupId = properties.get("GROUP")
// artifactId = properties.get("POM_ARTIFACT_ID")
return
}
println "dependencies:" + groupId + ":" + artifactId + ":" + it.version
def dependencyNode = dependenciesNode.appendNode('dependency')
Expand Down Expand Up @@ -228,3 +255,5 @@ signing {
sign publication
}
}

apply from: "${rootProject.projectDir}/gradle/existDenpendices.gradle"
3 changes: 2 additions & 1 deletion gradle/stagingMaven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ nexusStaging {
password = getRepositoryPassword()
}



task tryCloseAndReleaseRepository() {
if (releaseConfiguration.releaseVersion.contains("SNAPSHOT")) {
//println "not release, closeAndReleaseRepository pass"
} else {
//dependsOn closeAndReleaseRepository
dependsOn closeRepository
}

}
Loading

0 comments on commit 103e19e

Please sign in to comment.