Skip to content

Commit

Permalink
deployed binary dev version 0.6.4-aplha1 docopt#36
Browse files Browse the repository at this point in the history
  • Loading branch information
Sylvain Viart committed Aug 9, 2019
1 parent 4556e25 commit b49e4f5
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 32 deletions.
8 changes: 2 additions & 6 deletions PROGRESS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
# current work in PROGRRESS

## release and binary
## Alternative #35 docopt.sh

https://github.com/docopt/docopts/issues/32
Middle ware?

publish release and pre-build binaries

* travis deploy? https://docs.travis-ci.com/user/deployment/releases/
* https://blog.questionable.services/article/build-go-binaries-travis-ci-github/

## provide test on old environment

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.6.3-rc1
v0.6.4-alpha1
10 changes: 5 additions & 5 deletions build/sha256sum.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cabeab52e60001366c36329c3994608dfc20b1fa1f1c826b669e9c1813296432 docopts_darwin_386
cabf6cfc42abd61be3f05aa0abf73e07dd1cfbe35f033fa0ac2687cb22a213a3 docopts_darwin_amd64
831e2c75bca33e5165d50cd16a6ae75ed652f322df5bf80da4586cf02cf93ed1 docopts_linux_386
46345cdd8f30c52abdc725b11c96a4d9cb4606d46f5d67062925b1bc64a9ffba docopts_linux_amd64
5f18f8da2c384015e80af725f7c53c1bd2bf5d73e6e0960a803813caac3ada5f docopts_linux_arm
d961d34452e22e6557ae5164003b73092d9dada3483ee82cad272eb08d0025d9 docopts_darwin_386
f0db082d9f01a0e184691df784b340730bb67c5ae5fd76d1ab85bd2c0b70dc0b docopts_darwin_amd64
048f6dd7a70789efceee80161efb1da0977faa6c9c15c54ebc4d5cb8e5d4d294 docopts_linux_386
019c86f09ea30cf66cf8b099b10391c45eea7510af87a6ef5c90d8201b8df204 docopts_linux_amd64
bbb7d19573116af8f496f7b7622aaff40a7460178dee99292f0de73052d41513 docopts_linux_arm
67 changes: 48 additions & 19 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# -r REMOTE_REPOS Specify a REMOTE_REPOS name [default: origin]
# --replace Replace existing release with this one, previous release
# will be deleted first.
# -u GITHUB_USER force this GITHUB_USER
#
# Arguments:
# RELEASE_VERSION a git tag, or current for the local modified version
Expand Down Expand Up @@ -192,80 +193,108 @@ EOT

check_name_description()
{
local name="$1"
local description="$2"
local release=$1
local name="$2"
local description="$3"
if [[ -z $description || $description == null || -z $name || $name == null ]] ; then
echo "description or name not found for tag '$TAG' in $DEPLOYMENT_FILE"
echo "description or name not found for tag '$release' in $DEPLOYMENT_FILE"
echo "available git tags:"
indent "$(git tag)"
echo "available git tags in $DEPLOYMENT_FILE:"
indent "$(yaml_keys $DEPLOYMENT_FILE releases)"
echo "VERSION contains"
indent "$(cat VERSION)"
return 1
fi
}

main_deploy()
{
local release=$1
local release_version=$release

# redefine GITHUB_TOKEN to test if exported for strict mode
GITHUB_TOKEN=${GITHUB_TOKEN:-}

local description=$(yq.v2 r $DEPLOYMENT_FILE "releases[$release].description")
local name=$(yq.v2 r $DEPLOYMENT_FILE "releases[$release].name")
if [[ $release == current ]] ; then
release_version=$(cat VERSION)
echo "using current release in VERSION: $release_version"
fi

local description=$(yq.v2 r $DEPLOYMENT_FILE "releases[$release_version].description")
local name=$(yq.v2 r $DEPLOYMENT_FILE "releases[$release_version].name")

# will stop the execution (as set -e is enabled)
check_name_description "$name" "$description"
check_name_description $release_version "$name" "$description"

build_binaries $release $BUILD_DEST_DIR
UPLOAD_FILES=$(prepare_upload $BUILD_DEST_DIR)

if $ARGS_n ; then
show_release_data $release "$name" "$description"
show_release_data $release_version "$name" "$description"
exit 0
else
if [[ -z $GITHUB_TOKEN ]] ; then
echo "GITHUB_TOKEN must be exported"
return 1
fi

if check_release $release ; then
echo "release already exists: $release"
if check_release $release_version ; then
echo "release already exists: $release_version"
if $ARGS_replace ; then
echo "deleting existing release: $release"
delete_release $release
echo "creating release: $release"
create_release $release "$name" "$description"
echo "deleting existing release: $release_version"
delete_release $release_version
echo "creating release: $release_version"
create_release $release_version "$name" "$description"
else
echo "use --replace to replace the existing release"
echo "only upload new files"
fi
else
echo "release doesn't exists yet: $release"
echo "creating new release: $release"
create_release $release "$name" "$description"
echo "release doesn't exists yet: $release_version"
echo "creating new release: $release_version"
create_release $release_version "$name" "$description"
fi
upload_binaries $release $UPLOAD_FILES
upload_binaries $release_version $UPLOAD_FILES
fi
}

check_env()
{
local v val
local error=0

for v in GOPATH GOBIN
do
eval "val=\${$v:-}"
if [[ -z $val ]] ; then
echo "$v is undefined, check failed"
error=$((error+1))
fi
done
return $error
}

if [[ $0 == $BASH_SOURCE ]] ; then
# bash strict mode
set -euo pipefail

check_env

# we add our repository path to run our local docopts binary
# you will have to build it first of course.
PATH=$(dirname $0):$PATH
source docopts.sh --auto -G "$@"
docopt_print_ARGS -G

# fix docopt bug https://github.com/docopt/docopt/issues/386
ARGS_REMOTE_REPOS=${ARGS_REMOTE_REPOS:-$ARGS_r}
ARGS_GITHUB_USER=${ARGS_GITHUB_USER:-$ARGS_u}

if [[ -n $ARGS_GITHUB_USER ]]; then
GITHUB_USER=$ARGS_GITHUB_USER
fi

#docopt_print_ARGS -G

if [[ -n $ARGS_RELEASE_VERSION ]] ; then
TAG=$ARGS_RELEASE_VERSION
else
Expand Down
10 changes: 10 additions & 0 deletions deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ build:
#- android/arm
releases:
# yaml keys must match the git tag
v0.6.4-alpha1:
name: "docopts binary v0.6.4-alpha1"
description: |
Prototype version
based on dev-docopt_sh
changes:
- `--docopt_sh` output compatible variable ([see #36](https://github.com/docopt/docopts/issues/36))
v0.6.3-rc1:
name: "docopts binary transitional v0.6.3-rc1"
description: |
Expand Down
2 changes: 1 addition & 1 deletion get_docopts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ GIT_PROJECT=docopts
BASE_URL=https://github.com/$GIT_USER/$GIT_PROJECT/releases/download

#RELEASE=v0.6.3-rc1
RELEASE=v0.6.3-alpha2
RELEASE=v0.6.4-alpha1
BINARY=docopts
ISSUE_URL=https://github.com/$GIT_USER/$GIT_PROJECT/issues/

Expand Down

0 comments on commit b49e4f5

Please sign in to comment.