Skip to content

Commit e43832d

Browse files
committed
ci: 整理Github Actions,支持发布二进制到Github Packages
同时修复二进制sample的构建,并加到PR检查中。 #462
1 parent 2b49470 commit e43832d

File tree

20 files changed

+266
-45
lines changed

20 files changed

+266
-45
lines changed

.github/workflows/pr-check.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: PR Check
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
7+
jobs:
8+
build-and-test-on-macos:
9+
runs-on: macos-latest
10+
steps:
11+
- name: checkout
12+
uses: actions/checkout@v2
13+
- name: buildSdk
14+
run: ./gradlew buildSdk
15+
- name: lintSdk
16+
run: ./gradlew lintSdk
17+
- name: build sample/source
18+
run: ./gradlew build
19+
- name: unit test
20+
run: ./gradlew jvmTestSdk -S
21+
- name: run androidTestSdk on API 28 emulator
22+
uses: reactivecircus/android-emulator-runner@v2
23+
with:
24+
api-level: 28
25+
target: default
26+
arch: x86_64
27+
profile: pixel_xl
28+
script: ./gradlew androidTestSdk
29+
build-on-windows:
30+
runs-on: windows-latest
31+
steps:
32+
- name: checkout
33+
uses: actions/checkout@v2
34+
- name: buildSdk
35+
run: ./gradlew buildSdk
36+
- name: lintSdk
37+
run: ./gradlew lintSdk
38+
- name: build sample/source
39+
run: ./gradlew build
40+
build-samples:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: checkout
44+
uses: actions/checkout@v2
45+
- name: build sample/maven/host-project
46+
working-directory: projects/sample/maven/host-project
47+
run: ./gradlew assemble
48+
- name: build sample/maven/manager-project
49+
working-directory: projects/sample/maven/manager-project
50+
run: ./gradlew assemble
51+
- name: build sample/maven/plugin-project
52+
working-directory: projects/sample/maven/plugin-project
53+
run: ./gradlew assemble
54+
- name: build sample/sunflower/host-project
55+
working-directory: projects/sample/sunflower/host-project
56+
run: ./gradlew assemble
57+
- name: build sample/sunflower/manager-project
58+
working-directory: projects/sample/sunflower/manager-project
59+
run: ./gradlew assemble
60+
- name: build sample/sunflower/plugin-project
61+
working-directory: projects/sample/sunflower/plugin-project
62+
run: ./gradlew assemble

.github/workflows/release.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish release
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
build-and-test:
10+
runs-on: macos-latest
11+
steps:
12+
- name: checkout
13+
uses: actions/checkout@v2
14+
- name: buildSdk
15+
run: ./gradlew buildSdk
16+
- name: lintSdk
17+
run: ./gradlew lintSdk
18+
- name: build sample/source
19+
run: ./gradlew build
20+
- name: unit test
21+
run: ./gradlew jvmTestSdk -S
22+
- name: run androidTestSdk on API 28 emulator
23+
uses: reactivecircus/android-emulator-runner@v2
24+
with:
25+
api-level: 28
26+
target: default
27+
arch: x86_64
28+
profile: pixel_xl
29+
script: ./gradlew androidTestSdk
30+
publish:
31+
needs: build-and-test
32+
runs-on: macos-latest
33+
env:
34+
PUBLISH_RELEASE: true
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
steps:
37+
- name: Inject slug/short variables
38+
uses: rlespinasse/[email protected]
39+
- name: checkout
40+
uses: actions/checkout@v2
41+
- name: publish
42+
run: ./gradlew publish

.github/workflows/android.yml .github/workflows/snapshot.yml

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
name: Android CI
1+
name: Publish snapshot
22

33
on:
44
push:
55
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
86

97
jobs:
10-
test:
8+
build-and-test:
119
runs-on: macos-latest
1210
steps:
1311
- name: checkout
@@ -28,4 +26,16 @@ jobs:
2826
arch: x86_64
2927
profile: pixel_xl
3028
script: ./gradlew androidTestSdk
31-
29+
publish:
30+
needs: build-and-test
31+
runs-on: macos-latest
32+
env:
33+
PUBLISH_RELEASE: false
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
steps:
36+
- name: Inject slug/short variables
37+
uses: rlespinasse/[email protected]
38+
- name: checkout
39+
uses: actions/checkout@v2
40+
- name: publish
41+
run: ./gradlew publish

