add docker build function

This commit is contained in:
Simon 2023-07-31 23:37:27 +07:00
parent 28e4c95f86
commit 5febd8b20f
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -51,12 +51,50 @@ function sync_test {
}
function sync_docker {
# check things
if [[ $(git branch --show-current) != 'master' ]]; then
echo 'you are not on master, dummy!'
return
fi
if [[ $(systemctl is-active docker) != 'active' ]]; then
echo "starting docker"
sudo systemctl start docker
fi
echo "latest tags:"
git tag | tail -n 5 | sort -r
printf "\ncreate new version:\n"
read -r VERSION
echo "build and push $VERSION?"
read -rn 1
# start build
docker buildx build \
--platform linux/amd64,linux/arm64 \
-t bbilly1/tubearchivist-jf \
-t bbilly1/tubearchivist-jf:"$VERSION" --push .
# create release tag
echo "commits since last version:"
git log "$(git describe --tags --abbrev=0)"..HEAD --oneline
git tag -a "$VERSION" -m "new release version $VERSION"
git push origin "$VERSION"
}
if [[ $1 == "validate" ]]; then
validate "$2"
elif [[ $1 == "test" ]]; then
sync_test
elif [[ $1 == "docker" ]]; then
sync_docker
else
echo "valid options are: validate | test"
echo "valid options are: validate | test | docker"
fi