diff --git a/.VERSION b/.VERSION new file mode 100644 index 00000000..9e11b32f --- /dev/null +++ b/.VERSION @@ -0,0 +1 @@ +0.3.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f6bd7fb..8538e248 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,21 +1,23 @@ -name: Release SDK on GitHub +name: Release Python SDKs on: workflow_dispatch: inputs: version: - description: "Version number" + description: "New version for the SDKs in the format of M.m.p" required: true type: string build_number: - description: "Build number " - required: true - type: string + description: "New build number for the SDKs in the format of Mmmppbb " jobs: prepare-release: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/heads/sdk-core/') # Only run on branches that start with sdk-core/ + # Only run on branches that start with sdk-core/ + if: startsWith(github.ref, 'refs/heads/sdk-core/') + env: + VERSION: ${{ github.event.inputs.version }} + BUILD_NUMBER: ${{ github.event.inputs.build_number }} steps: - name: Checkout the code uses: actions/checkout@v4 @@ -28,22 +30,11 @@ jobs: git_user_signingkey: true git_commit_gpgsign: true - - name: Parse and Validate Inputs - run: | - # Get inputs passed to the workflow - VERSION="${{ github.event.inputs.version }}" - BUILD_NUMBER="${{ github.event.inputs.build_number }}" - - # Save the parsed values for future steps - echo "VERSION=$VERSION" >> $GITHUB_ENV - echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV - shell: bash - - name: Run the Prep Release Script env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - make prep-release VERSION="$VERSION" BUILD_NUMBER="$BUILD_NUMBER" + make prep-release VERSION="{{ env.SDK_VERSION }}" BUILD_NUMBER="{{ env.SDK_BUILD_NUMBER }}" shell: bash build-wheels: @@ -52,6 +43,7 @@ jobs: if: startsWith(github.ref, 'refs/heads/sdk-core/') needs: [prepare-release] strategy: + # we don't want all of them failing if one fails fail-fast: false matrix: # macOS 13 is an Intel runner and macOS 14 is an Apple Silicon runner @@ -66,7 +58,7 @@ jobs: # Need to grab the SDK version for the wheel name - name: Extract SDK Version - run: echo "SDK_VERSION=$(cat version.txt)" >> "$GITHUB_ENV" + run: echo "SDK_VERSION=$(cat .VERSION)" >> "$GITHUB_ENV" shell: bash - name: Install cibuildwheel @@ -75,17 +67,24 @@ jobs: - name: Build wheels env: + # Skip all the unneeded images like PyPy and musllinux images CIBW_SKIP: pp* *-musllinux_* + # Set the manylinux X86_64/aarch64 image to this specific 2.34 image CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux_2_34_x86_64" CIBW_MANYLINUX_AARCH64_IMAGE: "quay.io/pypa/manylinux_2_34_aarch64" + # Set the wheel to the native archtiecture (output of platform.machine() which we use in the setup.py script) CIBW_ARCHS: "native" + # Windows reparing of wheels are not supported so manually install it. CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" + # Dependencies required for testing each wheel CIBW_TEST_REQUIRES: "pydantic pytest pytest-asyncio" + # The minimum MacOS version for darwin wheels (matches OPH) MACOSX_DEPLOYMENT_TARGET: "12.0" + # The command to test every wheel CIBW_TEST_COMMAND: "python -m pytest {project}/src/onepassword/test_client.py" - OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }} - CIBW_ENVIRONMENT_PASS_LINUX: OP_SERVICE_ACCOUNT_TOKEN # We have to specify this to pass the token to the test command + # Pass the service account token in all wheel buildings for testing of the wheels. + CIBW_ENVIRONMENT: OP_SERVICE_ACCOUNT_TOKEN=${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }} run: | python -m cibuildwheel --output-dir dist @@ -105,7 +104,7 @@ jobs: ref: ${{ github.ref }} # Need to grab the SDK version for the wheel name - name: Extract SDK Version - run: echo "SDK_VERSION=$(cat version.txt)" >> "$GITHUB_ENV" + run: echo "SDK_VERSION=$(cat .VERSION)" >> "$GITHUB_ENV" shell: bash - name: Install dependencies @@ -134,7 +133,6 @@ jobs: - name: Checkout the code uses: actions/checkout@v4 with: - fetch-depth: 0 ref: ${{ github.ref }} - name: Import GPG key @@ -161,7 +159,7 @@ jobs: url: https://test.pypi.org/project/onepassword-sdk/ permissions: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing - needs: [release-sdk] + needs: [Release-SDK] steps: - uses: actions/download-artifact@v4 with: @@ -169,6 +167,6 @@ jobs: path: ./dist merge-multiple: true - name: Publish package distributions to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1.12 + uses: pypa/gh-action-pypi-publish@release/v1 with: - repository-url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ diff --git a/pyproject.toml b/pyproject.toml index db4245ac..43d85305 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,18 @@ authors = [{ name = "1Password" }] license = { file = "LICENSE" } readme = "README.md" requires-python = ">=3.9" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Operating System :: MacOS", + "Operating System :: POSIX :: Linux", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "License :: OSI Approved :: MIT License", +] dependencies = [ "pydantic>=2.5", ] @@ -18,4 +30,4 @@ dependencies = [ Homepage = "https://github.com/1Password/onepassword-sdk-python" [tool.setuptools.dynamic] -version = {file = "./version.txt"} \ No newline at end of file +version = {file = "./.VERSION"} diff --git a/src/release/README.md b/src/release/README.md index 8c6d4683..b7e07c7a 100644 --- a/src/release/README.md +++ b/src/release/README.md @@ -1,5 +1,15 @@ -## How to Prepare a Release for the Python SDK +# How to Release the Python SDK +## Release off an Release Candidate Branch in Github Actions +To release the Python SDK via Github Action, you must do the following: +1. SDK core opens a new PR with the latest generated code and latest core. This branch should start off with `sdk-core/...` +2. Add the release notes for the RC as well as update the examples if needed. +3. Run the `Release Python SDKs` action and input the correct build and version number while referencing the RC branch. +4. After the action is completed, the Python SDK is released on Github and PyPi, you can merge the PR branch. + +If the Github Action isn't working, you can follow the manual steps below to release the Python SDK. + +## Manual Steps to release a Python SDK Before running this script, the user must make sure that they have the write permissions to the Python SDK repository. Run this make command to install all dependencies required for the Python SDK release process. @@ -10,7 +20,7 @@ release/install-dependencies Step 1. Make any changes to the SDK as required on a feature branch or main branch. NOTE: If ran on a main branch, a release branch will be created. -Step 2. Go to the root of the repo and run +Step 2. Go to the root of the repo and run ``` make prep-release ``` diff --git a/src/release/scripts/build-wheels.sh b/src/release/scripts/build-wheels.sh index d26fdec4..ef2f25d9 100755 --- a/src/release/scripts/build-wheels.sh +++ b/src/release/scripts/build-wheels.sh @@ -2,8 +2,6 @@ # Helper script to build the required wheels for the Python SDK -output_version_file="version.py" - # The list of python verisons the SDKs release for python_versions=("$@") @@ -15,14 +13,14 @@ macOS_version_x86_64=10.9 macOS_version_arm64=11.0 # Extracts the current verison number for cleanup function -current_version=$(cat version.txt) +current_version=$(cat .VERSION) # Function to execute upon exit cleanup() { echo "Performing cleanup tasks..." # Remove dist and egg-info and the potential release candidate if created rm -r dist src/*.egg-info/ onepassword_sdk-"${current_version}" - exit 1 + exit 1 } # Set the trap to call the cleanup function on exit @@ -44,7 +42,7 @@ build_wheels() { export PYTHON_OS_PLATFORM=$os_platform export PYTHON_MACHINE_PLATFORM=$machine_platform - case "$os_platform" in + case "$os_platform" in Darwin) macos_version= # Min MacOS version for Python 3.13+ is 10.13 diff --git a/src/release/scripts/prep-release.sh b/src/release/scripts/prep-release.sh index 1abb7fbf..dda6e92e 100755 --- a/src/release/scripts/prep-release.sh +++ b/src/release/scripts/prep-release.sh @@ -2,7 +2,7 @@ # Helper script to prepare a release for the Python SDK. -output_version_file="version.txt" +output_version_file=".VERSION" output_build_file="src/onepassword/build_number.py" build_number_template_file="src/release/templates/build_number.tpl.py" @@ -10,8 +10,8 @@ version=$1 build=$2 # Extracts the current build/version number for comparison and backup -current_version=$(cat "$output_version_file" 2>/dev/null || echo "") -current_build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "$output_build_file") +current_version=$(cat "$output_version_file" | tr -d '[:space:]') +current_build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "$output_build_file" | tr -d '[:space:]') # Function to execute upon exit cleanup() { diff --git a/src/release/scripts/release.sh b/src/release/scripts/release.sh index 0fa9b1ca..4aae1ef6 100755 --- a/src/release/scripts/release.sh +++ b/src/release/scripts/release.sh @@ -5,7 +5,8 @@ set -e # Read the contents of the files into variables -version=$(cat "version.txt") +version=$(cat ".VERSION") + build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "src/onepassword/build_number.py") release_notes=$(< src/release/RELEASE-NOTES) diff --git a/version.py b/version.py deleted file mode 100644 index b2637133..00000000 --- a/version.py +++ /dev/null @@ -1 +0,0 @@ -SDK_VERSION = "0.3.0"