|
| 1 | +#!/bin/bash -e |
| 2 | + |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 4 | +# or more contributor license agreements. See the NOTICE file |
| 5 | +# distributed with this work for additional information |
| 6 | +# regarding copyright ownership. The ASF licenses this file |
| 7 | +# to you under the Apache License, Version 2.0 (the |
| 8 | +# "License"); you may not use this file except in compliance |
| 9 | +# with the License. You may obtain a copy of the License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, |
| 14 | +# software distributed under the License is distributed on an |
| 15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 16 | +# KIND, either express or implied. See the License for the |
| 17 | +# specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | + |
| 20 | +# This is a general bash script to sign and deploy a datasketches-memory-X.jar. |
| 21 | +# This is intended to be used for releasing the Memory component to Maven central. |
| 22 | + |
| 23 | +# Required Input Parameters: |
| 24 | +# \$1 = Git Version Tag for this deployment |
| 25 | +# Example tag for SNAPSHOT : 1.0.0-SNAPSHOT |
| 26 | +# Example tag for Release Candidate: 1.0.0-RC1 |
| 27 | +# Example tag for Release : 1.0.0 |
| 28 | +# \$2 = absolute path of project.basedir |
| 29 | +# For example: $ <this script>.sh 2.1.0 . |
| 30 | + |
| 31 | +#### Extract GitTag, TestJar and ProjectBaseDir from input parameters #### |
| 32 | +GitTag=$1 |
| 33 | +ProjectBaseDir=$2 |
| 34 | + |
| 35 | +#### Setup absolute directory references #### |
| 36 | +OutputDir=${ProjectBaseDir}/target |
| 37 | + |
| 38 | +OutputMrJar=${OutputDir}/datasketches-memory-${GitTag}.jar |
| 39 | +OutputTests=${OutputDir}/datasketches-memory-${GitTag}-tests.jar |
| 40 | +OutputJavaDoc=${OutputDir}/datasketches-memory-${GitTag}-javadoc.jar |
| 41 | +OutputSources=${OutputDir}/datasketches-memory-${GitTag}-sources.jar |
| 42 | +OutputTestSources=${OutputDir}/datasketches-memory-${GitTag}-test-sources.jar |
| 43 | +OutputPom=${OutputDir}/datasketches-memory-${GitTag}-pom |
| 44 | + |
| 45 | +#### Use GNU-GPG to create signature |
| 46 | +sign_file () { |
| 47 | + File=$1 |
| 48 | + gpg --verbose --personal-digest-preferences=SHA512 --detach-sign -a $File |
| 49 | +} |
| 50 | + |
| 51 | +### Deploy to nexus |
| 52 | +if [[ $GitTag == *SNAPSHOT ]] |
| 53 | +then |
| 54 | + echo "Using SNAPSHOT repository." |
| 55 | + DistributionsUrl=https://repository.apache.org/content/repositories/snapshots/ |
| 56 | + DistributionsId=apache.snapshots.https |
| 57 | +else |
| 58 | + echo "Using RELEASES repository." |
| 59 | + DistributionsUrl=https://repository.apache.org/service/local/staging/deploy/maven2/ |
| 60 | + DistributionsId=apache.releases.https |
| 61 | +fi; |
| 62 | + |
| 63 | +mvn org.apache.maven.plugins:maven-gpg-plugin:3.0.1:sign-and-deploy-file \ |
| 64 | + -Durl=$DistributionsUrl\ |
| 65 | + -DrepositoryId=$DistributionsId \ |
| 66 | + -Dfile=$OutputMrJar \ |
| 67 | + -Dsources=$OutputSources \ |
| 68 | + -Dfiles=$OutputTests,$OutputTestSources \ |
| 69 | + -Dtypes=jar,jar \ |
| 70 | + -Dclassifiers=tests,test-sources \ |
| 71 | + -Djavadoc=$OutputJavaDoc \ |
| 72 | + -Dpackaging=jar \ |
| 73 | + -Dversion=$GitTag \ |
| 74 | + -DupdateReleaseInfo=true \ |
| 75 | + -DpomFile=${ProjectBaseDir}/pom.xml |
| 76 | + |
| 77 | +echo "Successfully signed and deployed jars" |
0 commit comments