Skip to content

Commit

Permalink
Added release script.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshasa committed Dec 28, 2021
1 parent 396bb84 commit 0e1fd5d
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ http://trackers.transamrit.net:8082/announce

real 0m0.523s
user 0m0.375s
sys 0m0.374s
sys 0m0.374s
```

Replace the announce urls and overwrite the source files for all 10,000 torrents:
Expand Down
38 changes: 30 additions & 8 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,33 @@

set -eux

TARGET_OS="${TARGET_OS:-linux}"
TARGET_ARCH="${TARGET_ARCH:-amd64}"
BUILD_IMAGE="${BUILD_IMAGE:-build-env}"
BUILD_MARKDOWN="${BUILD_MARKDOWN:-no}"
BUILD_DOCS="${BUILD_DOCS:-no}"
BUILD_DIR="${BUILD_DIR:-./build}"

TARGET_OS="${TARGET_OS:-}"
TARGET_ARCH="${TARGET_ARCH:-amd64}"

case "${TARGET_OS:-}" in
darwin|linux)
echo "TARGET_OS=${TARGET_OS}"
;;
"")
if [[ ${OSTYPE} =~ ^darwin ]]; then
TARGET_OS=darwin
elif [[ ${OSTYPE} =~ ^linux-gnu ]]; then
TARGET_OS=linux
else
echo "could not detect a valid taret OS"
exit 1
fi
;;
*)
echo "unknown target OS: ${TARGET_OS}"
exit 1
;;
esac

if [[ "${BUILD_DOCS}" == "yes" ]]; then
BUILD_MARKDOWN="yes"
Expand Down Expand Up @@ -93,23 +115,23 @@ build_dir=$(mktemp -d); readonly build_dir
--name "${container}" \
"${rbedit_image}"

mkdir -p ./build/
docker cp "${container}:/rbedit-${TARGET_OS}-${TARGET_ARCH}" ./build/
mkdir -p "${BUILD_DIR}/"
docker cp "${container}:/rbedit-${TARGET_OS}-${TARGET_ARCH}" "${BUILD_DIR}/"

if [[ "${BUILD_MARKDOWN}" == "yes" ]]; then
docker cp "${container}:/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" ./build/
docker cp "${container}:/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" "${BUILD_DIR}/"
fi

if [[ "${BUILD_DOCS}" == "yes" ]]; then
if ! "./build/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" &> /dev/null; then
echo "could not run ./build/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}"
if ! "${BUILD_DIR}/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" &> /dev/null; then
echo "could not run ${BUILD_DIR}/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}"
exit 1
fi

rm -rf ./docs/cli
mkdir -p ./docs/cli

"./build/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" ./docs/cli
"${BUILD_DIR}/rbedit-markdown-${TARGET_OS}-${TARGET_ARCH}" ./docs/cli

git add ./docs/cli
fi
Expand Down
52 changes: 52 additions & 0 deletions scripts/generate-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

set -eux

project_root="$(cd "$(cd "$( dirname "${BASH_SOURCE[0]}" )" && git rev-parse --show-toplevel)" >/dev/null 2>&1 && pwd)"
readonly project_root

readonly container="rtdo-build-rbedit"
readonly rbedit_image="rtdo/rbedit"

cleanup() {
local -r retval="$?"
set +eux

if (( retval == 0 )); then
echo
echo "*************************"
echo "*** Release Succeeded ***"
echo "*************************"
echo
else
echo
echo "**********************"
echo "*** Release Failed ***"
echo "**********************"
echo
fi

exit "${retval}"
}
trap cleanup EXIT

build_dir="$(mktemp -d)"

( cd "${project_root}"

BUILD_DOCS=yes ./scripts/build.sh

BUILD_DIR="${build_dir}" TARGET_OS=linux ./scripts/build.sh
BUILD_DIR="${build_dir}" TARGET_OS=darwin ./scripts/build.sh
)

( cd "${build_dir}"; ls .

zip rbedit-darwin-amd64.zip rbedit-darwin-amd64
zip rbedit-linux-amd64.zip rbedit-linux-amd64
)

set +x

printf "\n%s" "${build_dir}/"*
printf "\n"

0 comments on commit 0e1fd5d

Please sign in to comment.