11name : Release Builder
22on :
3- workflow_dispatch :
4- inputs :
5- build-release :
6- description : ' Do you want to build the release for the Python SDK (this includes the wheels + sdist)?'
7- type : boolean
8- default : false
3+ pull_request :
4+ branches :
5+ - main
6+ types :
7+ - closed
98
109jobs :
1110 build_wheels :
1211 name : Build wheels for Python SDK on ${{ matrix.os }}
1312 runs-on : ${{ matrix.os }}
13+ if : github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/')
1414 strategy :
1515 matrix :
1616 # macOS 13 is an Intel runner and macOS 14 is an Apple Silicon runner
2121 # Need to grab the SDK version for the wheel name
2222 - name : Extract SDK Version
2323 run : echo "SDK_VERSION=$(python -c 'import version; print(version.SDK_VERSION)')" >> $GITHUB_ENV
24+
25+ - name : Install cibuildwheel
26+ run : |
27+ python -m pip install cibuildwheel
2428
2529 - name : Build wheels
2630 env :
@@ -33,17 +37,18 @@ jobs:
3337 MACOSX_DEPLOYMENT_TARGET : 11.0 # Required for building on macOS
3438 OP_SERVICE_ACCOUNT_TOKEN : ${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }}
3539 CIBW_ENVIRONMENT_PASS_LINUX : OP_SERVICE_ACCOUNT_TOKEN # to pass in the SA token, for some reason Linux doesn't read the env variables correctly
36-
37- uses : pypa/ cibuildwheel@v2.23.0
40+ run : |
41+ python -m cibuildwheel --output-dir dist
3842
3943 - uses : actions/upload-artifact@v4
4044 with :
4145 name : onepassword-sdk-${{ env.SDK_VERSION }}-${{ matrix.os }}
42- path : ./wheelhouse /*.whl
46+ path : ./dist /*.whl
4347
4448 build-sdist :
4549 name : Build source distribution for Python SDK
4650 runs-on : ubuntu-latest
51+ if : github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/')
4752 steps :
4853 # Need to grab the SDK version for the wheel name
4954 - name : Extract SDK Version
6772 with :
6873 name : onepassword-sdk-${{ env.SDK_VERSION }}
6974 path : ./dist/*.tar.gz
75+
76+ publish-to-pypi :
77+ name : Publish to PyPI
78+ runs-on : ubuntu-latest
79+ if : github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/')
80+ environment :
81+ name : testpypi
82+ url : https://pypi.org/p/<your-pypi-project-name>
83+ permissions :
84+ id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
85+ needs : [build_wheels, build-sdist]
86+ steps :
87+ - uses : actions/download-artifact@v2
88+ with :
89+ name : python-sdk-release
90+ path : dist
91+
92+ - name : Publish package distributions to TestPyPI
93+ uses : pypa/gh-action-pypi-publish@release/v1
94+ with :
95+ repository-url : https://test.pypi.org/legacy/
0 commit comments