Publish Python π distributions π¦ to PyPI #2491
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Publish a corresponding version of Python client to | |
## https://pypi.org/project/data-repo-client/ | |
## | |
## To manage the data-repo-client project in PyPi, you must have a PyPi account | |
## and be added as an owner to the project by a current owner. | |
name: Publish Python π distributions π¦ to PyPI | |
on: | |
workflow_dispatch: {} | |
env: | |
NODE_VERSION: 20 | |
jobs: | |
build-n-publish: | |
name: Build and publish Python π distributions π¦ to PyPI and TestPyPI | |
runs-on: ubuntu-latest | |
# Specifying a GitHub environment is optional, but strongly encouraged | |
environment: release | |
permissions: | |
# IMPORTANT: this permission is mandatory for trusted publishing (OIDC) | |
# https://docs.pypi.org/trusted-publishers/using-a-publisher/ | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python 3.7 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.7 | |
- name: set semver | |
run: | | |
CURRENT_SEMVER=$(curl -s -X GET "https://jade.datarepo-dev.broadinstitute.org/configuration" -H "accept: application/json" | jq -r '.semVer|rtrimstr("-SNAPSHOT")') | |
echo "CURRENT_SEMVER=${CURRENT_SEMVER}" >> "$GITHUB_ENV" | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
- name: Install openapi-generator-cli | |
run: npm install @openapitools/openapi-generator-cli -g | |
- name: set version to 4.3.1 | |
run: openapi-generator-cli version-manager set 4.3.1 | |
- name: Generate Python client | |
run: | | |
openapi-generator-cli generate \ | |
-i src/main/resources/api/data-repository-openapi.yaml \ | |
-g python \ | |
-o data-repo-client \ | |
--additional-properties=projectName=data-repo-client,packageName=data_repo_client,packageVersion=${CURRENT_SEMVER},useSpringBoot3=true \ | |
--skip-validate-spec | |
- name: Install pypa/build | |
working-directory: ./data-repo-client | |
run: >- | |
python -m pip install build --user | |
- name: Build a binary wheel and a source tarball | |
working-directory: ./data-repo-client | |
run: >- | |
python -m build --sdist --wheel --outdir dist/ . | |
- name: Publish distribution π¦ to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages_dir: ./data-repo-client/dist | |
skip_existing: true | |
report-workflow: | |
uses: broadinstitute/sherlock/.github/workflows/client-report-workflow.yaml@main | |
with: | |
relates-to-chart-releases: 'datarepo-dev' | |
notify-slack-channels-upon-workflow-failure: ${{ vars.SLACK_NOTIFICATION_CHANNELS }} | |
notify-slack-channels-upon-workflow-retry: ${{ vars.SLACK_NOTIFICATION_CHANNELS }} | |
permissions: | |
id-token: write |