|
| 1 | +name: Upload Python Packages to test PyPI |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + publish-to-test-pypi: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + needs: [get-directories] |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + directory: ${{ fromJson(needs.get-directories.outputs.directories) }} |
| 14 | + environment: |
| 15 | + name: testpypi |
| 16 | + url: https://test.pypi.org/p/${{ matrix.directory }} |
| 17 | + permissions: |
| 18 | + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 19 | + contents: read |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: '3.13' |
| 28 | + |
| 29 | + - name: Install requirements |
| 30 | + run: pip install -r requirements-dev.txt |
| 31 | + |
| 32 | + - name: Update __init__.py |
| 33 | + working-directory: src/${{ matrix.directory }} |
| 34 | + run: | |
| 35 | + name=$(uv run tomlq -r '.project.name' pyproject.toml) |
| 36 | + version=$(uv run tomlq -r '.project.version' pyproject.toml) |
| 37 | + if [ -d oracle/*_mcp_server ]; then |
| 38 | + init_py_file=oracle/*_mcp_server/__init__.py |
| 39 | + echo "\"\"\"\nCopyright (c) 2025, Oracle and/or its affiliates.\nLicensed under the Universal Permissive License v1.0 as shown at\nhttps://oss.oracle.com/licenses/upl.\n\"\"\"\n" > $$init_py_file; \ |
| 40 | + echo "__project__ = \"$name\"" >> $init_py_file |
| 41 | + echo "__version__ = \"$version\"" >> $init_py_file |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Sync |
| 45 | + working-directory: src/${{ matrix.directory }} |
| 46 | + run: uv sync --locked --all-extras --dev |
| 47 | + |
| 48 | + - name: Build |
| 49 | + working-directory: src/${{ matrix.directory }} |
| 50 | + run: uv build |
| 51 | + |
| 52 | + - name: Test install |
| 53 | + working-directory: src/${{ matrix.directory }} |
| 54 | + run: uv pip install . |
| 55 | + |
| 56 | + - name: Publish package to PyPI |
| 57 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 58 | + with: |
| 59 | + packages-dir: ./src/${{ matrix.directory }}/dist/ |
| 60 | + repository-url: https://test.pypi.org/legacy/ |
| 61 | + skip-existing: true |
| 62 | + |
| 63 | + |
| 64 | + get-directories: |
| 65 | + runs-on: ubuntu-latest |
| 66 | + outputs: |
| 67 | + directories: ${{ steps.get-directories.outputs.directories }} |
| 68 | + steps: |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Get directories |
| 73 | + id: get-directories |
| 74 | + run: | |
| 75 | + directories=$(ls src | grep -v dbtools-mcp-server | grep -v mysql-mcp-server | grep -v oci-pricing-mcp-server | grep -v oracle-db-doc-mcp-server | jq -R -s -c 'split("\n")[:-1]') |
| 76 | + echo "directories=$directories" >> $GITHUB_OUTPUT |
0 commit comments