Skip to content

v1.1.0

v1.1.0 #16

Workflow file for this run

name: Publish to PyPI
on:
release:
types: [published]
workflow_dispatch:
jobs:
build-and-publish:
environment: ucloud-sandbox-sdk-python
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Extract version from tag
id: get_version
run: |
# Get tag from release event or use ref for workflow_dispatch
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
else
TAG="${{ github.ref_name }}"
fi
# Remove 'v' prefix if present
VERSION="${TAG#v}"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Update version in pyproject.toml
run: |
sed -i "s/^version = .*/version = \"${{ steps.get_version.outputs.VERSION }}\"/" pyproject.toml
echo "Updated pyproject.toml:"
grep "^version" pyproject.toml
- name: Install build tooling
run: |
python -m pip install --upgrade pip
pip install build
- name: Build distribution artifacts
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}