1
1
#! /bin/sh
2
- GRADLE_FOLDER=~ /.gradle/
3
- GRADLE_PROPERTIES=$GRADLE_FOLDER /gradle.properties
4
- KEY_PATH=` pwd` /tools/bitrise-secret.key
2
+ maybe_install_gpg () {
3
+ # Install gnupgV2 if missing
4
+ if ! gpg --version > /dev/null; then
5
+ echo " No gnupg* found. Installing gnupg2..."
6
+ apt install gnupg2
7
+ fi
8
+ }
9
+
10
+ maybe_install_conv () {
11
+ # Install conventional-changelog-cli if missing
12
+ npm list -g conventional-changelog-cli > /dev/null || npm install -g conventional-changelog-cli
13
+ }
14
+
15
+ setup_gradle_signing () {
16
+ # Setup gradle properties for gpg signing artifacts
17
+ GRADLE_FOLDER=~ /.gradle/
18
+ GRADLE_PROPERTIES=$GRADLE_FOLDER /gradle.properties
19
+ KEY_PATH=` pwd` /tools/bitrise-secret.key
20
+
21
+ if [ ! -d $GRADLE_FOLDER ]
22
+ then
23
+ mkdir $GRADLE_FOLDER
24
+ fi
25
+
26
+ if [ -e $GRADLE_PROPERTIES ]
27
+ then
28
+ if grep -q " signing." $GRADLE_PROPERTIES
29
+ then
30
+ echo " The gradle properties already have a signing profile, leaving untouched."
31
+ return 0
32
+ fi
33
+ else
34
+ touch $GRADLE_PROPERTIES
35
+ fi
5
36
6
- add_signing () {
7
37
echo " Adding bitrise key to gradle properties..."
8
38
cat > $GRADLE_PROPERTIES << EOF
9
39
signing.keyId=9719DC41
@@ -12,33 +42,62 @@ signing.secretKeyRingFile=$KEY_PATH
12
42
EOF
13
43
echo " New gradle properties:"
14
44
cat $GRADLE_PROPERTIES
45
+ gpg --import $KEY_PATH
15
46
}
16
47
17
- # Install gnupg2 if missing
18
- if ! gpg --version > /dev/null; then
19
- echo " No gnupg* found. Installing gnupg2..."
20
- apt install gnupg2
21
- fi
22
-
23
- # Install conventional-changelog-cli if missing
24
- npm list -g conventional-changelog-cli || npm install -g conventional-changelog-cli
48
+ # Maven drop repository handling TODO: Remove if alternative https://issues.sonatype.org/browse/OSSRH-39124
49
+ drop_open_repo () {
50
+ echo " Creating minimal pom to use nexus maven plugin"
51
+ cat > pom.xml << EOF
52
+ <project>
53
+ <groupId>com.algolia</groupId>
54
+ <artifactId>algoliasearch-android</artifactId>
55
+ <version>0.0.0</version>
56
+ <modelVersion>4.0.0</modelVersion>
57
+ <build>
58
+ <plugins>
59
+ <plugin>
60
+ <groupId>org.sonatype.plugins</groupId>
61
+ <artifactId>nexus-staging-maven-plugin</artifactId>
62
+ <version>1.6.6</version>
63
+ <extensions>true</extensions>
64
+ <configuration>
65
+ <serverId>nexus</serverId>
66
+ <nexusUrl>https://oss.sonatype.org/</nexusUrl>
67
+ </configuration>
68
+ </plugin>
69
+ </plugins>
70
+ </build>
71
+ </project>
72
+ EOF
25
73
26
- # Setup gradle properties for gpg signing artifacts
27
- if [ ! -d $GRADLE_FOLDER ]
28
- then
29
- mkdir $GRADLE_FOLDER
30
- fi
74
+ echo " Creating local maven settings"
75
+ cat > mvn-settings.xml << EOF
76
+ <settings>
77
+ <servers>
78
+ <server>
79
+ <id>nexus</id>
80
+ <username>$NEXUS_USERNAME </username>
81
+ <password>$NEXUS_PASSWORD </password>
82
+ </server>
83
+ </servers>
84
+ </settings>
85
+ EOF
31
86
32
- if [ -e $GRADLE_PROPERTIES ]
33
- then
34
- if grep -q " signing. " $GRADLE_PROPERTIES
35
- then
36
- echo " The gradle properties already have a signing profile, leaving untouched. "
37
- exit 0
87
+ MVN_REPO_ID= ` mvn --settings mvn-settings.xml nexus-staging:rc-list | grep comalgolia | cut -d ' ' -f 2 `
88
+ if test -z $MVN_REPO_ID ; then
89
+ echo " No repository was currently open. "
90
+ else
91
+ echo " Existing repository to close: $MVN_REPO_ID "
92
+ mvn nexus-staging:drop -DstagingRepositoryId= $MVN_REPO_ID
38
93
fi
39
- else
40
- touch $GRADLE_PROPERTIES
41
- fi
42
94
43
- add_signing
44
- gpg --import $KEY_PATH
95
+ echo " Removing maven-related files..."
96
+ rm pom.xml
97
+ rm mvn-settings.xml
98
+ }
99
+
100
+ maybe_install_gpg
101
+ maybe_install_conv
102
+ drop_open_repo
103
+ setup_gradle_signing
0 commit comments