2.3.0 #32
Workflow file for this run
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: Publish to PyPI | |
on: | |
release: | |
types: | |
- released | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/djoser/ | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- name: Set up Python | |
uses: actions/[email protected] | |
with: | |
python-version: "3.8" | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: "1.3.2" | |
- name: Get release tag | |
id: get_tag | |
run: | | |
TAG=$(git describe --tags) | |
echo "TAG=$TAG" >> $GITHUB_ENV | |
VERSION=${TAG#v} # Remove "v" prefix if present | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Verify package version matches tag | |
run: | | |
PACKAGE_VERSION=$(poetry version -s) | |
if [ "$PACKAGE_VERSION" != "${{ env.VERSION }}" ]; then | |
echo "Package version ($PACKAGE_VERSION) does not match tag version (${{ env.VERSION }})" | |
exit 1 | |
fi | |
- name: Update package version from tag | |
run: | | |
echo "Updating version to ${{ env.VERSION }}" | |
poetry version ${{ env.VERSION }} | |
- name: Compile translations | |
run: | | |
echo "Compiling translation files..." | |
poetry run pybabel compile --domain django --directory djoser/locale -f | |
- name: Build package | |
run: | | |
echo "Building package..." | |
poetry build | |
echo "Package contents:" | |
ls -l dist/ | |
# Test PyPI deployment for pre-releases | |
- name: Configure Test PyPI | |
if: github.event.release.prerelease | |
run: | | |
echo "Configuring Test PyPI..." | |
poetry config repositories.testpypi https://test.pypi.org/legacy/ | |
poetry config pypi-token.testpypi ${{ secrets.TEST_PYPI_TOKEN }} | |
- name: Publish to Test PyPI | |
if: github.event.release.prerelease | |
run: | | |
echo "Publishing to Test PyPI..." | |
poetry publish --no-interaction -r testpypi | |
echo "Package published to Test PyPI successfully" | |
# Production PyPI deployment | |
- name: Configure PyPI | |
if: "!github.event.release.prerelease" | |
run: | | |
echo "Configuring PyPI..." | |
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | |
- name: Publish to PyPI | |
if: "!github.event.release.prerelease" | |
run: | | |
echo "Publishing to PyPI..." | |
poetry publish --no-interaction | |
echo "Package published to PyPI successfully" | |
- name: Verify publish | |
run: | | |
echo "Published version ${{ env.VERSION }} successfully" | |
echo "Package is available at https://pypi.org/p/djoser/${{ env.VERSION }}/" |