|
| 1 | +# Copyright 2023, Oracle Corporation and/or its affiliates. All rights reserved. |
| 2 | +# Licensed under the Universal Permissive License v 1.0 as shown at |
| 3 | +# https://oss.oracle.com/licenses/upl. |
| 4 | + |
| 5 | +# --------------------------------------------------------------------------- |
| 6 | +# Coherence Python Client GitHub Release Actions build. |
| 7 | +# --------------------------------------------------------------------------- |
| 8 | + |
| 9 | + |
| 10 | +name: Pypi publish CD workflow |
| 11 | + |
| 12 | +on: |
| 13 | + release: |
| 14 | + # This specifies that the build will be triggered when we publish a release |
| 15 | + types: [published] |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + matrix: |
| 20 | + python-version: ["3.11.x"] |
| 21 | + poetry-version: ["1.5.0"] |
| 22 | + os: [ubuntu-latest] |
| 23 | + runs-on: ${{ matrix.os }} |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Get Docker Images |
| 27 | + shell: bash |
| 28 | + run: | |
| 29 | + docker pull gcr.io/distroless/java17-debian11 |
| 30 | + uname -a |
| 31 | +
|
| 32 | + - name: Set up JDK |
| 33 | + uses: actions/setup-java@v3 |
| 34 | + with: |
| 35 | + java-version: '11' |
| 36 | + distribution: 'zulu' |
| 37 | + |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + - uses: actions/setup-python@v4 |
| 40 | + with: |
| 41 | + python-version: ${{ matrix.python-version }} |
| 42 | + |
| 43 | + - name: Cache Maven packages |
| 44 | + uses: actions/cache@v3 |
| 45 | + with: |
| 46 | + path: ~/.m2 |
| 47 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 48 | + restore-keys: ${{ runner.os }}-m2 |
| 49 | + |
| 50 | + - name: Install Poetry |
| 51 | + shell: bash |
| 52 | + run: | |
| 53 | + pip install poetry==${{ matrix.poetry-version }} |
| 54 | +
|
| 55 | + - name: Install Dependencies |
| 56 | + run: python -m poetry install |
| 57 | + |
| 58 | + - name: Generate docs |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + python -m poetry run make docs |
| 62 | + # copy generated docs to temp directory |
| 63 | + PY_CLIENT_DOC=/tmp/docs/ |
| 64 | + mkdir -p ${PY_CLIENT_DOC} |
| 65 | + cp -R ./docs/_build ${PY_CLIENT_DOC} |
| 66 | +
|
| 67 | + - name: Release GitHub Pages |
| 68 | + shell: bash |
| 69 | + run: | |
| 70 | + git config --local user.name "Github Action" |
| 71 | + git config --local user.email "[email protected]" |
| 72 | + git stash save --keep-index --include-untracked || true |
| 73 | + git stash drop || true |
| 74 | + git checkout --track origin/gh-pages-test |
| 75 | + git pull --rebase |
| 76 | + # copy the generated docs |
| 77 | + pwd |
| 78 | + rm -rf ./_build |
| 79 | + cp -R ${PY_CLIENT_DOC}/_build . |
| 80 | + git add -A _build/* |
| 81 | + git commit -m "Updating docs for Coherence Python Client" |
| 82 | + git push origin gh-pages-test |
| 83 | +
|
| 84 | + - name: Publish to PyPi |
| 85 | + shell: bash |
| 86 | + env: |
| 87 | + TWINE_USERNAME: ${{ secrets.TEST_PYPI_USER }} |
| 88 | + TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }} |
| 89 | + run: | |
| 90 | + pip install --upgrade pip |
| 91 | + pip install build twine |
| 92 | + python -m poetry run python3 -m build |
| 93 | + ls -la ./dist |
| 94 | + twine upload --repository testpypi dist/* |
0 commit comments