refractr/build

33 lines
1.1 KiB
Bash
Executable file

#!/bin/sh
# Create all the different builds for refractr
version=$(cat Cargo.toml | grep -m1 version | awk -F' ' '{print $3}' | sed 's|"||g')
major_version=$(echo $version | awk -F'.' '{print $1}')
uid=$(id -u)
gid=$(id -g)
date=$(date -u --rfc-3339=seconds)
cargo=$(which cargo 2> /dev/null)
if [ -n "$cargo" ]; then
cargo update
cargo clean
fi
# docker builds
docker build -t refractr:$version -t refractr:$major_version -t refractr:latest \
--build-arg VERSION=$version --build-arg DATE="$date" -f docker/Dockerfile .
if [ "$1" = "push" ]; then
docker tag refractr:$version git.brysonsteck.xyz/brysonsteck/refractr:latest
docker tag refractr:$version git.brysonsteck.xyz/brysonsteck/refractr:$version
docker tag refractr:$version git.brysonsteck.xyz/brysonsteck/refractr:$major_version
docker push -a git.brysonsteck.xyz/brysonsteck/refractr
docker image rm git.brysonsteck.xyz/brysonsteck/refractr:latest
docker image rm git.brysonsteck.xyz/brysonsteck/refractr:$version
docker image rm git.brysonsteck.xyz/brysonsteck/refractr:$major_version
fi
# rust build
if [ -n "$cargo" ]; then
cargo build
cargo build --release
fi