LiteyukiBot/.github/workflows/pypi-publish.yml

39 lines
1.1 KiB
YAML
Raw Normal View History

name: Publish
on:
2024-08-18 16:06:24 +00:00
release:
types: [published]
jobs:
pypi-publish:
name: upload release to PyPI
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- uses: pdm-project/setup-pdm@v3
2024-08-18 16:06:24 +00:00
- name: Get current version from PyPI
id: get_pypi_version
run: |
PACKAGE_NAME=$(pdm info | grep 'Name:' | awk '{print $2}')
CURRENT_VERSION=$(pdm info | grep 'Version:' | awk '{print $2}')
PYPI_VERSION=$(curl -s https://pypi.org/pypi/$PACKAGE_NAME/json | jq -r '.info.version')
echo "PACKAGE_NAME=$PACKAGE_NAME" >> $GITHUB_ENV
echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo "PYPI_VERSION=$PYPI_VERSION" >> $GITHUB_ENV
- name: Check if versions are different
id: check_versions
run: |
if [ "$CURRENT_VERSION" != "$PYPI_VERSION" ]; then
echo "versions_different=true" >> $GITHUB_ENV
else
echo "versions_different=false" >> $GITHUB_ENV
- name: Publish package distributions to PyPI
2024-08-18 16:06:24 +00:00
run: pdm publish