Publish Keeper SDK to PyPI #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Keeper SDK to PyPI | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: Version to release (tag or branch) | |
| required: true | |
| jobs: | |
| build-and-test: | |
| name: Build and test Keeper SDK package | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.version }} | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Install dependencies | |
| run: | | |
| pip install keepersdk-package/ | |
| - name: Run unit tests | |
| run: python -m unittest discover -s keepersdk-package/unit_tests/ | |
| - name: Build the package | |
| run: | | |
| python3 -m pip install -U build wheel twine | |
| python3 -m build --wheel keepersdk-package | |
| - name: Archive the package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: KeeperSdkWheel | |
| retention-days: 1 | |
| path: keepersdk-package/dist/* | |
| if-no-files-found: error | |
| publish-test-pypi: | |
| name: Publish to Test PyPI | |
| runs-on: ubuntu-latest | |
| needs: [build-and-test] | |
| environment: test | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: KeeperSdkWheel | |
| path: keepersdk-package/dist | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Publish to Test PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} | |
| run: | | |
| python -m pip install -U twine | |
| twine upload --repository testpypi keepersdk-package/dist/* | |
| publish-pypi: | |
| name: Publish to Production PyPI | |
| runs-on: ubuntu-latest | |
| needs: [publish-test-pypi] | |
| environment: prod | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: KeeperSdkWheel | |
| path: keepersdk-package/dist | |
| - name: Set up Python 3.13 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.13' | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_PUBLISH_TOKEN }} | |
| run: | | |
| python -m pip install -U twine | |
| twine upload keepersdk-package/dist/* |