From 7db84dc62ed8493a48d10da849062376a8afc6ea Mon Sep 17 00:00:00 2001 From: enr Date: Wed, 1 Aug 2018 23:46:04 +0200 Subject: [PATCH] sdlc scripts --- .sdlc/build | 16 ++++++------ .sdlc/build-dist | 68 ++++++++++++++++++++++++------------------------ .sdlc/config | 2 +- .sdlc/gh-release | 28 ++++++++++---------- .sdlc/update | 4 +-- 5 files changed, 59 insertions(+), 59 deletions(-) diff --git a/.sdlc/build b/.sdlc/build index 0f7c2fc..8aef9e4 100755 --- a/.sdlc/build +++ b/.sdlc/build @@ -28,12 +28,12 @@ echo "build time : ${buildtime}" dep ensure for dir in $(find "$CMDS_DIR" -mindepth 1 -maxdepth 1 -type d); do - app_name=$(basename "$dir") - echo " ===== Process ${app_name} ${dir} =====" - go build -ldflags "-s \ - -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.Version=${APP_VERSION} \ - -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.BuildTime=${buildtime} \ - -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.GitCommit=${git_commit}" \ - -o "${BIN_DIR}/${app_name}" \ - "github.com/${GH_OWNER}/${GH_REPO}/cmd/${app_name}" + app_name=$(basename "$dir") + echo " ===== Process ${app_name} ${dir} =====" + go build -ldflags "-s \ + -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.Version=${APP_VERSION} \ + -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.BuildTime=${buildtime} \ + -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.GitCommit=${git_commit}" \ + -o "${BIN_DIR}/${app_name}" \ + "github.com/${GH_OWNER}/${GH_REPO}/cmd/${app_name}" done diff --git a/.sdlc/build-dist b/.sdlc/build-dist index 9b07a3d..5f79582 100755 --- a/.sdlc/build-dist +++ b/.sdlc/build-dist @@ -21,8 +21,8 @@ echo "git : ${git_commit}" echo "build time : ${buildtime}" [[ -z "$DIST_DIR" ]] && { - echo "no dist dir set" - exit 1 + echo "no dist dir set" + exit 1 } [[ -d "${PRJ_HOME}/bin" ]] && rm -r "${PRJ_HOME}/bin" @@ -32,40 +32,40 @@ mkdir -p "$DIST_DIR" platforms="windows/amd64 linux/amd64 darwin/amd64" for dir in $(find "$CMDS_DIR" -mindepth 1 -maxdepth 1 -type d); do - app_name=$(basename "$dir") - echo " ===== Process ${app_name} ${dir} =====" - for platform in $platforms; do - cd "$PRJ_HOME" - target_goos=$(echo $platform | cut -d/ -f1) - target_goarch=$(echo $platform | cut -d/ -f2) - echo "building for ${target_goos} ${target_goarch}" - platform_dist_basename="${GH_REPO}-${APP_VERSION}_${target_goos}_${target_goarch}" - platform_dist_dir="${DIST_DIR}/${platform_dist_basename}" - mkdir -p "$platform_dist_dir" - ext='' - [[ "windows" = "$target_goos" ]] && ext='.exe' - built="${PRJ_HOME}/bin/${app_name}-${target_goos}-${target_goarch}${ext}" - GOOS="$target_goos" GOARCH="$target_goarch" go build -ldflags "-s \ - -X main.version=${APP_VERSION} \ - -X main.buildTime=${buildtime} \ - -X main.gitCommit=${git_commit}" \ - -o "$built" \ - "github.com/${GH_OWNER}/${GH_REPO}/cmd/${app_name}" - [[ -e "$built" ]] || { - echo "expected file not found: ${built}" - exit 1 - } - mv "${PRJ_HOME}/bin/${app_name}-${target_goos}-${target_goarch}${ext}" "${platform_dist_dir}/${app_name}${ext}" - # cd "$DIST_DIR" - # zip -r "${platform_dist_basename}.zip" "$platform_dist_basename" - # rm -r "$platform_dist_basename" - done + app_name=$(basename "$dir") + echo " ===== Process ${app_name} ${dir} =====" + for platform in $platforms; do + cd "$PRJ_HOME" + target_goos=$(echo $platform | cut -d/ -f1) + target_goarch=$(echo $platform | cut -d/ -f2) + echo "building for ${target_goos} ${target_goarch}" + platform_dist_basename="${GH_REPO}-${APP_VERSION}_${target_goos}_${target_goarch}" + platform_dist_dir="${DIST_DIR}/${platform_dist_basename}" + mkdir -p "$platform_dist_dir" + ext='' + [[ "windows" = "$target_goos" ]] && ext='.exe' + built="${PRJ_HOME}/bin/${app_name}-${target_goos}-${target_goarch}${ext}" + GOOS="$target_goos" GOARCH="$target_goarch" go build -ldflags "-s \ + -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.version=${APP_VERSION} \ + -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.buildTime=${buildtime} \ + -X github.com/${GH_OWNER}/${GH_REPO}/lib/core.gitCommit=${git_commit}" \ + -o "$built" \ + "github.com/${GH_OWNER}/${GH_REPO}/cmd/${app_name}" + [[ -e "$built" ]] || { + echo "expected file not found: ${built}" + exit 1 + } + mv "${PRJ_HOME}/bin/${app_name}-${target_goos}-${target_goarch}${ext}" "${platform_dist_dir}/${app_name}${ext}" + # cd "$DIST_DIR" + # zip -r "${platform_dist_basename}.zip" "$platform_dist_basename" + # rm -r "$platform_dist_basename" + done done cd "$DIST_DIR" for dir in $(find "$DIST_DIR" -mindepth 1 -maxdepth 1 -type d); do - dist_folder=$(basename "$dir") - echo " ===== Create dist ${dist_folder} ${dir} =====" - zip -r "${dist_folder}.zip" "$dist_folder" - rm -r "$dist_folder" + dist_folder=$(basename "$dir") + echo " ===== Create dist ${dist_folder} ${dir} =====" + zip -r "${dist_folder}.zip" "$dist_folder" + rm -r "$dist_folder" done diff --git a/.sdlc/config b/.sdlc/config index 6fe3aa0..f861c1a 100755 --- a/.sdlc/config +++ b/.sdlc/config @@ -2,4 +2,4 @@ GH_OWNER='enr' GH_REPO='zipp' DIST_DIR='dist' -APP_VERSION='0.5.0' +APP_VERSION='0.5.1' diff --git a/.sdlc/gh-release b/.sdlc/gh-release index c684540..3aa4bdb 100755 --- a/.sdlc/gh-release +++ b/.sdlc/gh-release @@ -16,28 +16,28 @@ git_dirty=$(git status --porcelain) } [[ -z "$GH_TOKEN" ]] && { - echo "Missing GH_TOKEN" - exit 1 + echo "Missing GH_TOKEN" + exit 1 } # https://github.com/tcnksm/ghr/releases/download/v0.5.4/ghr_v0.5.4_linux_amd64.zip command -v ghr >/dev/null || { - echo "ghr not found" - exit 1 + echo "ghr not found" + exit 1 } [[ -z "$GH_OWNER" ]] && { - echo "no gh owner" - exit 1 + echo "no gh owner" + exit 1 } [[ -z "$GH_REPO" ]] && { - echo "no gh repo" - exit 1 + echo "no gh repo" + exit 1 } if [ -z "$APP_VERSION" ]; then - echo 'no release version supplied. $APP_VERSION expected' - exit 1 + echo 'no release version supplied. $APP_VERSION expected' + exit 1 fi RELEASE_VERSION="v$APP_VERSION" @@ -45,9 +45,9 @@ git tag -a "${RELEASE_VERSION}" -m "release version ${RELEASE_VERSION}" git push origin "${RELEASE_VERSION}" if [ "$1" = "--prod" ]; then - PRERELEASE='' + PRERELEASE='' else - PRERELEASE='--prerelease' + PRERELEASE='--prerelease' fi echo "Release $PRJ_HOME version $RELEASE_VERSION $PRERELEASE" @@ -55,8 +55,8 @@ echo "Release $PRJ_HOME version $RELEASE_VERSION $PRERELEASE" "${HACK_DIR}/build-dist" [[ -z "$DIST_DIR" ]] && { - echo "dist directory not found: ${DIST_DIR}" - exit 1 + echo "dist directory not found: ${DIST_DIR}" + exit 1 } #ghr -t "$GH_TOKEN" -u "$GH_OWNER" -r "$GH_REPO" "$PRERELEASE" "$RELEASE_VERSION" "$DIST_DIR" diff --git a/.sdlc/update b/.sdlc/update index ece93f2..50be2d9 100755 --- a/.sdlc/update +++ b/.sdlc/update @@ -10,8 +10,8 @@ PRJ_HOME="$( cd -P "$( dirname "$HACK_DIR" )" && pwd )" cd "$PRJ_HOME" command -v dep >/dev/null || { - echo "dep not found" - exit 1 + echo "dep not found" + exit 1 } dep ensure -update