blob: 879d2b64b9c5f03d372681868235b1a4fd551dac [file] [log] [blame]
Brian O'Connor1fce5982016-10-25 00:16:16 -07001#!/bin/bash
Brian O'Connordc548792016-11-18 16:57:04 -08002#
3# Script that queries buck for main and test artifacts and publishes them to
4# a remote Maven repository. Main artifacts are published with javadoc and sources
5# jars and auto-generated pom.xml files. Test artifacts are published as compiled
6# jars only. All artifacts are signed.
7#
Brian O'Connor1fce5982016-10-25 00:16:16 -07008
Brian O'Connordc548792016-11-18 16:57:04 -08009ARTIFACT_PUB=$(mktemp /tmp/onos-publish.XXXXX) &&
10 echo "Created temp file for artifact publish: $ARTIFACT_PUB" ||
11 { echo "Failed to create temp file"; exit 1; }
12
13TEST_PUB=$(mktemp /tmp/onos-publish-tests.XXXXX) &&
14 echo "Created temp file for test artifact publish: $TEST_PUB" ||
15 { echo "Failed to create temp file"; exit 1; }
Brian O'Connor1fce5982016-10-25 00:16:16 -070016
Yuta HIGUCHIaa0cb502017-01-12 09:57:32 -080017trap "rm -f $ARTIFACT_PUB $ARTIFACT_PUB.bak $TEST_PUB $TEST_PUB.bak" EXIT
18
Brian O'Connor1fce5982016-10-25 00:16:16 -070019set -e
20set -x
21
Brian O'Connordc548792016-11-18 16:57:04 -080022# Prepare artifact publish commands
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080023cat ${ONOS_ROOT}/tools/build/publish-target-list | grep -v '#' >> $ARTIFACT_PUB
Yuta HIGUCHIea8966d2016-12-03 15:04:54 -080024sed -i.bak 's/^/onos-buck publish --to-maven-central --include-source --include-javadoc --sign /g' $ARTIFACT_PUB
Ray Milkeya3b7f5d2017-02-02 10:37:35 -080025cp $ARTIFACT_PUB $ARTIFACT_PUB.bak
26( echo "set -e"; cat $ARTIFACT_PUB.bak ) >$ARTIFACT_PUB
Brian O'Connor1fce5982016-10-25 00:16:16 -070027
Brian O'Connordc548792016-11-18 16:57:04 -080028# Print commands to be run and then run them
29cat $ARTIFACT_PUB
30bash $ARTIFACT_PUB
Brian O'Connor1fce5982016-10-25 00:16:16 -070031
Ray Milkey033b9f92016-12-09 16:21:55 -080032# Prepare feature commands
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080033onos-buck query "filter('.*-feature', deps(filter('.*-oar', deps('//tools/package:onos-package', 1)),1))" > $TEST_PUB
34echo "//tools/package:onos-features" >> $TEST_PUB
Ray Milkey033b9f92016-12-09 16:21:55 -080035
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080036# Prepare test commands
37cat ${ONOS_ROOT}/tools/build/publish-test-target-list | grep -v '#' >> $TEST_PUB
Yuta HIGUCHIea8966d2016-12-03 15:04:54 -080038sed -i.bak 's#^#onos-buck publish --to-maven-central --sign #g' $TEST_PUB
Ray Milkeya3b7f5d2017-02-02 10:37:35 -080039cp $TEST_PUB $TEST_PUB.bak
40( echo "set -e"; cat $TEST_PUB.bak ) >$TEST_PUB
Brian O'Connor1fce5982016-10-25 00:16:16 -070041
Brian O'Connordc548792016-11-18 16:57:04 -080042# Print commands to be run and then run them
43cat $TEST_PUB
44bash $TEST_PUB
Brian O'Connor1fce5982016-10-25 00:16:16 -070045
Ray Milkey5c5454b2017-01-25 13:26:30 -080046# stage ONOS poms
47onos-buck publish --to-maven-central --sign //:top-level-pom
48onos-buck publish --to-maven-central --sign //lib:onos-dependencies-pom
49
Ray Milkey52e11272017-02-01 17:15:10 -080050if [ ! grep "maven_url" $ONOS_ROOT/.buckconfig.local | grep -v '#' | grep -q snapshots ]; then
51 # Close the staging area
52 onos-close-staging
53fi