Support doing releases from CI.
This commit is contained in:
21
ci/CI.adoc
Normal file
21
ci/CI.adoc
Normal file
@@ -0,0 +1,21 @@
|
||||
== Running CI tasks locally
|
||||
|
||||
IMPORTANT: To do this you must have Docker installed on your machine.
|
||||
|
||||
1. `cd ..`
|
||||
+
|
||||
Because this tool is actually a subfolder, you must run the Docker container from up above.
|
||||
+
|
||||
2. `docker run -it --mount type=bind,source="$(pwd)",target=/release-tools springci/spring-data-release-tools:0.1 /bin/bash`
|
||||
+
|
||||
This will launch the Docker image and mount your source code at `release-tools-github`.
|
||||
+
|
||||
3. `cd release-tools`
|
||||
+
|
||||
Next, run the `ci/prepare-and-build.bash` script from inside the container:
|
||||
+
|
||||
4. `SONATYPE_USR=foo SONATYPE_PSW=bar ci/prepare-and-build.bash <version>`
|
||||
|
||||
Since the container is binding to your source, you can make edits from your IDE and continue to run build jobs.
|
||||
|
||||
NOTE: Docker containers can eat up disk space fast! From time to time, run `docker system prune` to clean out old images.
|
||||
30
ci/Dockerfile
Executable file
30
ci/Dockerfile
Executable file
@@ -0,0 +1,30 @@
|
||||
FROM ubuntu:22.10
|
||||
|
||||
ARG USER_UID="1001"
|
||||
ARG USER_GID="1001"
|
||||
ARG USER_NAME="jenkins"
|
||||
|
||||
RUN groupadd -g $USER_GID $USER_NAME && \
|
||||
useradd -m -g $USER_GID -u $USER_UID $USER_NAME
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get -y install curl zip gnupg
|
||||
RUN rm -rf /var/lib/apt/lists/* && \
|
||||
rm -rf /tmp/*
|
||||
|
||||
USER $USER_UID:$USER_GID
|
||||
|
||||
RUN curl -s "https://get.sdkman.io" | bash
|
||||
|
||||
RUN bash -c "source $HOME/.sdkman/bin/sdkman-init.sh && \
|
||||
yes | sdk install java 17.0.2-tem && \
|
||||
yes | sdk install java 17.0.3-tem && \
|
||||
yes | sdk install java 8.0.322-tem && \
|
||||
yes | sdk install java 8.0.332-tem && \
|
||||
yes | sdk install maven && \
|
||||
rm -rf $HOME/.sdkman/archives/* && \
|
||||
rm -rf $HOME/.sdkman/tmp/*"
|
||||
|
||||
ENV MAVEN_HOME="$HOME/.sdkman/candidates/maven/current"
|
||||
ENV JAVA_HOME="$HOME/.sdkman/candidates/java/current"
|
||||
ENV PATH="$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH"
|
||||
11
ci/build-spring-data-release-cli.bash
Executable file
11
ci/build-spring-data-release-cli.bash
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export MAVEN_HOME="$HOME/.sdkman/candidates/maven/current"
|
||||
export JAVA_HOME="$HOME/.sdkman/candidates/java/current"
|
||||
export PATH="$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH"
|
||||
|
||||
export JENKINS_HOME=/tmp/jenkins-home
|
||||
|
||||
mvn clean package -DskipTests
|
||||
51
ci/conclude.bash
Executable file
51
ci/conclude.bash
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=$1
|
||||
echo "You want me to conclude ${VERSION} ??"
|
||||
|
||||
export MAVEN_HOME="$HOME/.sdkman/candidates/maven/current"
|
||||
export JAVA_HOME="$HOME/.sdkman/candidates/java/current"
|
||||
export PATH="$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH"
|
||||
|
||||
export JENKINS_HOME=/tmp/jenkins-home
|
||||
export RELEASE_TOOLS_CACHE=${JENKINS_HOME}/.m2/spring-data-release-tools
|
||||
export LOGS_DIR=${JENKINS_HOME}/spring-data-shell/logs
|
||||
export SETTINGS_XML=${JENKINS_HOME}/settings.xml
|
||||
export GNUPGHOME=~/.gnupg/
|
||||
|
||||
if test -f application-local.properties; then
|
||||
echo "You are running from dev environment! Using application-local.properties."
|
||||
|
||||
GIT_BRANCH=""
|
||||
|
||||
function spring-data-release-shell {
|
||||
java \
|
||||
"-Ddeployment.settings-xml=${SETTINGS_XML}" \
|
||||
"-Ddeployment.local=true" \
|
||||
"-Dmaven.mavenHome=${MAVEN_HOME}" \
|
||||
"-Dgpg.executable=/usr/bin/gpg" \
|
||||
"-Dio.workDir=dist" \
|
||||
-jar target/spring-data-release-cli.jar
|
||||
}
|
||||
else
|
||||
echo "You are running inside Jenkins! Using parameters fed from the agent."
|
||||
|
||||
# Reinstall Jenkins' GPG keys
|
||||
\rm -rf ${GNUPGHOME}
|
||||
mkdir -p ${GNUPGHOME}
|
||||
chmod 700 ${GNUPGHOME}
|
||||
cp $KEYRING $GNUPGHOME
|
||||
|
||||
function spring-data-release-shell {
|
||||
java \
|
||||
-Dspring.profiles.active=jenkins \
|
||||
-Dmaven.home=${MAVEN_HOME} \
|
||||
-jar target/spring-data-release-cli.jar
|
||||
}
|
||||
fi
|
||||
|
||||
echo "About to conclude ${VERSION}."
|
||||
|
||||
echo "release conclude ${VERSION}" | spring-data-release-shell
|
||||
63
ci/prepare-and-build.bash
Executable file
63
ci/prepare-and-build.bash
Executable file
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=$1
|
||||
echo "You want me to build and deploy ${VERSION} ??"
|
||||
|
||||
export MAVEN_HOME="$HOME/.sdkman/candidates/maven/current"
|
||||
export JAVA_HOME="$HOME/.sdkman/candidates/java/current"
|
||||
export PATH="$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH"
|
||||
|
||||
export JENKINS_HOME=/tmp/jenkins-home
|
||||
export RELEASE_TOOLS_CACHE=${JENKINS_HOME}/.m2/spring-data-release-tools
|
||||
export LOGS_DIR=${JENKINS_HOME}/spring-data-shell/logs
|
||||
export SETTINGS_XML=${JENKINS_HOME}/settings.xml
|
||||
|
||||
mkdir -p ${RELEASE_TOOLS_CACHE}
|
||||
mkdir -p ${LOGS_DIR}
|
||||
|
||||
export GNUPGHOME=~/.gnupg/
|
||||
mkdir -p ${GNUPGHOME}
|
||||
chmod 700 ${GNUPGHOME}
|
||||
|
||||
cp ci/settings.xml ${JENKINS_HOME}
|
||||
|
||||
if test -f application-local.properties; then
|
||||
echo "You are running from dev environment! Using application-local.properties."
|
||||
|
||||
GIT_BRANCH=""
|
||||
|
||||
function spring-data-release-shell {
|
||||
java \
|
||||
"-Ddeployment.settings-xml=${SETTINGS_XML}" \
|
||||
"-Ddeployment.local=true" \
|
||||
"-Dmaven.mavenHome=${MAVEN_HOME}" \
|
||||
"-Dgpg.executable=/usr/bin/gpg" \
|
||||
"-Dio.workDir=dist" \
|
||||
-jar target/spring-data-release-cli.jar \
|
||||
--cmdfile target/prepare-and-build.shell
|
||||
}
|
||||
else
|
||||
echo "You are running inside Jenkins! Using parameters fed from the agent."
|
||||
|
||||
cp $KEYRING $GNUPGHOME
|
||||
|
||||
ls -ld ~/.gnupg
|
||||
ls -lR ~/.gnupg
|
||||
id
|
||||
|
||||
function spring-data-release-shell {
|
||||
java \
|
||||
-Dspring.profiles.active=jenkins \
|
||||
-Dmaven.home=${MAVEN_HOME} \
|
||||
-jar target/spring-data-release-cli.jar \
|
||||
--cmdfile target/prepare-and-build.shell
|
||||
}
|
||||
fi
|
||||
|
||||
echo "About to prepare and build ${VERSION}."
|
||||
|
||||
sed "s|\${VERSION}|${VERSION}|g" < ci/prepare-and-build.template > target/prepare-and-build.shell
|
||||
|
||||
spring-data-release-shell
|
||||
5
ci/prepare-and-build.template
Normal file
5
ci/prepare-and-build.template
Normal file
@@ -0,0 +1,5 @@
|
||||
workspace cleanup
|
||||
release prepare ${VERSION}
|
||||
repository open ${VERSION}
|
||||
release build ${VERSION}
|
||||
repository close ${VERSION}
|
||||
50
ci/push-and-distribute.bash
Executable file
50
ci/push-and-distribute.bash
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
VERSION=$1
|
||||
echo "You want me to push and distribute ${VERSION} ??"
|
||||
|
||||
export MAVEN_HOME="$HOME/.sdkman/candidates/maven/current"
|
||||
export JAVA_HOME="$HOME/.sdkman/candidates/java/current"
|
||||
export PATH="$MAVEN_HOME/bin:$JAVA_HOME/bin:$PATH"
|
||||
|
||||
export JENKINS_HOME=/tmp/jenkins-home
|
||||
export RELEASE_TOOLS_CACHE=${JENKINS_HOME}/.m2/spring-data-release-tools
|
||||
export LOGS_DIR=${JENKINS_HOME}/spring-data-shell/logs
|
||||
export SETTINGS_XML=${JENKINS_HOME}/settings.xml
|
||||
export GNUPGHOME=~/.gnupg/
|
||||
|
||||
if test -f application-local.properties; then
|
||||
echo "You are running from dev environment! Using application-local.properties."
|
||||
|
||||
GIT_BRANCH=""
|
||||
|
||||
function spring-data-release-shell {
|
||||
java \
|
||||
"-Ddeployment.settings-xml=${SETTINGS_XML}" \
|
||||
"-Ddeployment.local=true" \
|
||||
"-Dmaven.mavenHome=${MAVEN_HOME}" \
|
||||
"-Dgpg.executable=/usr/bin/gpg" \
|
||||
"-Dio.workDir=dist" \
|
||||
-jar target/spring-data-release-cli.jar \
|
||||
--cmdfile target/push-and-distribute.shell
|
||||
}
|
||||
else
|
||||
echo "You are running inside Jenkins! Using parameters fed from the agent."
|
||||
|
||||
function spring-data-release-shell {
|
||||
java \
|
||||
-Dspring.profiles.active=jenkins \
|
||||
-Dmaven.home=${MAVEN_HOME} \
|
||||
-jar target/spring-data-release-cli.jar \
|
||||
--cmdfile target/push-and-distribute.shell
|
||||
}
|
||||
|
||||
fi
|
||||
|
||||
echo "About to push and distribute ${VERSION}."
|
||||
|
||||
sed "s|\${VERSION}|${VERSION}|g" < ci/push-and-distribute.template > target/push-and-distribute.shell
|
||||
|
||||
spring-data-release-shell
|
||||
2
ci/push-and-distribute.template
Executable file
2
ci/push-and-distribute.template
Executable file
@@ -0,0 +1,2 @@
|
||||
github push ${VERSION}
|
||||
release distribute ${VERSION}
|
||||
3
ci/release.properties
Normal file
3
ci/release.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
# Release train version
|
||||
release.version=2021.1.7
|
||||
#release.version=2022.0.0-M6
|
||||
12
ci/settings.xml
Normal file
12
ci/settings.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
|
||||
|
||||
<servers>
|
||||
<server>
|
||||
<id>sonatype</id>
|
||||
<username>${env.SONATYPE_USR}</username>
|
||||
<password>${env.SONATYPE_PSW}</password>
|
||||
</server>
|
||||
</servers>
|
||||
</settings>
|
||||
Reference in New Issue
Block a user