Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,25 +84,24 @@ Changes will appear against the [/sdks](sdks) directory. Make sure to include th

### Releasing SDKs

The [copy-sdks](copy-sdks) script copies built SDK files from [/sdks](sdks) into the [/repos](repos) directory, updates version numbers, commits, and pushes a release branch.
The [bake-sdk-release](bake-sdk-release) script copies built SDK files from [/sdks](sdks) into the [/repos](repos) directory, updates version numbers, commits, and pushes a release branch.

You can release a single SDK with an explicit version:

```bash
./copy-sdks -t php -v 1.4.0
./bake-sdk-release -t php -v 1.4.0
```

Or release multiple SDKs at once, with automatic version bumps (reads the current version from `repos/[SDK]/VERSION`):
Or release multiple SDKs at once. Without `-b` or `-v`, the current version from `repos/[SDK]/VERSION` is used as-is:

```bash
./copy-sdks -t python,node,ruby # specific SDKs, auto-bump minor
./copy-sdks -t all # all SDKs, auto-bump minor
./copy-sdks -t all -b patch # all SDKs, auto-bump patch
./copy-sdks -t all -b major # all SDKs, auto-bump major
./copy-sdks -t all -v 2.0.0 # all SDKs, explicit version
./bake-sdk-release -t all # all SDKs, keep current version
./bake-sdk-release -t all -b minor # all SDKs, bump minor
./bake-sdk-release -t all -b patch # all SDKs, bump patch
./bake-sdk-release -t all -v 2.0.0 # all SDKs, explicit version
```

The `-b` flag accepts `major`, `minor` (default), or `patch`.
The `-b` flag accepts `major`, `minor`, or `patch`.

The script shows a summary table of current and new versions and asks for confirmation before proceeding.

Expand Down
49 changes: 30 additions & 19 deletions copy-sdks → bake-sdk-release
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ SDKS=( dotnet java-v1 java-v2 node php python ruby )
SHOW_HELP=0
TARGET_SDK=
TARGET_VERSION=
BUMP_TYPE=minor
BUMP_TYPE=
DRY_RUN=0

REPO_DOTNET="https://github.com/hellosign/dropbox-sign-dotnet.git"
REPO_JAVA_V1="--branch v1 https://github.com/hellosign/dropbox-sign-java.git"
Expand All @@ -19,14 +20,16 @@ REPO_RUBY="https://github.com/hellosign/dropbox-sign-ruby.git"

REPO_MAIN_BRANCH="main"

while getopts ":t:v:b:h" opt; do
while getopts ":t:v:b:dh" opt; do
case $opt in
t) TARGET_SDK="$OPTARG"
;;
v) TARGET_VERSION="$OPTARG"
;;
b) BUMP_TYPE="$OPTARG"
;;
d) DRY_RUN=1
;;
h) SHOW_HELP=1
;;
\?) echo "Invalid option -$OPTARG" >&2
Expand Down Expand Up @@ -95,8 +98,10 @@ function main() {

if [[ -n "${TARGET_VERSION}" ]]; then
versions+=("${TARGET_VERSION}")
else
elif [[ -n "${BUMP_TYPE}" ]]; then
versions+=("$(bump_version "$current_ver" "$BUMP_TYPE")")
else
versions+=("${current_ver}")
fi
done

Expand Down Expand Up @@ -136,7 +141,7 @@ function main() {

function show_help() {
cat << EOF
Usage: copy-sdks [OPTION]
Usage: bake-sdk-release [OPTION]
Copies build files for a given SDK into the repos/[SDK] directory.

**WARNING** All files and directories present in the repos/[SDK] directory will
Expand All @@ -146,15 +151,17 @@ Copies build files for a given SDK into the repos/[SDK] directory.
valid: dotnet, java-v1, java-v2, node, php, python, ruby, all
-v version of the SDK, ex: 1.4.0
if omitted, auto-bumps version from repos/[SDK]/VERSION
-b bump type when -v is omitted: major, minor (default), or patch
-b bump version: major, minor, or patch
if omitted, uses current version from repos/[SDK]/VERSION
-d dry run: copy files and update versions but skip commit and push
-h display this help and exit

Examples:
copy-sdks -t php -v 1.4.0 # single SDK, explicit version
copy-sdks -t python,node,ruby # multiple SDKs, auto-bump minor
copy-sdks -t all # all SDKs, auto-bump minor
copy-sdks -t all -b patch # all SDKs, auto-bump patch
copy-sdks -t all -v 2.0.0 # all SDKs, same explicit version
bake-sdk-release -t php -v 1.4.0 # single SDK, explicit version
bake-sdk-release -t all -b minor # all SDKs, bump minor
bake-sdk-release -t all -b patch # all SDKs, bump patch
bake-sdk-release -t all # all SDKs, keep current version
bake-sdk-release -t python,node,ruby # specific SDKs, keep current version
EOF

exit 0
Expand Down Expand Up @@ -193,10 +200,12 @@ function copy_files()
printf "Copying built files for the ${SDK} SDK to ${SDK_DIR}\n"
pushd "${SDK_DIR}/"

git reset --hard origin/${REPO_MAIN_BRANCH}
git pull origin ${REPO_MAIN_BRANCH}
git checkout "release-${VERSION}" 2>/dev/null || git checkout -b "release-${VERSION}"
git rm -rf --cached .
git fetch origin
git checkout "release-${VERSION}" 2>/dev/null || {
git checkout ${REPO_MAIN_BRANCH}
git reset --hard origin/${REPO_MAIN_BRANCH}
git checkout -b "release-${VERSION}"
}

popd

Expand All @@ -207,8 +216,6 @@ function copy_files()

pushd "${SDK_DIR}/"

git add .

rm -f "${SDK_DIR}/openapi-sdk.yaml"
rm -rf "${SDK_DIR}/examples"
mkdir -p "${SDK_DIR}/examples"
Expand All @@ -233,9 +240,13 @@ function copy_files()

php "${DIR}/bin/update-sdk-version.php" ${SDK} ${VERSION}

git add -A
git commit -m "Release ${VERSION}"
git push -u origin "release-${VERSION}"
if [[ "${DRY_RUN}" -eq 0 ]]; then
git add -A
git commit -m "Release ${VERSION}"
git push -u origin "release-${VERSION}"
else
printf "Dry run: skipping commit and push for %s\n" "$SDK"
fi

popd
}
Expand Down
4 changes: 4 additions & 0 deletions bin/copy-examples-filtered
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ for FILE in "${SRC_DIR}"/*."${EXT}"; do
[ -f "$FILE" ] || continue
BASENAME=$(basename "$FILE" ".$EXT")

if [[ "$BASENAME" != *Example ]]; then
continue
fi

SKIP=0
for PASCAL in "${HIDDEN_PASCALS[@]}"; do
if [ "$BASENAME" = "${PASCAL}Example" ]; then
Expand Down
Loading