-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-docker.sh
executable file
·27 lines (21 loc) · 1.24 KB
/
build-docker.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
#!/bin/bash
set -e
VERSION=$(git describe --tags `git rev-list --tags --max-count=1` --always)
# dynamically pull more interesting stuff from latest git commit
HASH=$(git show-ref --head --hash=8 head) # first 8 letters of hash should be enough; that's what GitHub uses
# Change the version in the project.clj and resources/tservice-plugin.yaml
TRIMMED_VERSION=$(echo $VERSION | sed 's/^v//')
# If running on macOS, use sed -i '' instead of sed -i
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i "" "s/(defproject quartet-rseqc-report \".*\"/(defproject quartet-rseqc-report \"${TRIMMED_VERSION}\"/g" project.clj
sed -i "" "s/version: v.*$/version: v${TRIMMED_VERSION}-${HASH}/g" resources/tservice-plugin.yaml
else
sed -i "s/(defproject quartet-rseqc-report \".*\"/(defproject quartet-rseqc-report \"${TRIMMED_VERSION}\"/g" project.clj
sed -i "s/version: v.*$/version: v${TRIMMED_VERSION}-${HASH}/g" resources/tservice-plugin.yaml
fi
# Build standalone docker image
docker build -t quartet-rseqc-report:${VERSION}-${HASH} .
if [ "$1" == "--push" ]; then
docker tag quartet-rseqc-report:${VERSION}-${HASH} ghcr.io/chinese-quartet/quartet-rseqc-report:${VERSION}-${HASH} && \
docker push ghcr.io/chinese-quartet/quartet-rseqc-report:${VERSION}-${HASH}
fi