Skip to content

Commit

Permalink
sdlc scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
enr committed Aug 1, 2018
1 parent 1b8d5c9 commit 7db84dc
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 59 deletions.
16 changes: 8 additions & 8 deletions .sdlc/build
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 34 additions & 34 deletions .sdlc/build-dist
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
2 changes: 1 addition & 1 deletion .sdlc/config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ GH_OWNER='enr'
GH_REPO='zipp'
DIST_DIR='dist'

APP_VERSION='0.5.0'
APP_VERSION='0.5.1'
28 changes: 14 additions & 14 deletions .sdlc/gh-release
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,47 @@ 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"
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"

"${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"
Expand Down
4 changes: 2 additions & 2 deletions .sdlc/update
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7db84dc

Please sign in to comment.