소스 검색

android: improve SDK release script

- don't hardcode defaults in gradle files
- allow for uploading also to HTTP URLs
- support HTTP authentication when publishing
master
Saúl Ibarra Corretgé 6 년 전
부모
커밋
b78989f5f2
3개의 변경된 파일67개의 추가작업 그리고 23개의 파일을 삭제
  1. 12
    2
      android/build.gradle
  2. 46
    20
      android/scripts/release-sdk.sh
  3. 9
    1
      android/sdk/build.gradle

+ 12
- 2
android/build.gradle 파일 보기

55
         publishing {
55
         publishing {
56
             publications {}
56
             publications {}
57
             repositories {
57
             repositories {
58
-                maven { url "file:${rootProject.ext.mavenRepo}" }
58
+                maven {
59
+                    url rootProject.ext.mavenRepo
60
+                    if (!rootProject.ext.mavenRepo.startsWith("file")) {
61
+                        credentials {
62
+                            username rootProject.ext.mavenUser
63
+                            password rootProject.ext.mavenPassword
64
+                        }
65
+                    }
66
+                }
59
             }
67
             }
60
         }
68
         }
61
     }
69
     }
152
     moduleGroupId = 'com.facebook.react'
160
     moduleGroupId = 'com.facebook.react'
153
 
161
 
154
     // Maven repo where artifacts will be published
162
     // Maven repo where artifacts will be published
155
-    mavenRepo = System.env.MVN_REPO ?: "${rootProject.projectDir}/../../jitsi-maven-repository/releases"
163
+    mavenRepo = System.env.MVN_REPO ?: ""
164
+    mavenUser = System.env.MVN_USER ?: ""
165
+    mavenPassword = System.env.MVN_PASSWORD ?: ""
156
 
166
 
157
     // Glide
167
     // Glide
158
     excludeAppGlideModule = true
168
     excludeAppGlideModule = true

+ 46
- 20
android/scripts/release-sdk.sh 파일 보기

5
 
5
 
6
 THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
6
 THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
7
 DEFAULT_MVN_REPO="${THIS_DIR}/../../../jitsi-maven-repository/releases"
7
 DEFAULT_MVN_REPO="${THIS_DIR}/../../../jitsi-maven-repository/releases"
8
-export MVN_REPO=$(realpath ${1:-$DEFAULT_MVN_REPO})
8
+THE_MVN_REPO=${MVN_REPO:-${1:-$DEFAULT_MVN_REPO}}
9
+MVN_HTTP=0
9
 SDK_VERSION=$(grep sdkVersion ${THIS_DIR}/../gradle.properties | cut -d"=" -f2)
10
 SDK_VERSION=$(grep sdkVersion ${THIS_DIR}/../gradle.properties | cut -d"=" -f2)
10
 RN_VERSION=$(jq -r '.dependencies."react-native"' ${THIS_DIR}/../../package.json)
11
 RN_VERSION=$(jq -r '.dependencies."react-native"' ${THIS_DIR}/../../package.json)
11
 
12
 
13
+if [[ $THE_MVN_REPO == http* ]]; then
14
+    MVN_HTTP=1
15
+else
16
+    MVN_REPO_PATH=$(realpath $THE_MVN_REPO)
17
+    THE_MVN_REPO="file:${MVN_REPO_PATH}"
18
+fi
19
+
20
+export MVN_REPO=$THE_MVN_REPO
12
 
21
 
13
 echo "Releasing Jitsi Meet SDK ${SDK_VERSION}"
22
 echo "Releasing Jitsi Meet SDK ${SDK_VERSION}"
14
 echo "Using ${MVN_REPO} as the Maven repo"
23
 echo "Using ${MVN_REPO} as the Maven repo"
15
 
24
 
16
-# Check if an SDK with that same version has already been released
17
-if [[ -d ${MVN_REPO}/org/jitsi/react/jitsi-meet-sdk/${SDK_VERSION} ]]; then
18
-    echo "There is already a release with that version in the Maven repo!"
19
-    exit 1
20
-fi
21
-
22
-# First push React Native, if necessary
23
-if [[ ! -d ${MVN_REPO}/com/facebook/react/react-native/${RN_VERSION} ]]; then
25
+if [[ $MVN_HTTP == 1 ]]; then
26
+    # Push React Native
24
     echo "Pushing React Native ${RN_VERSION} to the Maven repo"
