Skip to content

Add Automation of Python SDK Release Process. #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 64 commits into
base: main
Choose a base branch
from

Conversation

MOmarMiraj
Copy link
Contributor

@MOmarMiraj MOmarMiraj commented Apr 3, 2025

This PR will automate our python wheel building and publishing to PyPi to a GitHub action. This action will run when the RC branches are merged. This has been tested on the fork of my branch here.

I kept the build-wheels.sh script as fallback incase the action ever breaks and we need to run it manually.

On the Test RC MR below, you will see that the pipeline had the option to add release notes. I opted to remove that as GitHub's workflow manual job doesn't accept multiline strings whether its in the workflow dispatch or we grab it from the comments its a lot of workarounds and will make it messy. I feel like it will be easier to manually commit release notes.

The nice thing is the prep and release SDK flow can be incorporated into the Go SDK as well as the JS SDK.

Heres the MOmarMiraj#50 that I have on my fork which runs through this whole flow.

These are the specific jobs:
Release the SDKs on GitHub - https://github.com/MOmarMiraj/onepassword-sdk-python/actions/runs/14983407609

The workflow will be as follows:

Add the release notes manually (adding the release notes with correct markdown is very difficult for some reason so didn't include this in the prep workflow)
Run the release workflow manual on the RC branch which will build and publish on pypi aswell and increment the build and version number.
Our old flow was
make prep-release which would input the version + build + release notes (usually we would just skip this and add it manual)
make build-wheels this would build all the wheels (but build it very incorrectly and it wouldn't work correctly)
make release, we would also need to export our github token and have the pypi API token to publish on PyPi.

Dependencies Required for this PR to work:

  1. Upload GPG_SECRET_KEY and PASS_PHRASE to the repository to be able to have signed commits when we have the prep-release and release workflows.
  2. Upload a PAT on the checkout action of the commiting actions to properly sign the commits.
  3. Fix the binaries that we have to have a minimum MacOS Deployment Target of 12.0

@MOmarMiraj MOmarMiraj added the enhancement New feature or request label Apr 3, 2025
@MOmarMiraj MOmarMiraj requested a review from hculea April 3, 2025 21:13
@MOmarMiraj MOmarMiraj self-assigned this Apr 3, 2025
Comment on lines 26 to 29
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whose GPG key is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the private key of the bot that we will add to the secrets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify which fields exactly you would expect to have in the GitHub Secrets? i.e. the key & value for the secret.

As well as any other dependencies that we should take care of before merging this MR - would be nice to have a Dependencies section in the PR description.

Copy link
Contributor Author

@MOmarMiraj MOmarMiraj May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Github secrets would have to have the GPG secret key from the bot we expect to push the release. Similar to how it is here, it would be GPG_PRIVATE_KEY as the key and the value would be the actual GPG key. Yes I can add that dependencies in the PR section.

Copy link
Member

@edif2008 edif2008 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look ok and I've looked at the linked workflows to see what's going on.

What's missing for me is how will a release process look like once these changes are in. What does the flow look like? Based on that I can easily identify if we've complicated some parts or not.

For example, I don't really understand the purpose of prep-release workflow. If it's manual, what does it add compared to how we do a release prep now? 🤔

@MOmarMiraj
Copy link
Contributor Author

MOmarMiraj commented Apr 25, 2025

Changes look ok and I've looked at the linked workflows to see what's going on.

What's missing for me is how will a release process look like once these changes are in. What does the flow look like? Based on that I can easily identify if we've complicated some parts or not.

For example, I don't really understand the purpose of prep-release workflow. If it's manual, what does it add compared to how we do a release prep now? 🤔

The workflow will be as follows:

  1. Run the Github Action Prep Release by inputting new version + build
  2. Add the release notes manually (adding the release notes with correct markdown is very difficult for some reason so didn't include this in the prep workflow)
  3. Run the release workflow manual on the RC branch
  4. Merge the PR and the Python Wheels + publish on PyPi will be ran automatically on merge of the RC branch.

Our old flow was
make prep-release which would input the version + build + release notes (usually we would just skip this and add it manual)
make build-wheels this would build all the wheels (but build it very incorrectly and it wouldn't work correctly)
make release, we would also need to export our github token and have the pypi API token to publish on pypi.

The prep workflow is kind of over complicated now that I see, what if remove the prep workflow and keep the make prep-release script and then keep the other two flows WDYT?

EDIT: This has been updated so please look at the description for the latest flow.

@hculea
Copy link
Member

hculea commented May 8, 2025

Changes look ok and I've looked at the linked workflows to see what's going on.
What's missing for me is how will a release process look like once these changes are in. What does the flow look like? Based on that I can easily identify if we've complicated some parts or not.
For example, I don't really understand the purpose of prep-release workflow. If it's manual, what does it add compared to how we do a release prep now? 🤔

The workflow will be as follows:

  1. Run the Github Action Prep Release by inputting new version + build
  2. Add the release notes manually (adding the release notes with correct markdown is very difficult for some reason so didn't include this in the prep workflow)
  3. Run the release workflow manual on the RC branch
  4. Merge the PR and the Python Wheels + publish on PyPi will be ran automatically on merge of the RC branch.

Our old flow was make prep-release which would input the version + build + release notes (usually we would just skip this and add it manual) make build-wheels this would build all the wheels (but build it very incorrectly and it wouldn't work correctly) make release, we would also need to export our github token and have the pypi API token to publish on pypi.

The prep workflow is kind of over complicated now that I see, what if remove the prep workflow and keep the make prep-release script and then keep the other two flows WDYT?

Can we change the release docs to capture this? We want to make sure they are up to date with the latest process.

@hculea
Copy link
Member

hculea commented May 12, 2025

@MOmarMiraj I still don't see the release process documented anywhere.

We have instructions in src/release/README.md, I would like us to update those as well.

@hculea
Copy link
Member

hculea commented May 12, 2025

What's the reasoning behind still requiring to run two different manual jobs to get the thing working?

I envision the flow to look like this:

  • SDK core opens a new PR with the latest generated code and latest core
  • we come in the branch and add examples + RELEASE NOTES
  • we trigger a workflow that releases to GitHub and PyPI
  • we merge the PR

WDYT?

@edif2008
Copy link
Member

What is the likelyhood of the release process to not succeed?
I ask because it might be worth swapping the last two steps and trigger the pipeline on main when a merge from an sdk-release branch happened.

@MOmarMiraj
Copy link
Contributor Author

What is the likelyhood of the release process to not succeed? I ask because it might be worth swapping the last two steps and trigger the pipeline on main when a merge from an sdk-release branch happened.

Very rarely the Python release scripts fail, I think what horia recommended is fine and will implement that. Only JS can get finnicky sometimes but that is out of scope for now.

… update the logic as well as update the release readme.
@MOmarMiraj
Copy link
Contributor Author

MOmarMiraj commented May 12, 2025

  • SDK core opens a new PR with the latest generated code and latest core
  • we come in the branch and add examples + RELEASE NOTES
  • we trigger a workflow that releases to GitHub and PyPI
  • we merge the PR

I updated the release/readme.md with the new updated notes.

What's the reasoning behind still requiring to run two different manual jobs to get the thing working?

I envision the flow to look like this:

SDK core opens a new PR with the latest generated code and latest core
we come in the branch and add examples + RELEASE NOTES
we trigger a workflow that releases to GitHub and PyPI
we merge the PR

You are right, we can make this simplification and this has been done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants