|
| 1 | +name: Release Python Connector |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +jobs: |
| 10 | + detect-clients: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + outputs: |
| 13 | + clients: ${{ steps.detect.outputs.clients }} |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Detect all clients |
| 19 | + id: detect |
| 20 | + run: | |
| 21 | + ALL_CLIENTS=$(ls -d clients/*/ | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]') |
| 22 | + echo "Detected clients: $ALL_CLIENTS" |
| 23 | + echo "clients=$ALL_CLIENTS" >> $GITHUB_ENV |
| 24 | + echo "::set-output name=clients::$ALL_CLIENTS" |
| 25 | +
|
| 26 | + release: |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Compare versions |
| 33 | + id: version |
| 34 | + run: | |
| 35 | + if [ "${{ matrix.client }}" == "common" ]; then |
| 36 | + cd common |
| 37 | + else |
| 38 | + cd clients/${{ matrix.client }} |
| 39 | + fi |
| 40 | +
|
| 41 | + old_version=$(git show HEAD^:pyproject.toml | grep '^version' | head -1 | sed -E 's/version = "(.*)"/\1/') |
| 42 | + new_version=$(grep '^version' pyproject.toml | head -1 | sed -E 's/version = "(.*)"/\1/') |
| 43 | + |
| 44 | + if [ "$old_version" = "$new_version" ]; then |
| 45 | + echo "::error ::Version was not bumped in pyproject.toml — skipping release" |
| 46 | + exit 1 |
| 47 | + fi |
| 48 | +
|
| 49 | + - name: Set working directory path |
| 50 | + id: path |
| 51 | + run: echo "dir=$([[ '${{ matrix.client }}' == 'common' ]] && echo 'common' || echo 'clients/${{ matrix.client }}')" >> $GITHUB_OUTPUT |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + working-directory: ${{ steps.path.outputs.dir }} |
| 55 | + run: | |
| 56 | + curl -sSL https://install.python-poetry.org | python3 - |
| 57 | + echo "$HOME/.local/bin" >> $GITHUB_PATH |
| 58 | +
|
| 59 | + - name: Configure Poetry |
| 60 | + working-directory: ${{ steps.path.outputs.dir }} |
| 61 | + run: | |
| 62 | + poetry install |
| 63 | + if [ "${{ matrix.client }}" == "common" ]; then |
| 64 | + poetry config pypi-token.pypi ${{ secrets.PYPI_COMMON_TOKEN }} |
| 65 | + else |
| 66 | + poetry config pypi-token.pypi ${{ secrets.PYPI_CLIENTS_TOKEN }} |
| 67 | + fi |
| 68 | +
|
| 69 | + - name: Build (release) |
| 70 | + working-directory: ${{ steps.path.outputs.dir }} |
| 71 | + run: poetry build |
| 72 | + |
| 73 | + - name: Publish to pypi |
| 74 | + working-directory: ${{ steps.path.outputs.dir }} |
| 75 | + run: poetry publish --build |
0 commit comments