From a5775cd5bc85d8d7118668c883fd10414f81626e Mon Sep 17 00:00:00 2001 From: Andrzej Danilowski Date: Tue, 12 May 2026 16:20:14 +0200 Subject: [PATCH 1/2] [SIGN-15354] Improve releasing SDKs --- README.md | 30 ++++++++++++++ copy-sdks | 118 +++++++++++++++++++++++++++++++++++++++++++++-------- reset-sdks | 40 ++++++++++++++++++ 3 files changed, 171 insertions(+), 17 deletions(-) create mode 100755 reset-sdks diff --git a/README.md b/README.md index f55872138..9ed050736 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,36 @@ To rebuild all SDKs run `./generate-sdks -t all`. Changes will appear against the [/sdks](sdks) directory. Make sure to include these changes in your pull requests! +### 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. + +You can release a single SDK with an explicit version: + +```bash +./copy-sdks -t php -v 1.4.0 +``` + +Or release multiple SDKs at once, with automatic minor version bumps (reads the current version from `repos/[SDK]/VERSION`): + +```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 -v 2.0.0 # all SDKs, explicit version +``` + +The script shows a summary table of current and new versions and asks for confirmation before proceeding. + +### Resetting SDK Repos + +The [reset-sdks](reset-sdks) script resets SDK repos in [/repos](repos) back to their main branch (pulling latest from origin). Useful before starting a new release cycle. + +```bash +./reset-sdks # reset all SDK repos +./reset-sdks ruby # reset a single SDK +./reset-sdks python,node,ruby # reset specific SDKs +``` + ### Changes to Generated SDK Code We generate our SDKs using the [OpenAPI Generator](https://openapi-generator.tech/) tool. This tool reads the contents of the [openapi-sdk.yaml](openapi-sdk.yaml) file. It also reads related examples from the [/examples](examples) directory and embeds the contents into the generated documentation. diff --git a/copy-sdks b/copy-sdks index 2fffe8b51..38dbd7693 100755 --- a/copy-sdks +++ b/copy-sdks @@ -31,17 +31,92 @@ while getopts ":t:v:h" opt; do esac done +function get_current_version() +{ + local sdk="$1" + local version_file="${DIR}/repos/${sdk}/VERSION" + + if [[ ! -f "${version_file}" ]]; then + printf "ERROR: VERSION file not found at %s\n" "${version_file}" >&2 + exit 1 + fi + + grep -oE '[0-9]+\.[0-9]+\.[0-9]+' "${version_file}" | head -1 +} + +function bump_minor_version() +{ + local current="$1" + local major minor + major=$(echo "$current" | cut -d. -f1) + minor=$(echo "$current" | cut -d. -f2) + echo "${major}.$((minor + 1)).0" +} + function main() { - if [[ -z ${TARGET_SDK} || -z ${TARGET_VERSION} ]]; then + if [[ -z ${TARGET_SDK} ]]; then show_help + exit 0 + fi + + # Parse target SDKs: "all", comma-separated, or single + local sdk_list=() + if [[ "${TARGET_SDK}" == "all" ]]; then + sdk_list=("${SDKS[@]}") + else + IFS=',' read -ra sdk_list <<< "${TARGET_SDK}" + fi + for sdk in "${sdk_list[@]}"; do + validate_sdk_choice "$sdk" + done + + # Resolve versions and build summary + local versions=() + local current_versions=() + for sdk in "${sdk_list[@]}"; do + local current_ver + current_ver=$(get_current_version "$sdk") + current_versions+=("$current_ver") + + if [[ -n "${TARGET_VERSION}" ]]; then + versions+=("${TARGET_VERSION}") + else + versions+=("$(bump_minor_version "$current_ver")") + fi + done + + # Show summary table + printf "\n%-12s %-15s %-15s\n" "SDK" "Current" "New Version" + printf "%-12s %-15s %-15s\n" "---" "-------" "-----------" + for i in "${!sdk_list[@]}"; do + printf "%-12s %-15s %-15s\n" "${sdk_list[$i]}" "${current_versions[$i]}" "${versions[$i]}" + done + printf "\n" + + read -p "Proceed? [y/N] " confirm + if [[ "${confirm}" != "y" && "${confirm}" != "Y" ]]; then + printf "Aborted.\n" exit 0 fi - validate_sdk_choice $TARGET_SDK - copy_files $TARGET_SDK $TARGET_VERSION + # Process each SDK + for i in "${!sdk_list[@]}"; do + local sdk="${sdk_list[$i]}" + local ver="${versions[$i]}" + + printf "\n=== Processing %s %s ===\n" "$sdk" "$ver" + + REPO_MAIN_BRANCH="main" + if [[ "${sdk}" == "java-v1" ]]; then + REPO_MAIN_BRANCH="v1" + fi + + copy_files "$sdk" "$ver" + printf "Done: %s %s\n" "$sdk" "$ver" + done - printf "Success! Ready for git commit!\n" + printf "\nSuccess! All SDKs committed and pushed.\n" exit 0 } @@ -53,10 +128,17 @@ Copies build files for a given SDK into the repos/[SDK] directory. **WARNING** All files and directories present in the repos/[SDK] directory will be DELETED, except for the .git directory! --t target SDK, "dotnet", "java-v2", "java-v1", "node", "php", "python", "ruby" +-t target SDK(s): a single SDK, comma-separated list, or "all" + valid: dotnet, java-v1, java-v2, node, php, python, ruby, all -v version of the SDK, ex: 1.4.0 + if omitted, auto-bumps minor version from repos/[SDK]/VERSION -h display this help and exit -Example: copy-sdks -t php -v 1.4.0 + +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 -v 2.0.0 # all SDKs, same explicit version EOF exit 0 @@ -80,10 +162,6 @@ function validate_sdk_choice() exit 1 fi - - if [[ "${SDK}" == "java-v1" ]]; then - REPO_MAIN_BRANCH="v1" - fi } function copy_files() @@ -101,7 +179,7 @@ function copy_files() git reset --hard origin/${REPO_MAIN_BRANCH} git pull origin ${REPO_MAIN_BRANCH} - git checkout -b "release-${VERSION}" + git checkout "release-${VERSION}" 2>/dev/null || git checkout -b "release-${VERSION}" git rm -rf --cached . popd @@ -121,22 +199,28 @@ function copy_files() cp -r "${DIR}/openapi-sdk.yaml" "${SDK_DIR}/openapi-sdk.yaml" + local EXAMPLES_SRC="${DIR}/sdks/${SDK}/examples" + if [[ "${SDK}" == "dotnet" ]]; then - "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" cs + "${DIR}/bin/copy-examples-filtered" "${EXAMPLES_SRC}" "${SDK_DIR}/examples" cs elif [[ "${SDK}" == "java-v2" ]] || [[ "${SDK}" == "java-v1" ]]; then - "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" java + "${DIR}/bin/copy-examples-filtered" "${EXAMPLES_SRC}" "${SDK_DIR}/examples" java elif [[ "${SDK}" == "node" ]]; then - "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" ts + "${DIR}/bin/copy-examples-filtered" "${EXAMPLES_SRC}" "${SDK_DIR}/examples" ts elif [[ "${SDK}" == "php" ]]; then - "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" php + "${DIR}/bin/copy-examples-filtered" "${EXAMPLES_SRC}" "${SDK_DIR}/examples" php elif [[ "${SDK}" == "python" ]]; then - "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" py + "${DIR}/bin/copy-examples-filtered" "${EXAMPLES_SRC}" "${SDK_DIR}/examples" py elif [[ "${SDK}" == "ruby" ]]; then - "${DIR}/bin/copy-examples-filtered" "${DIR}/examples" "${SDK_DIR}/examples" rb + "${DIR}/bin/copy-examples-filtered" "${EXAMPLES_SRC}" "${SDK_DIR}/examples" rb fi php "${DIR}/bin/update-sdk-version.php" ${SDK} ${VERSION} + git add -A + git commit -m "Release ${VERSION}" + git push -u origin "release-${VERSION}" + popd } diff --git a/reset-sdks b/reset-sdks new file mode 100755 index 000000000..5a837ca74 --- /dev/null +++ b/reset-sdks @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +set -e + +DIR=$(cd `dirname $0` && pwd) +ALL_SDKS=( dotnet java-v1 java-v2 node php python ruby ) +TARGET="${1:-all}" + +if [[ "${TARGET}" == "all" ]]; then + SDKS=("${ALL_SDKS[@]}") +else + IFS=',' read -ra SDKS <<< "${TARGET}" +fi + +for SDK in "${SDKS[@]}"; do + SDK_DIR="${DIR}/repos/${SDK}" + BRANCH="main" + + if [[ "${SDK}" == "java-v1" ]]; then + BRANCH="v1" + fi + + if [[ ! -d "${SDK_DIR}/.git" ]]; then + printf "SKIP: %s (not cloned at %s)\n" "$SDK" "$SDK_DIR" + continue + fi + + printf "Resetting %s to %s...\n" "$SDK" "$BRANCH" + pushd "${SDK_DIR}/" > /dev/null + + git checkout "$BRANCH" + git reset --hard "origin/${BRANCH}" + git pull origin "$BRANCH" + git fetch --prune + + popd > /dev/null + printf "Done: %s\n\n" "$SDK" +done + +printf "All SDK repos reset.\n" From f97b0277f8bba1fcd2b97db64ee0de30732eca1d Mon Sep 17 00:00:00 2001 From: Andrzej Danilowski Date: Tue, 12 May 2026 16:25:26 +0200 Subject: [PATCH 2/2] [SIGN-15354] Allow switching between minor/major/patch bump --- README.md | 6 +++++- copy-sdks | 28 ++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9ed050736..b31036e6a 100644 --- a/README.md +++ b/README.md @@ -92,14 +92,18 @@ You can release a single SDK with an explicit version: ./copy-sdks -t php -v 1.4.0 ``` -Or release multiple SDKs at once, with automatic minor version bumps (reads the current version from `repos/[SDK]/VERSION`): +Or release multiple SDKs at once, with automatic version bumps (reads the current version from `repos/[SDK]/VERSION`): ```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 ``` +The `-b` flag accepts `major`, `minor` (default), or `patch`. + The script shows a summary table of current and new versions and asks for confirmation before proceeding. ### Resetting SDK Repos diff --git a/copy-sdks b/copy-sdks index 38dbd7693..34f1186cd 100755 --- a/copy-sdks +++ b/copy-sdks @@ -7,6 +7,7 @@ SDKS=( dotnet java-v1 java-v2 node php python ruby ) SHOW_HELP=0 TARGET_SDK= TARGET_VERSION= +BUMP_TYPE=minor REPO_DOTNET="https://github.com/hellosign/dropbox-sign-dotnet.git" REPO_JAVA_V1="--branch v1 https://github.com/hellosign/dropbox-sign-java.git" @@ -18,12 +19,14 @@ REPO_RUBY="https://github.com/hellosign/dropbox-sign-ruby.git" REPO_MAIN_BRANCH="main" -while getopts ":t:v:h" opt; do +while getopts ":t:v:b:h" opt; do case $opt in t) TARGET_SDK="$OPTARG" ;; v) TARGET_VERSION="$OPTARG" ;; + b) BUMP_TYPE="$OPTARG" + ;; h) SHOW_HELP=1 ;; \?) echo "Invalid option -$OPTARG" >&2 @@ -44,13 +47,24 @@ function get_current_version() grep -oE '[0-9]+\.[0-9]+\.[0-9]+' "${version_file}" | head -1 } -function bump_minor_version() +function bump_version() { local current="$1" - local major minor + local type="$2" + local major minor patch major=$(echo "$current" | cut -d. -f1) minor=$(echo "$current" | cut -d. -f2) - echo "${major}.$((minor + 1)).0" + patch=$(echo "$current" | cut -d. -f3) + + case "$type" in + major) echo "$((major + 1)).0.0" ;; + minor) echo "${major}.$((minor + 1)).0" ;; + patch) echo "${major}.${minor}.$((patch + 1))" ;; + *) + printf "Invalid bump type: %s (must be major, minor, or patch)\n" "$type" >&2 + exit 1 + ;; + esac } function main() { @@ -82,7 +96,7 @@ function main() { if [[ -n "${TARGET_VERSION}" ]]; then versions+=("${TARGET_VERSION}") else - versions+=("$(bump_minor_version "$current_ver")") + versions+=("$(bump_version "$current_ver" "$BUMP_TYPE")") fi done @@ -131,13 +145,15 @@ Copies build files for a given SDK into the repos/[SDK] directory. -t target SDK(s): a single SDK, comma-separated list, or "all" valid: dotnet, java-v1, java-v2, node, php, python, ruby, all -v version of the SDK, ex: 1.4.0 - if omitted, auto-bumps minor version from repos/[SDK]/VERSION + if omitted, auto-bumps version from repos/[SDK]/VERSION +-b bump type when -v is omitted: major, minor (default), or patch -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 EOF