Skip to content
This repository was archived by the owner on Oct 21, 2019. It is now read-only.

Commit

Permalink
🎉 Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Teakowa committed Aug 24, 2019
0 parents commit 2cd3c5b
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Builder

## Install

```
sudo curl -L https://raw.githubusercontent.com/FSPNET/builder/master/scripts/publish.sh -o /usr/local/bin/docker-publish
sudo chmod +x /usr/local/bin/docker-publish
```

## Usage

```
~ docker-publish
usage: docker-publish repo[:tag] repo:tag [prefix count]
ie: docker-publish build:travis FSPNET/php:7.3.4
docker-publish build FSPNET/php:7.3.4 2
```
58 changes: 58 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash

set -eo pipefail
shopt -s dotglob

# make sure we can GTFO
trap 'echo >&2 Ctrl+C captured, exiting; exit 1' SIGINT

usage() {
self="$(basename "$0")"
cat <<-EOUSAGE
usage: $self repo[:tag] repo:tag [prefix count]
ie: $self build:travis FSPNET/php:7.3.4
$self build FSPNET/php:7.3.4 2
EOUSAGE
}

if [ $# -lt 2 ]; then
usage >&2
exit 1
fi

image_build="$1" && shift
image_target="$1" && shift
prefix_count=${1:-"0"}

target_name=`echo "$image_target" | cut -d: -f1`
target_version=`echo "$image_target" | cut -d: -f2`
target_version_count=`echo "$target_version" | tr -dc '.' | wc -c | awk '{$1=$1;print}'`

versions=()

if [[ "$target_version" =~ -dev$ ]]; then
is_dev="true"
target_version=`echo $target_version | sed 's/-dev$//'`
fi

if [[ "$prefix_count" = "0" ]]; then
if [ ! -z $is_dev ]; then
versions+=("dev")
else
versions+=("latest")
fi
prefix_count="1"
fi

for (( i=$((${target_version_count}+1)); i>=${prefix_count}; i-- )); do
version=`echo "$target_version" | cut -d. -f1-${i}`
if [ ! -z $is_dev ]; then
version="$version-dev"
fi
versions+=($version)
done

for version in "${versions[@]}"; do
docker tag ${image_build} ${target_name}:${version}
docker push ${target_name}:${version}
done

0 comments on commit 2cd3c5b

Please sign in to comment.