27
     echo "Pushing React Native ${RN_VERSION} to the Maven repo"
25
     pushd ${THIS_DIR}/../../node_modules/react-native/android/com/facebook/react/react-native/${RN_VERSION}
28
     pushd ${THIS_DIR}/../../node_modules/react-native/android/com/facebook/react/react-native/${RN_VERSION}
26
     mvn \
29
     mvn \
27
         deploy:deploy-file \
30
         deploy:deploy-file \
28
-        -Durl=file://${MVN_REPO} \
31
+        -Durl=${MVN_REPO} \
32
+        -DrepositoryId=${MVN_REPO_ID} \
29
         -Dfile=react-native-${RN_VERSION}.aar \
33
         -Dfile=react-native-${RN_VERSION}.aar \
30
         -Dpackaging=aar \
34
         -Dpackaging=aar \
31
         -DgeneratePom=false \
35
         -DgeneratePom=false \
32
-        -DpomFile=react-native-${RN_VERSION}.pom
36
+        -DpomFile=react-native-${RN_VERSION}.pom || true
33
     popd
37
     popd
38
+else
39
+    # Check if an SDK with that same version has already been released
40
+    if [[ -d ${MVN_REPO}/org/jitsi/react/jitsi-meet-sdk/${SDK_VERSION} ]]; then
41
+        echo "There is already a release with that version in the Maven repo!"
42
+        exit 1
43
+    fi
44
+
45
+    # First push React Native, if necessary
46
+    if [[ ! -d ${MVN_REPO}/com/facebook/react/react-native/${RN_VERSION} ]]; then
47
+        echo "Pushing React Native ${RN_VERSION} to the Maven repo"
48
+        pushd ${THIS_DIR}/../../node_modules/react-native/android/com/facebook/react/react-native/${RN_VERSION}
49
+        mvn \
50
+            deploy:deploy-file \
51
+            -Durl=${MVN_REPO} \
52
+            -Dfile=react-native-${RN_VERSION}.aar \
53
+            -Dpackaging=aar \
54
+            -DgeneratePom=false \
55
+            -DpomFile=react-native-${RN_VERSION}.pom
56
+        popd
57
+    fi
34
 fi
58
 fi
35
 
59
 
36
 # Now build and publish the Jitsi Meet SDK and its dependencies
60
 # Now build and publish the Jitsi Meet SDK and its dependencies
39
 ./gradlew clean assembleRelease publish
63
 ./gradlew clean assembleRelease publish
40
 popd
64
 popd
41
 
65
 
42
-# The artifacts are now on the Maven repo, commit them
43
-pushd ${MVN_REPO}
44
-if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]]; then
45
-    git add -A .
46
-    git commit -m "Jitsi Meet SDK + dependencies"
47
-fi
48
-popd
66
+if [[ $MVN_HTTP == 0 ]]; then
67
+    # The artifacts are now on the Maven repo, commit them
68
+    pushd ${MVN_REPO_PATH}
69
+    if [[ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" == "true" ]]; then
70
+        git add -A .
71
+        git commit -m "Jitsi Meet SDK + dependencies"
72
+    fi
73
+    popd
49
 
74
 
50
-# Tag the release
51
-git tag -a android-sdk-${SDK_VERSION}
75
+    # Tag the release
76
+    git tag -a android-sdk-${SDK_VERSION}
77
+fi
52
 
78
 
53
 # Done!
79
 # Done!
54
 echo "Finished! Don't forget to push the tag and the Maven repo artifacts."
80
 echo "Finished! Don't forget to push the tag and the Maven repo artifacts."

+ 9
- 1
android/sdk/build.gradle 파일 보기

201
 
201
 
202
     }
202
     }
203
     repositories {
203
     repositories {
204
-        maven { url "file:${rootProject.ext.mavenRepo}" }
204
+        maven {
205
+            url rootProject.ext.mavenRepo
206
+            if (!rootProject.ext.mavenRepo.startsWith("file")) {
207
+                credentials {
208
+                    username rootProject.ext.mavenUser
209
+                    password rootProject.ext.mavenPassword
210
+                }
211
+            }
212
+        }
205
     }
213
     }
206
 }
214
 }

Loading…
취소
저장