1#!/bin/sh
2#
3# Release automation script for Linux builds.  This should be run
4# first.  Must be run from the top-level conscrypt directory.
5
6set -e
7
8if [ -z "$1" ]; then
9  echo "Usage: $0 <version>"
10  exit 1
11fi
12
13# Replace the last numerical component of the release with and x, so
14# 1.2.3 becomes 1.2.x
15BRANCH=$(echo "$1" | sed -E 's/([0-9]+[.][0-9]+[.])[0-9]+/\1x/')
16
17git checkout "$BRANCH"
18
19# Update the build.gradle file for the new version
20sed -i 's/version = ".*"/version = "'"$1"'"/' build.gradle
21
22# Commit the build.gradle, tag the release, and push upstream
23git commit -a -m "Preparing version $1"
24git tag -a "$1" -m "Version $1"
25git push upstream "$BRANCH"
26git push upstream "$1"
27
28# Build and start the Docker container
29CONTAINER_TAG="conscrypt-deploy-$1"
30docker build -t $CONTAINER_TAG release
31CONTAINER_ID=$(docker run -itd $CONTAINER_TAG)
32
33# Copy the relevant files from the host machine into the container
34docker exec $CONTAINER_ID mkdir /root/.gradle
35docker cp ~/.gnupg $CONTAINER_ID:/root/
36docker cp ~/.gradle/gradle.properties $CONTAINER_ID:/root/.gradle/
37docker cp "$(grep signingKeystore ~/.gradle/gradle.properties | cut -d= -f2)" $CONTAINER_ID:/root/certkeystore
38
39# Run the release automation script for the docker container
40docker exec $CONTAINER_ID scl enable llvm-toolset-7 "/conscrypt/release/docker $1"
41