Skip to content

Commit 3710e8d

Browse files
committed
Add docker support for maven release
1 parent ea2d59a commit 3710e8d

File tree

3 files changed

+51
-64
lines changed

3 files changed

+51
-64
lines changed

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
FROM openjdk:8-jdk-alpine
2+
3+
ENV VERSION=
4+
ENV NEXT_VERSION=
5+
ENV GPG_PASSPHRASE=
6+
ENV GIT_USERNAME=
7+
ENV GIT_SECRET=
8+
ARG GIT_EMAIL=
9+
ARG FULL_NAME=
10+
11+
ARG MAVEN_VERSION=3.3.9
12+
ARG USER_HOME_DIR="/root"
13+
ENV MAVEN_HOME /usr/share/maven
14+
ENV MAVEN_CONFIG "$USER_HOME_DIR/.m2"
15+
# speed up Maven JVM a bit
16+
ENV MAVEN_OPTS="-XX:+TieredCompilation -XX:TieredStopAtLevel=1"
17+
18+
VOLUME /gpg
19+
VOLUME /maven
20+
21+
COPY maven-release.sh /maven-release.sh
22+
23+
# Install Maven, Git and gpg
24+
RUN apk add --no-cache curl tar bash git gnupg
25+
RUN mkdir -p /usr/share/maven && \
26+
curl -fsSL http://apache.osuosl.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz | tar -xzC /usr/share/maven --strip-components=1 && \
27+
ln -s /usr/share/maven/bin/mvn /usr/bin/mvn
28+
RUN git config --global user.email ${GIT_EMAIL} && \
29+
git config --global user.name ${FULL_NAME}
30+
31+
# Configure gpg
32+
RUN export GPG_TTY=/dev/console
33+
RUN export GPG_OPTS='--pinentry-mode loopback'
34+
35+
RUN ["chmod", "+x", "/maven-release.sh"]
36+
ENTRYPOINT /maven-release.sh

maven-release-snapshot.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

maven-release.sh

100755100644
Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,23 @@
11
#!/bin/sh
22

3-
# Usage: ./maven-release.sh v2.0 2.1-SNAPSHOT 2.0
4-
53
branch_to_release="master"
4+
set -e
5+
6+
echo "Set private key..."
7+
cp -vr /gpg ~/.gnupg
8+
echo "pinentry-mode loopback" > ~/.gnupg/gpg.conf
9+
cp -vpr /maven ~/.m2
10+
11+
echo "Cloning convertapi-java..."
12+
git clone https://${GIT_USERNAME}:${GIT_SECRET}@github.com/ConvertAPI/convertapi-java.git
13+
cd convertapi-java
614

715
echo "Switching to the release branch..."
816
git fetch
917
git checkout $branch_to_release
1018

11-
echo "Pulling changes..."
12-
git pull --ff-only
13-
14-
echo "Push commits..."
15-
git push
16-
17-
echo "Revert uncommitted changes..."
18-
git checkout .
19-
20-
echo "Cleaning..."
21-
mvn clean
22-
2319
echo "Preparing release..."
24-
if [ $# -eq 1 ]
25-
then
26-
echo "\n\n" | mvn release:prepare -Dtag=$1 -Dresume=false
27-
elif [ $# -eq 2 ]
28-
then
29-
echo "\n" | mvn release:prepare -DdevelopmentVersion=$2 -Dtag=$1 -Dresume=false
30-
elif [ $# -eq 3 ]
31-
then
32-
mvn release:prepare -DreleaseVersion=$3 -DdevelopmentVersion=$2 -Dtag=$1 -Dresume=false
33-
else
34-
echo "\n\n\n" | mvn release:prepare -Dresume=false
35-
fi
20+
mvn release:prepare -DreleaseVersion=${VERSION} -DdevelopmentVersion=${NEXT_VERSION} -Dtag=v${VERSION} -Dresume=false -Darguments=-Dgpg.passphrase=${GPG_PASSPHRASE}
3621

3722
echo "Performing release..."
3823
mvn release:perform
@@ -42,3 +27,7 @@ git push --tags
4227

4328
echo "Push release commits..."
4429
git push
30+
31+
echo "-------------------------------------------------------------"
32+
echo "SUCCESSFULLY released ${VERSION} to Maven Central repository."
33+
echo "-------------------------------------------------------------"

0 commit comments

Comments
 (0)