From b1fc2d3f175616cb72fa3e299d4c7dfac8d9c449 Mon Sep 17 00:00:00 2001 From: mawenbo <85687446+mawenbo-huawei@users.noreply.github.com> Date: Thu, 15 Jun 2023 11:22:43 +0800 Subject: [PATCH] Github Actions Workflow - Publish Python Packages To Pypi. --- .github/workflows/pypi-publish.yml | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/pypi-publish.yml diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml new file mode 100644 index 000000000..507d16c13 --- /dev/null +++ b/.github/workflows/pypi-publish.yml @@ -0,0 +1,34 @@ +name: Publish Python Packages To Pypi +on: + workflow_dispatch: + release: + types: [created] +jobs: + publish: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build packages + run: | + for each in $(find "${GITHUB_WORKSPACE}" -maxdepth 1 -mindepth 1 -type d -name "*sdk*") + do + cd "${each}" || exit 1 + python setup.py bdist_wheel + cp dist/*.whl "${GITHUB_WORKSPACE}" + done + shell: bash + - name: Publish packages + run: | + echo -e "[pypi]\nusername = __token__\npassword = ${PYPI_API_TOKEN}" >> "${HOME}/.pypirc" + cd "${GITHUB_WORKSPACE}" || exit 1 + twine upload --repository pypi ./*.whl --skip-existing --verbose + env: + PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}