|
3 | 3 | # Helper script to prepare a release for the Python SDK. |
4 | 4 |
|
5 | 5 | output_version_file="version.py" |
| 6 | +output_build_file="src/onepassword/build_number.py" |
6 | 7 | version_template_file="src/release/templates/version.tpl.py" |
| 8 | +build_number_template_file="src/release/templates/build_number.tpl.py" |
7 | 9 |
|
8 | | -# The list of python verisons the SDKs release for |
9 | | -python_versions=("$@") |
10 | | - |
11 | | -# Minimum glibc version we support |
12 | | -glibc_version=2-32 |
13 | | - |
14 | | -# These versions are being supported due to the SDKs supporting Python 3.9+ |
15 | | -macOS_version_x86_64=10.9 |
16 | | -macOS_version_arm64=11.0 |
17 | 10 |
|
18 | 11 | # Extracts the current build/version number for comparison and backup |
19 | 12 | current_version=$(awk -F "['\"]" '/SDK_VERSION =/{print $2}' "$output_version_file") |
| 13 | +current_build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "$output_build_file") |
20 | 14 |
|
21 | 15 | # Function to execute upon exit |
22 | 16 | cleanup() { |
23 | 17 | echo "Performing cleanup tasks..." |
24 | 18 | # Revert changes to file if any |
25 | 19 | sed -e "s/{{ version }}/$current_version/" "$version_template_file" > "$output_version_file" |
| 20 | + sed -e "s/{{ build }}/$current_build/" "$build_number_template_file" > "$output_build_file" |
26 | 21 | exit 1 |
27 | 22 | } |
28 | 23 |
|
@@ -59,61 +54,42 @@ update_and_validate_version() { |
59 | 54 | done |
60 | 55 | } |
61 | 56 |
|
62 | | -build_wheels() { |
63 | | - os_platform=$1 |
64 | | - machine_platform=$2 |
65 | | - |
66 | | - export PYTHON_OS_PLATFORM=$os_platform |
67 | | - export PYTHON_MACHINE_PLATFORM=$machine_platform |
68 | | - |
69 | | - case "$os_platform" in |
70 | | - Darwin) |
71 | | - macos_version= |
72 | | - if [[ "$machine_platform" == "x86_64" ]]; then |
73 | | - macos_version=$macOS_version_x86_64 |
| 57 | +# Function to validate the build number format. |
| 58 | +# SEMVER Format: Mmmppbb - 7 Digits |
| 59 | +update_and_validate_build() { |
| 60 | + while true; do |
| 61 | + # Prompt the user to input the build number |
| 62 | + read -p "Enter the build number (format: Mmmppbb): " build |
| 63 | + |
| 64 | + # Validate the build number format |
| 65 | + if [[ "${build}" =~ ^[0-9]{7}$ ]]; then |
| 66 | + if (( 10#$current_build < 10#$build )); then |
| 67 | + # Write the valid build number to the file |
| 68 | + echo "New build number is: ${build}" |
| 69 | + return 0 |
74 | 70 | else |
75 | | - macos_version=$macOS_version_arm64 |
76 | | - fi |
77 | | - |
78 | | - export _PYTHON_HOST_PLATFORM="macosx-${macos_version}-${PYTHON_MACHINE_PLATFORM}" |
79 | | - ;; |
80 | | - Linux) |
81 | | - export _PYTHON_HOST_PLATFORM="manylinux-${glibc_version}-${PYTHON_MACHINE_PLATFORM}" |
82 | | - ;; |
83 | | - Windows) |
84 | | - export _PYTHON_HOST_PLATFORM="win-${PYTHON_MACHINE_PLATFORM}" |
85 | | - ;; |
86 | | - *) |
87 | | - echo "Unsupported OS: $os_platform" |
88 | | - exit 1 |
89 | | - ;; |
90 | | - esac |
91 | | - |
92 | | - pyenv exec python setup.py bdist_wheel |
93 | | - rm -rf build |
| 71 | + echo "New build version should be higher than current build version." |
| 72 | + fi |
| 73 | + else |
| 74 | + echo "Invalid build number format: ${build}" |
| 75 | + echo "Please enter a build number in the 'Mmmppbb' format." |
| 76 | + fi |
| 77 | + done |
94 | 78 | } |
95 | 79 |
|
96 | | -# Ensure working directory is clean |
| 80 | +# Ensure that the current working directory is clean |
97 | 81 | enforce_latest_code |
98 | 82 |
|
99 | 83 | # Update and validate the version number |
100 | 84 | update_and_validate_version |
101 | 85 |
|
102 | | -# Update version in version.py |
| 86 | +# Update and validate the build number |
| 87 | +update_and_validate_build |
| 88 | + |
| 89 | +# Update version & build number in version.py and build_number.py respectively |
103 | 90 | sed -e "s/{{ version }}/$version/" "$version_template_file" > "$output_version_file" |
| 91 | +sed -e "s/{{ build }}/$build/" "$build_number_template_file" > "$output_build_file" |
104 | 92 |
|
105 | | -# Acquire the wheels for different OS |
106 | | -for python_version in "${python_versions[@]}"; do |
107 | | -pyenv local $python_version |
108 | | -build_wheels Darwin x86_64 |
109 | | -build_wheels Darwin arm64 |
110 | | -build_wheels Linux x86_64 |
111 | | -build_wheels Linux aarch64 |
112 | | -build_wheels Windows amd64 |
113 | | -done |
114 | | - |
115 | | -# Build Source as well incase wheels fails, pypi can install this as backup (standard practice) |
116 | | -python3 -m build --sdist |
117 | 93 |
|
118 | 94 | printf "Press ENTER to edit the RELEASE-NOTES in your default editor...\n" |
119 | 95 | read -r _ignore |
|
0 commit comments