-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
添加 growingio sdk bom-platform (#163)
* add growingio sdk bom-platform * support CI manual publish with select module
- Loading branch information
Showing
15 changed files
with
483 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.