-
Notifications
You must be signed in to change notification settings - Fork 15
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
base: main
Are you sure you want to change the base?
Changes from all commits
88398fb
8eac2b7
c2627e6
ea82680
9742677
16a9cb4
cd8b06f
6f659f6
deaeb15
efe387e
670175f
3ad27e9
5e84ed0
35d2f0d
67edcbb
145758d
f316654
881497d
f7a1083
1cc21ce
f94d10b
c777afd
521efd0
bacb8c7
efc4ed4
8f19e0d
1a3e9bb
e3ffc3e
ea0c161
fce070e
8bba2eb
028d32b
2e6941f
4e944bd
cd9b562
98f4832
8bf9ccb
e88f750
976c276
2a09d16
1fc3895
c3f0211
cc5cf76
5690c32
2345ad1
a16e535
94fe548
1a487ca
f7b1d8c
3593dfb
212f8a6
fa1c3ec
314cdc7
a004bf2
43548d1
2474110
5750b30
95c3aee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Prep Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: "Version number:" | ||
required: true | ||
type: string | ||
build_number: | ||
description: "Build number:" | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
if: startsWith(github.ref, 'refs/heads/sdk-core/') # Only run on branches that start with sdk-core/ | ||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Import GPG key | ||
uses: crazy-max/ghaction-import-gpg@v6 | ||
with: | ||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
git_user_signingkey: true | ||
git_commit_gpgsign: true | ||
git_tag_gpgsign: true | ||
|
||
- name: Setup Git User | ||
run: | | ||
git config user.name "$GITHUB_ACTOR" | ||
git config user.email "[email protected]" | ||
|
||
- name: Parse and Validate Inputs | ||
id: get_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" | ||
shell: bash |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||
name: Release SDK | ||||||
|
||||||
on: | ||||||
workflow_dispatch: | ||||||
|
||||||
jobs: | ||||||
Release-SDK: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think a better common pattern for job names is kebab-case:
Suggested change
|
||||||
runs-on: ubuntu-latest | ||||||
if: startsWith(github.ref, 'refs/heads/sdk-core/') # Only run on branches that start with sdk-core/ | ||||||
steps: | ||||||
- name: Checkout the code | ||||||
uses: actions/checkout@v4 | ||||||
- name: Import GPG key | ||||||
uses: crazy-max/ghaction-import-gpg@v6 | ||||||
with: | ||||||
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||||||
git_user_signingkey: true | ||||||
git_commit_gpgsign: true | ||||||
git_tag_gpgsign: true | ||||||
- name: Setup Git User | ||||||
run: | | ||||||
git config user.name "$GITHUB_ACTOR" | ||||||
git config user.email "[email protected]" | ||||||
|
||||||
- name: Run the Release Script | ||||||
env: | ||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
run: make release | ||||||
shell: bash |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,101 @@ | ||||||||||||||||||||
name: Wheels Builder and Publisher | ||||||||||||||||||||
on: | ||||||||||||||||||||
pull_request: | ||||||||||||||||||||
branches: | ||||||||||||||||||||
- main | ||||||||||||||||||||
types: | ||||||||||||||||||||
- closed | ||||||||||||||||||||
|
||||||||||||||||||||
jobs: | ||||||||||||||||||||
build_wheels: | ||||||||||||||||||||
name: Build wheels for Python SDK on ${{ matrix.os }} | ||||||||||||||||||||
runs-on: ${{ matrix.os }} | ||||||||||||||||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/') | ||||||||||||||||||||
strategy: | ||||||||||||||||||||
fail-fast: false | ||||||||||||||||||||
matrix: | ||||||||||||||||||||
# macOS 13 is an Intel runner and macOS 14 is an Apple Silicon runner | ||||||||||||||||||||
os: [ubuntu-22.04, ubuntu-22.04-arm, windows-latest, macos-13, macos-14] | ||||||||||||||||||||
steps: | ||||||||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||||||||
- name: Upgrade build dependencies | ||||||||||||||||||||
run: python -m pip install --upgrade pip setuptools wheel | ||||||||||||||||||||
|
||||||||||||||||||||
|
||||||||||||||||||||
# Need to grab the SDK version for the wheel name | ||||||||||||||||||||
- name: Extract SDK Version | ||||||||||||||||||||
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You can remove one extra line:
Suggested change
|
||||||||||||||||||||
run: echo "SDK_VERSION=$(cat version.txt)" >> "$GITHUB_ENV" | ||||||||||||||||||||
shell: bash | ||||||||||||||||||||
|
||||||||||||||||||||
- name: Install cibuildwheel | ||||||||||||||||||||
run: | | ||||||||||||||||||||
python -m pip install cibuildwheel | ||||||||||||||||||||
|
||||||||||||||||||||
- name: Build wheels | ||||||||||||||||||||
env: | ||||||||||||||||||||
CIBW_SKIP: pp* *-musllinux_* | ||||||||||||||||||||
CIBW_MANYLINUX_X86_64_IMAGE: "quay.io/pypa/manylinux_2_34_x86_64" | ||||||||||||||||||||
CIBW_MANYLINUX_AARCH64_IMAGE: "quay.io/pypa/manylinux_2_34_aarch64" | ||||||||||||||||||||
CIBW_ARCHS: "native" # Equivalent to python's platform.machine() | ||||||||||||||||||||
CIBW_BEFORE_BUILD_WINDOWS: "pip install delvewheel" | ||||||||||||||||||||
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | ||||||||||||||||||||
CIBW_TEST_REQUIRES: "pydantic pytest pytest-asyncio" | ||||||||||||||||||||
MACOSX_DEPLOYMENT_TARGET: "12.0" | ||||||||||||||||||||
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 | ||||||||||||||||||||
run: | | ||||||||||||||||||||
python -m cibuildwheel --output-dir dist | ||||||||||||||||||||
|
||||||||||||||||||||
- uses: actions/upload-artifact@v4 | ||||||||||||||||||||
with: | ||||||||||||||||||||
name: onepassword-sdk-${{ env.SDK_VERSION }}-${{ matrix.os }} | ||||||||||||||||||||
path: ./dist/*.whl | ||||||||||||||||||||
|
||||||||||||||||||||
build-sdist: | ||||||||||||||||||||
name: Build source distribution for Python SDK | ||||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/') | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do we want to replace |
||||||||||||||||||||
steps: | ||||||||||||||||||||
- uses: actions/checkout@v4 | ||||||||||||||||||||
|
||||||||||||||||||||
- name: Extract SDK Version | ||||||||||||||||||||
run: echo "SDK_VERSION=$(cat version.txt)" >> "$GITHUB_ENV" | ||||||||||||||||||||
shell: bash | ||||||||||||||||||||
|
||||||||||||||||||||
- name: Install dependencies | ||||||||||||||||||||
run: pip3 install build pydantic pytest pytest-asyncio | ||||||||||||||||||||
|
||||||||||||||||||||
- name: Build source distribution | ||||||||||||||||||||
run: python3 -m build --sdist | ||||||||||||||||||||
|
||||||||||||||||||||
- name: Test Source Distribution | ||||||||||||||||||||
env: | ||||||||||||||||||||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }} | ||||||||||||||||||||
run: | | ||||||||||||||||||||
python3 -m pip install dist/*.tar.gz | ||||||||||||||||||||
python3 -m pytest src/onepassword/test_client.py | ||||||||||||||||||||
|
||||||||||||||||||||
- uses: actions/upload-artifact@v4 | ||||||||||||||||||||
with: | ||||||||||||||||||||
name: onepassword-sdk-${{ env.SDK_VERSION }} | ||||||||||||||||||||
path: ./dist/*.tar.gz | ||||||||||||||||||||
|
||||||||||||||||||||
publish-to-pypi: | ||||||||||||||||||||
name: Publish to PyPI | ||||||||||||||||||||
runs-on: ubuntu-latest | ||||||||||||||||||||
if: github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/') | ||||||||||||||||||||
environment: | ||||||||||||||||||||
name: pypi | ||||||||||||||||||||
url: https://pypi.org/project/onepassword-sdk/ | ||||||||||||||||||||
permissions: | ||||||||||||||||||||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||||||||||||||||||||
needs: [build_wheels, build-sdist] | ||||||||||||||||||||
steps: | ||||||||||||||||||||
- uses: actions/download-artifact@v4 | ||||||||||||||||||||
with: | ||||||||||||||||||||
pattern: onepassword-sdk-* | ||||||||||||||||||||
path: ./dist | ||||||||||||||||||||
merge-multiple: true | ||||||||||||||||||||
- name: Publish package distributions to PyPi | ||||||||||||||||||||
uses: pypa/gh-action-pypi-publish@release/v1.12 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[build-system] | ||
requires = ["setuptools>=66", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "onepassword-sdk" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth adding the version here. We do that for Connect SDK for Python. |
||
dynamic = ["version"] | ||
description = "The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python." | ||
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", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/1Password/onepassword-sdk-python" | ||
|
||
[tool.setuptools.dynamic] | ||
version = {file = "./version.txt"} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A couple of questions here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.2.0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need a |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.