.github/workflows/windows.yml

-20
This file was deleted.

buildScripts/gradle/common.gradle

+9-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ allprojects {
1212
ext.MIN_SDK_VERSION = 14
1313
ext.TARGET_SDK_VERSION = 28
1414
ext.VERSION_CODE = 1
15-
ext.VERSION_NAME = "2.0.12"
15+
16+
if ("${System.env.CI}".equalsIgnoreCase("true")) {
17+
ext.VERSION_NAME = System.getenv("GITHUB_REF_SLUG")
18+
} else {
19+
ext.VERSION_NAME = "local"
20+
}
21+
1622
if ("${System.env.PUBLISH_RELEASE}".equalsIgnoreCase("true")) {
1723
ext.VERSION_SUFFIX = ""
18-
} else if ("${System.env.ORANGE}".equalsIgnoreCase("true")) {
19-
ext.VERSION_SUFFIX = "-${System.env.ORANGE_COMMIT_SHORT}-SNAPSHOT"
24+
} else if ("${System.env.CI}".equalsIgnoreCase("true")) {
25+
ext.VERSION_SUFFIX = "-${System.env.GITHUB_SHA_SHORT}-SNAPSHOT"
2026
} else {
2127
ext.VERSION_SUFFIX = "-${gitShortRev()}-SNAPSHOT"
2228
}

buildScripts/gradle/maven.gradle

+38-5
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ def gitShortRev() {
7171
}
7272

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

7676
def commit
77-
if ("${System.env.ORANGE}".equalsIgnoreCase("true")) {
78-
commit = "${System.env.ORANGE_COMMIT}"
77+
if ("${System.env.CI}".equalsIgnoreCase("true")) {
78+
commit = System.getenv("GITHUB_SHA")
7979
} else {
8080
commit = gitShortRev()
8181
}
82-
scm.appendNode('url', "https://github.com/Tencent/Shadow/commit/$commit")
82+
scm.appendNode('url', "https://github.com/${System.getenv("GITHUB_ACTOR")}/Shadow/commit/$commit")
8383
}
8484

8585
def setGeneratePomFileAndDepends(publicationName) {
@@ -387,7 +387,40 @@ publishing {
387387
}
388388
}
389389
repositories {
390-
mavenLocal()
390+
def useLocalCredential = false
391+
Properties properties = new Properties()
392+
def propertiesFile = project.rootProject.file('local.properties')
393+
if (propertiesFile.exists()) {
394+
properties.load(propertiesFile.newDataInputStream())
395+
396+
if ("${properties.getProperty('gpr.local')}".equalsIgnoreCase('true')) {
397+
def user = properties.getProperty('gpr.user')
398+
def key = properties.getProperty('gpr.key')
399+
maven {
400+
name = "GitHubPackages"
401+
credentials {
402+
username = user
403+
password = key
404+
}
405+
url "https://maven.pkg.github.com/${user}/shadow"
406+
}
407+
408+
useLocalCredential = true
409+
}
410+
}
411+
412+
if (!useLocalCredential && "${System.env.CI}".equalsIgnoreCase("true")) {
413+
maven {
414+
name = "GitHubPackages"
415+
credentials {
416+
username = System.getenv("GITHUB_ACTOR")
417+
password = System.getenv("GITHUB_TOKEN")
418+
}
419+
url "https://maven.pkg.github.com/" + "${System.env.GITHUB_REPOSITORY}".toLowerCase()
420+
}
421+
} else {
422+
mavenLocal()
423+
}
391424
}
392425
}
393426

