-
Notifications
You must be signed in to change notification settings - Fork 4
/
staged-maven-deploy.sh
executable file
·42 lines (34 loc) · 1.44 KB
/
staged-maven-deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env bash
set -u -e -o pipefail
# First arg must be release type followed by any args to pass to the nexus-staging-cli, i.e. --package-group=com.example
# Execute from the actual top level workspace
cd $BUILD_WORKSPACE_DIRECTORY
# Called by auto -- `release` for normal releases or `snapshot` for canary/next.
readonly RELEASE_TYPE=${1}
# TODO: It'd be really nice to encapsulate this into a rule -- but requires touching the workspace and during wildcard queries
if [ "$RELEASE_TYPE" == "snapshot" ]; then
# Need to add snapshot identifier for snapshot releases
cp VERSION VERSION.bak
echo -n -SNAPSHOT >> VERSION
elif [ "$RELEASE_TYPE" == "release" ]; then
# Prep staging repo
readonly STAGING=$(bazel run @rules_player//distribution:nexus-staging-cli -- "${@:2}")
fi
# Find all the maven packages in the repo
readonly DEPLOY_LABELS=$(bazel query --output=label 'kind("maven_publish rule", //...) - attr("tags", "\[.*do-not-publish.*\]", //...)')
for pkg in $DEPLOY_LABELS ; do
if [ -n "${STAGING-}" ]; then
bazel run "$pkg" --define=maven_repo="$STAGING" -- "$1"
else
bazel run "$pkg" --define=maven_repo="https://oss.sonatype.org/content/repositories/snapshots/" -- "$1"
fi
done
if [ -n "${STAGING-}" ]; then
# Close and release staging repo
bazel run @rules_player//distribution:nexus-staging-cli -- "${@:2}" --staging-id="${STAGING##*/}"
fi
# Cleanup
if [ -f VERSION.bak ]; then
rm VERSION
mv VERSION.bak VERSION
fi