-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaven_repo
executable file
·76 lines (56 loc) · 2.22 KB
/
maven_repo
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Check if enough arguments have been given to the script.
if [[ $# < 1 ]]; then
echo "Usage: $0 <command> [Travis-JDK] [branch]"
echo "This will run the command using these environment variables:"
echo "REPO_GLOBAL, REPO_RELEASES, REPO_SNAPSHOTS, REPO_THIRDPARTY"
echo "The build should automatically publish it in Maven repository format to the correct folder."
exit 1
fi
GIT_REPO=${GIT_REPO:-"git@github.com:LapisBlue/Repo.git"}
GIT_DIR=/tmp/deploy/repo
# This is where I am.
deploy_scripts=$(dirname $0)
# The command to execute that will publish the artifacts.
command=$1
# JDK to publish the artifacts with, Java 6 by default
jdk=${2:-openjdk6}
branch=${3:-master}
# Ensure all commands complete successfully
set -e
# Make sure we're running the right Travis JDK version
[[ -z "$TRAVIS_JDK_VERSION" || "$TRAVIS_JDK_VERSION" = "$jdk" ]]
# Make sure we're on the right branch
[[ -z "$TRAVIS_BRANCH" || "$TRAVIS_BRANCH" = "$branch" ]]
# Initialize the ssh-agent so we can use Git later for deploying
eval $(ssh-agent)
# Set up our Git environment
$deploy_scripts/setup_git
# Clone our Maven repo repository
git clone $GIT_REPO $GIT_DIR
# Setup repo path environment variables
export REPO_GLOBAL="$GIT_DIR"
echo "Publishing to: $REPO_GLOBAL"
export REPO_RELEASES="$GIT_DIR/releases"
echo "Publishing releases to: $REPO_RELEASES"
export REPO_SNAPSHOTS="$GIT_DIR/snapshots"
echo "Publishing snapshots to: $REPO_SNAPSHOTS"
export REPO_THIRDPARTY="$GIT_DIR/thirdparty"
echo "Publishing third party artifacts to: $REPO_THIRDPARTY"
echo "Publishing artifacts..."
# Run the specified command to build the Javadocs
$command
echo "Successfully published artifacts, deploying to GitHub..."
cd $GIT_DIR
# Stage all changed and removed files for commit
git add -A
# Commit the changes with a more detailed commit message only for Travis.
[[ "$TRAVIS" = "true" ]] \
&& message="Publish $TRAVIS_REPO_SLUG@$TRAVIS_COMMIT (Build $TRAVIS_BUILD_NUMBER)" \
|| message="Publish $(date -u +"%Y-%m-%dT%H:%M:%SZ")" # -> ugly date
git commit -m "$message"
# Push the changes to GitHub
git push
# Kill the ssh-agent because we're done with deploying
eval $(ssh-agent -k)
echo "Done! Successfully published artifacts to the GitHub Maven repository! :)"