projects/sample/maven/host-project/build.gradle

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.shadow_version = '2.0.12-c3a2c91f-SNAPSHOT'
4+
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
55
repositories {
66
google()
77
jcenter()
@@ -17,6 +17,16 @@ allprojects {
1717
repositories {
1818
google()
1919
jcenter()
20+
maven {
21+
name = "GitHubPackages"
22+
url "https://maven.pkg.github.com/shifujun/shadow"
23+
//一个只读账号兼容Github Packages暂时不支持匿名下载
24+
//https://github.community/t/download-from-github-package-registry-without-authentication/14407
25+
credentials {
26+
username = 'readonlypat'
27+
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'
28+
}
29+
}
2030
mavenLocal()
2131
}
2232
}

projects/sample/maven/host-project/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

projects/sample/maven/manager-project/build.gradle

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.shadow_version = '2.0.12-c3a2c91f-SNAPSHOT'
4+
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
55
repositories {
66
google()
77
jcenter()
@@ -17,6 +17,16 @@ allprojects {
1717
repositories {
1818
google()
1919
jcenter()
20+
maven {
21+
name = "GitHubPackages"
22+
url "https://maven.pkg.github.com/shifujun/shadow"
23+
//一个只读账号兼容Github Packages暂时不支持匿名下载
24+
//https://github.community/t/download-from-github-package-registry-without-authentication/14407
25+
credentials {
26+
username = 'readonlypat'
27+
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'
28+
}
29+
}
2030
mavenLocal()
2131
}
2232
}

projects/sample/maven/manager-project/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

projects/sample/maven/plugin-project/build.gradle

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.shadow_version = '2.0.12-c3a2c91f-SNAPSHOT'
4+
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
55
repositories {
66
google()
77
jcenter()
@@ -17,6 +17,16 @@ allprojects {
1717
repositories {
1818
google()
1919
jcenter()
20+
maven {
21+
name = "GitHubPackages"
22+
url "https://maven.pkg.github.com/shifujun/shadow"
23+
//一个只读账号兼容Github Packages暂时不支持匿名下载
24+
//https://github.community/t/download-from-github-package-registry-without-authentication/14407
25+
credentials {
26+
username = 'readonlypat'
27+
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'
28+
}
29+
}
2030
mavenLocal()
2131
}
2232
}

projects/sample/maven/plugin-project/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

projects/sample/maven/plugin-project/plugin-shadow-apk/build.gradle

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ buildscript {
1919
repositories {
2020
google()
2121
jcenter()
22+
maven {
23+
name = "GitHubPackages"
24+
url "https://maven.pkg.github.com/shifujun/shadow"
25+
//一个只读账号兼容Github Packages暂时不支持匿名下载
26+
//https://github.community/t/download-from-github-package-registry-without-authentication/14407
27+
credentials {
28+
username = 'readonlypat'
29+
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'
30+
}
31+
}
2232
mavenLocal()
2333
}
2434

projects/sample/maven/plugin-project/sample-loader/proguard-rules.pro

+1
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@
5252
-dontwarn com.tencent.shadow.dynamic.loader.**
5353
-dontwarn com.tencent.shadow.core.common.**
5454
-dontwarn com.tencent.shadow.core.loader.**
55+
-dontwarn module-info

projects/sample/maven/plugin-project/sample-runtime/proguard-rules.pro

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@
2525

2626
-keep class com.tencent.shadow.core.runtime.**{*;}
2727
#需要keep在宿主AndroidManifest.xml注册的壳子activity
28-
-keep class com.tencent.shadow.sample.runtime.**{*;}
28+
-keep class com.tencent.shadow.sample.runtime.**{*;}
29+
30+
#GeneratedPluginContainerActivity包含新版本API的接口,可能在业务编译时使用的低版本compileSDK中找不到
31+
-dontwarn com.tencent.shadow.core.runtime.container.GeneratedPluginContainerActivity

projects/sample/sunflower/host-project/build.gradle

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.shadow_version = '2.0.12-4de02e2e-SNAPSHOT'
4+
ext.shadow_version = 'master-b4632d8f-SNAPSHOT'
55
repositories {
66
google()
77
jcenter()
@@ -17,6 +17,16 @@ allprojects {
1717
repositories {
1818
google()
1919
jcenter()
20+
maven {
21+
name = "GitHubPackages"
22+
url "https://maven.pkg.github.com/shifujun/shadow"
23+
//一个只读账号兼容Github Packages暂时不支持匿名下载
24+
//https://github.community/t/download-from-github-package-registry-without-authentication/14407
25+
credentials {
26+
username = 'readonlypat'
27+
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'
28+
}
29+
}
2030
mavenLocal()
2131
}
2232
}

0 commit comments

Comments
 (0)