Skip to content

Commit

Permalink
ci: 整理Github Actions,支持发布二进制到Github Packages
Browse files Browse the repository at this point in the history
同时修复二进制sample的构建,并加到PR检查中。

#462
  • Loading branch information
shifujun committed Feb 22, 2021
1 parent 2b49470 commit e43832d
Show file tree
Hide file tree
Showing 20 changed files with 266 additions and 45 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: PR Check

on:
pull_request:
branches: [ master ]

jobs:
build-and-test-on-macos:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: buildSdk
run: ./gradlew buildSdk
- name: lintSdk
run: ./gradlew lintSdk
- name: build sample/source
run: ./gradlew build
- name: unit test
run: ./gradlew jvmTestSdk -S
- name: run androidTestSdk on API 28 emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
target: default
arch: x86_64
profile: pixel_xl
script: ./gradlew androidTestSdk
build-on-windows:
runs-on: windows-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: buildSdk
run: ./gradlew buildSdk
- name: lintSdk
run: ./gradlew lintSdk
- name: build sample/source
run: ./gradlew build
build-samples:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: build sample/maven/host-project
working-directory: projects/sample/maven/host-project
run: ./gradlew assemble
- name: build sample/maven/manager-project
working-directory: projects/sample/maven/manager-project
run: ./gradlew assemble
- name: build sample/maven/plugin-project
working-directory: projects/sample/maven/plugin-project
run: ./gradlew assemble
- name: build sample/sunflower/host-project
working-directory: projects/sample/sunflower/host-project
run: ./gradlew assemble
- name: build sample/sunflower/manager-project
working-directory: projects/sample/sunflower/manager-project
run: ./gradlew assemble
- name: build sample/sunflower/plugin-project
working-directory: projects/sample/sunflower/plugin-project
run: ./gradlew assemble
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish release

on:
release:
types:
- created

jobs:
build-and-test:
runs-on: macos-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: buildSdk
run: ./gradlew buildSdk
- name: lintSdk
run: ./gradlew lintSdk
- name: build sample/source
run: ./gradlew build
- name: unit test
run: ./gradlew jvmTestSdk -S
- name: run androidTestSdk on API 28 emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 28
target: default
arch: x86_64
profile: pixel_xl
script: ./gradlew androidTestSdk
publish:
needs: build-and-test
runs-on: macos-latest
env:
PUBLISH_RELEASE: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: checkout
uses: actions/checkout@v2
- name: publish
run: ./gradlew publish
20 changes: 15 additions & 5 deletions .github/workflows/android.yml → .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: Android CI
name: Publish snapshot

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
build-and-test:
runs-on: macos-latest
steps:
- name: checkout
Expand All @@ -28,4 +26,16 @@ jobs:
arch: x86_64
profile: pixel_xl
script: ./gradlew androidTestSdk

publish:
needs: build-and-test
runs-on: macos-latest
env:
PUBLISH_RELEASE: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Inject slug/short variables
uses: rlespinasse/github-slug-action@v3.x
- name: checkout
uses: actions/checkout@v2
- name: publish
run: ./gradlew publish
20 changes: 0 additions & 20 deletions .github/workflows/windows.yml

This file was deleted.

