Skip to content

Commit 4944955

Browse files
Publish Java libraries to GCS instead of Maven Central
Co-authored-by: Andrew <[email protected]>
1 parent 02d5145 commit 4944955

File tree

6 files changed

+59
-26
lines changed

6 files changed

+59
-26
lines changed

.github/workflows/jni_artifacts.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Upload Java libraries to Sonatype
1+
name: Upload Java libraries
22
run-name: ${{ github.workflow }} (${{ github.ref_name }})
33

44
on:
@@ -125,6 +125,11 @@ jobs:
125125
publish:
126126
name: Build for production and publish
127127

128+
permissions:
129+
contents: read
130+
# Needed for google-github-actions/auth.
131+
id-token: write
132+
128133
runs-on: ubuntu-latest-8-cores
129134

130135
needs: [build, verify-rust]
@@ -175,12 +180,19 @@ jobs:
175180
name: libsignal-server
176181
path: java/server/build/libs/libsignal-server-*.jar
177182

183+
- id: gcp-auth
184+
uses: google-github-actions/auth@55bd3a7c6e2ae7cf1877fd1ccb9d54c0503c457c # v2.1.2
185+
if: ${{ !inputs.dry_run }}
186+
with:
187+
workload_identity_provider: 'projects/741367068918/locations/global/workloadIdentityPools/github/providers/github-actions'
188+
service_account: '[email protected]'
189+
token_format: 'access_token'
190+
178191
- run: make publish_java
179192
if: ${{ !inputs.dry_run }}
180193
working-directory: java
181194
env:
182-
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USER }}
183-
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
195+
CLOUDSDK_AUTH_ACCESS_TOKEN: ${{ steps.gcp-auth.outputs.access_token }}
184196
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEYID }}
185197
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
186198
# ASCII-armored PGP secret key

README.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,25 @@ $ make
145145
When exposing new APIs to Java, you will need to run `rust/bridge/jni/bin/gen_java_decl.py` in
146146
addition to rebuilding. This requires installing the `cbindgen` Rust tool, as detailed above.
147147

148-
### Maven Central
148+
### Use as a library
149149

