This repository has been archived by the owner on May 10, 2024. It is now read-only.
Deploy to PyPi #153
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
name: Deploy to PyPi | |
on: | |
workflow_run: | |
workflows: ["Run Tests"] | |
branches: [main] | |
types: | |
- completed | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
if: github.event.workflow_run.conclusion == 'success' | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
id: setup_python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
id: install_deps | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
- name: Build | |
id: build | |
run: | | |
python -m build | |
- name: Check if version has changed | |
id: check_version | |
run: | | |
LOCAL_VERSION=$(python setup.py --version) | |
PYPI_VERSION=$(curl -s https://pypi.org/pypi/paddle-billing-python-sdk/json | jq -r '.info.version') | |
if [ "$LOCAL_VERSION" != "$PYPI_VERSION" ]; then | |
echo "Version has changed. Current version: $LOCAL_VERSION" | |
echo "should_publish=true" >> $GITHUB_ENV | |
else | |
echo "Version has not changed. Skipping publish." | |
echo "should_publish=false" >> $GITHUB_ENV | |
fi | |
- name: Publish to PyPi | |
id: publish | |
if: env.should_publish == 'true' | |
uses: pypa/gh-action-pypi-publish@release/v1 |