12 changes: 9 additions & 3 deletions buildScripts/gradle/common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ allprojects {
ext.MIN_SDK_VERSION = 14
ext.TARGET_SDK_VERSION = 28
ext.VERSION_CODE = 1
ext.VERSION_NAME = "2.0.12"

if ("${System.env.CI}".equalsIgnoreCase("true")) {
ext.VERSION_NAME = System.getenv("GITHUB_REF_SLUG")
} else {
ext.VERSION_NAME = "local"
}

if ("${System.env.PUBLISH_RELEASE}".equalsIgnoreCase("true")) {
ext.VERSION_SUFFIX = ""
} else if ("${System.env.ORANGE}".equalsIgnoreCase("true")) {
ext.VERSION_SUFFIX = "-${System.env.ORANGE_COMMIT_SHORT}-SNAPSHOT"
} else if ("${System.env.CI}".equalsIgnoreCase("true")) {
ext.VERSION_SUFFIX = "-${System.env.GITHUB_SHA_SHORT}-SNAPSHOT"
} else {
ext.VERSION_SUFFIX = "-${gitShortRev()}-SNAPSHOT"
}
Expand Down
43 changes: 38 additions & 5 deletions buildScripts/gradle/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ def gitShortRev() {
}

def setScm(scm) {
scm.appendNode('connection', 'https://github.com/Tencent/Shadow.git')
scm.appendNode('connection', "https://github.com/${System.getenv("GITHUB_ACTOR")}/Shadow.git")

def commit
if ("${System.env.ORANGE}".equalsIgnoreCase("true")) {
commit = "${System.env.ORANGE_COMMIT}"
if ("${System.env.CI}".equalsIgnoreCase("true")) {
commit = System.getenv("GITHUB_SHA")
} else {
commit = gitShortRev()
}
scm.appendNode('url', "https://github.com/Tencent/Shadow/commit/$commit")
scm.appendNode('url', "https://github.com/${System.getenv("GITHUB_ACTOR")}/Shadow/commit/$commit")
}

def setGeneratePomFileAndDepends(publicationName) {
Expand Down Expand Up @@ -387,7 +387,40 @@ publishing {
}
}
repositories {
mavenLocal()
def useLocalCredential = false
Properties properties = new Properties()
def propertiesFile = project.rootProject.file('local.properties')
if (propertiesFile.exists()) {
properties.load(propertiesFile.newDataInputStream())

if ("${properties.getProperty('gpr.local')}".equalsIgnoreCase('true')) {
def user = properties.getProperty('gpr.user')
def key = properties.getProperty('gpr.key')
maven {
name = "GitHubPackages"
credentials {
username = user
password = key
}
url "https://maven.pkg.github.com/${user}/shadow"
}

useLocalCredential = true
}
}

if (!useLocalCredential && "${System.env.CI}".equalsIgnoreCase("true")) {
maven {
name = "GitHubPackages"
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
url "https://maven.pkg.github.com/" + "${System.env.GITHUB_REPOSITORY}".toLowerCase()
}
} else {
mavenLocal()
}
}
}

Expand Down
12 changes: 11 additions & 1 deletion projects/sample/maven/host-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.shadow_version = '2.0.12-c3a2c91f-SNAPSHOT'
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
repositories {
google()
jcenter()
Expand All @@ -17,6 +17,16 @@ allprojects {
repositories {
google()
jcenter()
maven {
name = "GitHubPackages"
url "https://maven.pkg.github.com/shifujun/shadow"
//一个只读账号兼容Github Packages暂时不支持匿名下载
//https://gh.neting.ccmunity/t/download-from-github-package-registry-without-authentication/14407
credentials {
username = 'readonlypat'
password = '\u0062\u0036\u0064\u0037\u0035\u0032\u0062\u0061\u0035\u0038\u0063\u0064\u0032\u0061\u0038\u0037\u0064\u0033\u0034\u0033\u0039\u0038\u0035\u0036\u0032\u0034\u0065\u0039\u0031\u0036\u0066\u0065\u0065\u0062\u0031\u0065\u0033\u0037\u0061\u0039'
}
}
mavenLocal()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
12 changes: 11 additions & 1 deletion projects/sample/maven/manager-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.shadow_version = '2.0.12-c3a2c91f-SNAPSHOT'
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
repositories {
google()
jcenter()
Expand All @@ -17,6 +17,16 @@ allprojects {
repositories {
google()
jcenter()
maven {
name = "GitHubPackages"
url "https://maven.pkg.github.com/shifujun/shadow"
//一个只读账号兼容Github Packages暂时不支持匿名下载
//https://gh.neting.ccmunity/t/download-from-github-package-registry-without-authentication/14407
credentials {
username = 'readonlypat'
password = '\u0062\u0036\u0064\u0037\u0035\u0032\u0062\u0061\u0035\u0038\u0063\u0064\u0032\u0061\u0038\u0037\u0064\u0033\u0034\u0033\u0039\u0038\u0035\u0036\u0032\u0034\u0065\u0039\u0031\u0036\u0066\u0065\u0065\u0062\u0031\u0065\u0033\u0037\u0061\u0039'
}
}
mavenLocal()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
12 changes: 11 additions & 1 deletion projects/sample/maven/plugin-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.shadow_version = '2.0.12-c3a2c91f-SNAPSHOT'
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
repositories {
google()
jcenter()
Expand All @@ -17,6 +17,16 @@ allprojects {
repositories {
google()
jcenter()
maven {
name = "GitHubPackages"
url "https://maven.pkg.github.com/shifujun/shadow"
//一个只读账号兼容Github Packages暂时不支持匿名下载
//https://gh.neting.ccmunity/t/download-from-github-package-registry-without-authentication/14407
credentials {
username = 'readonlypat'
password = '\u0062\u0036\u0064\u0037\u0035\u0032\u0062\u0061\u0035\u0038\u0063\u0064\u0032\u0061\u0038\u0037\u0064\u0033\u0034\u0033\u0039\u0038\u0035\u0036\u0032\u0034\u0065\u0039\u0031\u0036\u0066\u0065\u0065\u0062\u0031\u0065\u0033\u0037\u0061\u0039'
}
}
mavenLocal()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ buildscript {
repositories {
google()
jcenter()
maven {
name = "GitHubPackages"
url "https://maven.pkg.github.com/shifujun/shadow"
//一个只读账号兼容Github Packages暂时不支持匿名下载
//https://gh.neting.ccmunity/t/download-from-github-package-registry-without-authentication/14407
credentials {
username = 'readonlypat'
password = '\u0062\u0036\u0064\u0037\u0035\u0032\u0062\u0061\u0035\u0038\u0063\u0064\u0032\u0061\u0038\u0037\u0064\u0033\u0034\u0033\u0039\u0038\u0035\u0036\u0032\u0034\u0065\u0039\u0031\u0036\u0066\u0065\u0065\u0062\u0031\u0065\u0033\u0037\u0061\u0039'
}
}
mavenLocal()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@
-dontwarn com.tencent.shadow.dynamic.loader.**
-dontwarn com.tencent.shadow.core.common.**
-dontwarn com.tencent.shadow.core.loader.**
-dontwarn module-info
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@

-keep class com.tencent.shadow.core.runtime.**{*;}
#需要keep在宿主AndroidManifest.xml注册的壳子activity
-keep class com.tencent.shadow.sample.runtime.**{*;}
-keep class com.tencent.shadow.sample.runtime.**{*;}

#GeneratedPluginContainerActivity包含新版本API的接口,可能在业务编译时使用的低版本compileSDK中找不到
-dontwarn com.tencent.shadow.core.runtime.container.GeneratedPluginContainerActivity
12 changes: 11 additions & 1 deletion projects/sample/sunflower/host-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.shadow_version = '2.0.12-4de02e2e-SNAPSHOT'
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
repositories {
google()
jcenter()
Expand All @@ -17,6 +17,16 @@ allprojects {
repositories {
google()
jcenter()
maven {
name = "GitHubPackages"
url "https://maven.pkg.github.com/shifujun/shadow"
//一个只读账号兼容Github Packages暂时不支持匿名下载
//https://gh.neting.ccmunity/t/download-from-github-package-registry-without-authentication/14407
credentials {
username = 'readonlypat'
password = '\u0062\u0036\u0064\u0037\u0035\u0032\u0062\u0061\u0035\u0038\u0063\u0064\u0032\u0061\u0038\u0037\u0064\u0033\u0034\u0033\u0039\u0038\u0035\u0036\u0032\u0034\u0065\u0039\u0031\u0036\u0066\u0065\u0065\u0062\u0031\u0065\u0033\u0037\u0061\u0039'
}
}
mavenLocal()
}
}
Expand Down
Loading

0 comments on commit e43832d

Please sign in to comment.