150-
Signal publishes Java packages on [Maven Central](https://central.sonatype.org) for its own use,
151-
under the names org.signal:libsignal-server, org.signal:libsignal-client, and
152-
org.signal:libsignal-android. libsignal-client and libsignal-server contain native libraries for
153-
Debian-flavored x86_64 Linux as well as Windows (x86_64) and macOS (x86_64 and arm64).
154-
libsignal-android contains native libraries for armeabi-v7a, arm64-v8a, x86, and x86_64 Android.
150+
Signal publishes Java packages for its own use, under the names org.signal:libsignal-server,
151+
org.signal:libsignal-client, and org.signal:libsignal-android. libsignal-client and libsignal-server
152+
contain native libraries for Debian-flavored x86_64 Linux as well as Windows (x86_64) and macOS
153+
(x86_64 and arm64). libsignal-android contains native libraries for armeabi-v7a, arm64-v8a, x86, and
154+
x86_64 Android. These are located in a Maven repository at
155+
https://build-artifacts.signal.org/libraries/maven/; for use from Gradle, add the following to your
156+
`repositories` block:
157+
158+
```
159+
maven {
160+
name = "SignalBuildArtifacts"
161+
// The "uri()" part is only necessary for Kotlin Gradle; Groovy Gradle accepts a bare string here.
162+
url = uri("https://build-artifacts.signal.org/libraries/maven/")
163+
}
164+
```
165+
166+
Older builds were published to [Maven Central](https://central.sonatype.org) instead.
155167

156168
When building for Android you need *both* libsignal-android and libsignal-client, but the Windows
157169
and macOS libraries in libsignal-client won't automatically be excluded from your final app. You can

RELEASE.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ git push <remote> HEAD:main <release tag, e.g. v0.x.y>
5656

5757
### Android and Server: Sonatype
5858

59-
In the signalapp/libsignal repository on GitHub, run the "Upload Java libraries to Sonatype" action on the tag you just made. Then go to [Maven Central][] and wait for the build to show up (it can take up to an hour).
60-
61-
[Maven Central]: https://central.sonatype.com/artifact/org.signal/libsignal-client/versions
59+
In the signalapp/libsignal repository on GitHub, run the "Upload Java libraries" action on the tag you just made.
6260

6361
### Node: NPM
6462

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
v0.86.6
22

3+
- Java artifacts are now published to build-artifacts.signal.org rather than Maven Central. See the README for further instructions.
4+
35
- keytrans: Fall back to search-with-version if self-monitor returns unexpected versions.

java/Makefile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ java_build: docker_image
2929
publish_java: DOCKER_EXTRA = $(shell [ -L build ] && P=$$(readlink build) && echo -v $$P/:$$P )
3030
publish_java: docker_image
3131
$(DOCKER) run --rm --user $$(id -u):$$(id -g) \
32-
-v `cd .. && pwd`/:/home/libsignal/src $(DOCKER_EXTRA) \
33-
-e ORG_GRADLE_PROJECT_sonatypeUsername \
34-
-e ORG_GRADLE_PROJECT_sonatypePassword \
3532
-e ORG_GRADLE_PROJECT_signingKeyId \
3633
-e ORG_GRADLE_PROJECT_signingPassword \
3734
-e ORG_GRADLE_PROJECT_signingKey \
35+
-e CLOUDSDK_AUTH_ACCESS_TOKEN \
36+
-v `cd .. && pwd`/:/home/libsignal/src $(DOCKER_EXTRA) \
3837
$(DOCKER_IMAGE) \
39-
sh -c "cd src/java; ./gradlew $(GRADLE_OPTIONS) publish closeAndReleaseStagingRepositories $(CROSS_COMPILE_SERVER)"
38+
sh -c "cd src/java; ./gradlew $(GRADLE_OPTIONS) publish $(CROSS_COMPILE_SERVER)"
4039

4140
# We could run these through Docker, but they would have the same result anyway.
4241

java/build.gradle

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import org.gradle.api.publish.PublishingExtension
12
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
23
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
34

45
plugins {
56
id "base"
67
id "signing"
78
id "com.diffplug.spotless" version "7.2.1"
8-
id "io.github.gradle-nexus.publish-plugin" version "2.0.0"
99

1010
id "org.jetbrains.kotlin.jvm" version "2.1.0" apply false
1111
id "org.jetbrains.dokka" version "2.0.0" apply false
@@ -104,15 +104,25 @@ ext.setUpSigningKey = { signingExt ->
104104
}
105105
}
106106

107-
nexusPublishing {
108-
repositories {
109-
sonatype {
110-
username = project.findProperty('sonatypeUsername') ?: ""
111-
password = project.findProperty('sonatypePassword') ?: ""
112-
// This is the recommended configuration from the README for the plugin we use, gradle-nexus/publish-plugin.
113-
// The URLs are from https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
114-
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
115-
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
107+
subprojects { subproject ->
108+
subproject.plugins.withId('maven-publish') {
109+
subproject.extensions.configure(PublishingExtension) { publishing ->
110+
publishing.repositories {
111+
maven {
112+
name = "SignalBuildArtifacts"
113+
// We can't use Gradle's built-in GCS support with the way we authenticate
114+
// GitHub Actions. Fortunately, GCS's REST APIs are basically just normal HTTP
115+
// GET/PUT with an auth token, which is compatible with what Gradle will do.
116+
url = subproject.uri("https://storage.googleapis.com/build-artifacts.signal.org/libraries/maven")
117+
credentials(HttpHeaderCredentials) {
118+
name = "Authorization"
119+
value = "Bearer ${System.getenv("CLOUDSDK_AUTH_ACCESS_TOKEN") ?: ""}"
120+
}
121+
authentication {
122+
header(HttpHeaderAuthentication)
123+
}
124+
}
125+
}
116126
}
117127
}
118128
}

0 commit comments

Comments
 (0)