File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed
Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -65,10 +65,26 @@ afterEvaluate {
6565 }
6666
6767 signing {
68- useInMemoryPgpKeys(
69- new String (Base64 . decoder. decode(System . getenv(" SIGNING_KEY" )), " UTF-8" ),
70- System . getenv(" SIGNING_PASSWORD" )
71- )
72- sign publishing. publications. release
68+ signing {
69+ def base64Key = System . getenv(" SIGNING_KEY" ) ?: project. findProperty(" signing.key" )
70+ def password = System . getenv(" SIGNING_PASSWORD" ) ?: project. findProperty(" signing.password" )
71+
72+ if (! base64Key) throw new GradleException (" SIGNING_KEY is missing or null." )
73+ if (! password) throw new GradleException (" SIGNING_PASSWORD is missing or null." )
74+
75+ def decodedKey = new String (Base64 . decoder. decode(base64Key as String ), " UTF-8" )
76+
77+ if (! decodedKey. startsWith(" -----BEGIN PGP PRIVATE KEY BLOCK-----" )) {
78+ throw new GradleException (" SIGNING_KEY does not decode into a valid key block." )
79+ }
80+
81+ try {
82+ useInMemoryPgpKeys(decodedKey, password)
83+ } catch (MissingMethodException e) {
84+ throw new GradleException (" `useInMemoryPgpKeys()` not found. Is the signing plugin applied?" )
85+ }
86+
87+ sign publishing. publications. release
88+ }
7389 }
7490}
You can’t perform that action at this time.
0 commit comments