Merge branch 'better-builds' into develop
commit
c411fc5d6c
|
@ -313,6 +313,16 @@ dependencies = [
|
|||
"cfg-if 1.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fej"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"reqwest",
|
||||
"rocket",
|
||||
"rocket_contrib",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.14"
|
||||
|
@ -1254,16 +1264,6 @@ dependencies = [
|
|||
"unicode-xid 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-api"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"reqwest",
|
||||
"rocket",
|
||||
"rocket_contrib",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.2.3"
|
||||
|
|
8
Makefile
8
Makefile
|
@ -1,6 +1,4 @@
|
|||
IMAGE := chewingbever/fej
|
||||
TAG := 0.0.1-dev
|
||||
shell := /bin/bash
|
||||
|
||||
|
||||
all: debug
|
||||
|
@ -16,11 +14,11 @@ release:
|
|||
.PHONY: release
|
||||
|
||||
image: Dockerfile
|
||||
@ docker build -t '$(IMAGE):$(TAG)' .
|
||||
@ ./build '$(IMAGE)'
|
||||
.PHONY: image
|
||||
|
||||
push: image
|
||||
@ docker push '$(IMAGE):$(TAG)'
|
||||
push:
|
||||
@ ./build '$(IMAGE)' push
|
||||
.PHONY: push
|
||||
|
||||
# Run
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Simple guard to check input args
|
||||
[[ $# -eq 1 ]] || [[ $# -eq 2 ]] || {
|
||||
>&2 echo "Usage: ./build IMAGE [ACTION]"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extract current version from Cargo.toml & get current branch
|
||||
patch_version="$(grep -Po '(?<=version = ").*(?=")' Cargo.toml | head -n1)"
|
||||
major_version="$(echo "$patch_version" |
|
||||
sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+)/\1/')"
|
||||
minor_version="$(echo "$patch_version" |
|
||||
sed -E 's/([0-9]+).([0-9]+).([0-9]+)/\1.\2/')"
|
||||
branch="$(git branch --show-current)"
|
||||
|
||||
if [[ "$branch" = "master" ]]; then
|
||||
tags=("$patch_version" "$minor_version" "$major_version" "latest" )
|
||||
|
||||
elif [[ "$branch" = "develop" ]]; then
|
||||
tags=("$patch_version-dev" "$minor_version-dev" "$major_version-dev" )
|
||||
|
||||
else
|
||||
tags=("$branch")
|
||||
|
||||
fi
|
||||
|
||||
tag_flags=()
|
||||
|
||||
for tag in "${tags[@]}"; do
|
||||
tag_flags+=("-t $1:$tag")
|
||||
|
||||
done
|
||||
|
||||
# Run the actual build command
|
||||
docker build $tag_flags .
|
||||
|
||||
if [[ "$2" = push ]]; then
|
||||
[[ "$branch" =~ ^develop|master$ ]] || {
|
||||
>&2 echo "You can only push from develop or master."
|
||||
exit 2
|
||||
}
|
||||
|
||||
for tag in "${tags[@]}"; do
|
||||
docker push "$1:$tag"
|
||||
done
|
||||
|
||||
elif [[ "$2" = run ]]; then
|
||||
docker run \
|
||||
--rm \
|
||||
--interactive \
|
||||
--tty \
|
||||
--publish 8000:8000 \
|
||||
"$1:$tags"
|
||||
fi
|
Loading…
Reference in New Issue