|
| 1 | +name: Python CD |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [develop] |
| 5 | + release: |
| 6 | + types: [published] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-distributables: |
| 11 | + # Why building is separate from publishing: |
| 12 | + # https://github.com/pypa/gh-action-pypi-publish/issues/217#issuecomment-1965727093 |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd |
| 16 | + with: |
| 17 | + persist-credentials: false |
| 18 | + - uses: ./.github/actions/setup-sdk-environment |
| 19 | + with: |
| 20 | + python-version: 3.13 |
| 21 | + deps-group: release |
| 22 | + - name: Set pre-release version |
| 23 | + id: set-version |
| 24 | + if: ${{ ! startsWith(github.ref, 'refs/tags/') }} |
| 25 | + run: | |
| 26 | + VERSION_BASE="$(uv version --short)" |
| 27 | + RUN_NUMBER="${{ github.run_number }}" |
| 28 | + COMMIT_SHA="$(git rev-parse --short HEAD)" |
| 29 | + uv version --frozen "${VERSION_BASE}.dev${RUN_NUMBER}+g${COMMIT_SHA}" |
| 30 | + - name: Build packages for distribution |
| 31 | + run: uv build |
| 32 | + - name: Run AppInspect |
| 33 | + uses: ./.github/actions/run-appinspect |
| 34 | + - name: Upload pre-release distributables |
| 35 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 36 | + with: |
| 37 | + name: splunk-sdk |
| 38 | + path: dist/ |
| 39 | + - name: Generate API reference |
| 40 | + run: make -C ./docs html |
| 41 | + - name: Upload docs artifact |
| 42 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a |
| 43 | + with: |
| 44 | + name: python-sdk-docs |
| 45 | + path: docs/_build/html |
| 46 | + |
| 47 | + publish-pre-release: |
| 48 | + if: startsWith(github.ref, 'refs/tags/') != true |
| 49 | + needs: build-release |
| 50 | + runs-on: ubuntu-latest |
| 51 | + permissions: |
| 52 | + id-token: write |
| 53 | + environment: |
| 54 | + name: splunk-test-pypi |
| 55 | + url: https://test.pypi.org/project/splunk-sdk/ |
| 56 | + steps: |
| 57 | + - name: Download distributables |
| 58 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 59 | + with: |
| 60 | + name: splunk-sdk |
| 61 | + path: dist/ |
| 62 | + - name: Publish packages to Test PyPI |
| 63 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b |
| 64 | + with: |
| 65 | + repository-url: https://test.pypi.org/legacy/ |
| 66 | + |
| 67 | + publish-release: |
| 68 | + if: startsWith(github.ref, 'refs/tags/') |
| 69 | + needs: build-release |
| 70 | + runs-on: ubuntu-latest |
| 71 | + permissions: |
| 72 | + id-token: write |
| 73 | + environment: |
| 74 | + name: splunk-pypi |
| 75 | + url: https://pypi.org/project/splunk-sdk/ |
| 76 | + steps: |
| 77 | + - name: Download distributables |
| 78 | + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 79 | + with: |
| 80 | + name: splunk-sdk |
| 81 | + path: dist/ |
| 82 | + - name: Publish packages to PyPI |
| 83 | + uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b |
| 84 | + with: |
| 85 | + repository-url: https://pypi.org/legacy/ |
0 commit comments