diff --git a/build.gradle b/build.gradle index c3263d63a5..dde7b2df71 100644 --- a/build.gradle +++ b/build.gradle @@ -317,8 +317,12 @@ subprojects { authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) } } - repository(url: stagingUrl, configureAuth) - snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) + if (rootProject.hasProperty('repositoryDir')) { + repository(url: new File(rootProject.repositoryDir).toURI()) + } else { + repository(url: stagingUrl, configureAuth) + snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) + } } uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") } diff --git a/buildscripts/sign-local-repo.sh b/buildscripts/sign-local-repo.sh new file mode 100755 index 0000000000..563b37023e --- /dev/null +++ b/buildscripts/sign-local-repo.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright 2017, gRPC Authors All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -e + +if [ $# -ne 1 ]; then + cat < Staging Profiles + * Select profile based on name (e.g., 'io.grpc') + * Copy hex identifier from URL after "#stagingProfiles;" + DIR Directory to upload to Sonatype as a new staging repository + +~/.config/sonatype-upload: Configuration file for Sonatype username and password + USERNAME=yourusername + PASSWORD=yourpass + +Sonatype provides a "user token" that is a randomly generated username/password. +It does allow access to your account, however. You can create one via: + * Log in to https://oss.sonatype.org + * Click your username at the top right and click to Profile + * Change the drop-down from "Summary" to "User Token" + * Click "Access User Token" +EOF + exit 1 +fi + +PROFILE_ID="$1" +DIR="$2" +if [ -z "$DIR" ]; then + echo "Must specify non-empty directory name" + exit 1 +fi + +[ -f "$CONF" ] && . "$CONF" + +if [ -z "$USERNAME" -o -z "$PASSWORD" ]; then + # TODO(ejona86): if people would use it, could prompt for values to avoid + # having passwords in plain-text. + echo "You must create '$CONF' with keys USERNAME and PASSWORD" >&2 + exit 1 +fi + +CONF="$HOME/.config/sonatype-upload" +STAGING_URL="https://oss.sonatype.org/service/local/staging" + +# We go through the effort of using deloyByRepositoryId/ because it is +# _substantially_ faster to upload files than deploy/maven2/. When using +# deploy/maven2/ a repository is implicitly created, but the response doesn't +# provide its name. + +USERPASS="$USERNAME:$PASSWORD" + +# https://oss.sonatype.org/nexus-staging-plugin/default/docs/index.html +# +# Example returned data: +# +# +# iogrpc-1082 +# Release upload +# +# +echo "Creating staging repo" +REPOID="$( + XML=" + + + Release upload + + " + curl -s -X POST -d "$XML" -u "$USERPASS" -H "Content-Type: application/xml" \ + "$STAGING_URL/profiles/$PROFILE_ID/start" | + grep stagedRepositoryId | + sed 's/.*\(.*\)<\/stagedRepositoryId>.*/\1/' + )" +echo "Repository id: $REPOID" + +for X in $(cd "$DIR" && find -type f | cut -b 3-); do + echo "Uploading $X" + curl -T "$DIR/$X" -u "$USERPASS" -H "Content-Type: application/octet-stream" \ + "$STAGING_URL/deployByRepositoryId/$REPOID/$X" +done + +echo "Closing staging repo" +XML=" + + + $REPOID + Auto-close via upload script + +" +curl -X POST -d "$XML" -u "$USERPASS" -H "Content-Type: application/xml" \ + "$STAGING_URL/profiles/$PROFILE_ID/finish"