Skip to content

Merge pull request #566 from PacificGilly/jamesgilmore/hotfix-versioner #19

Merge pull request #566 from PacificGilly/jamesgilmore/hotfix-versioner

Merge pull request #566 from PacificGilly/jamesgilmore/hotfix-versioner #19

Workflow file for this run

---
name: Deploy to test.pypi.org
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
cache: pip
- name: Install dependencies
run: python -m pip install --upgrade pip poetry
- name: Deploy to testpypi.org
run: |
# Need to check both Test PyPi and GH releases as we need to version bump the patch
# version everytime we merge in a PR, but once we release a new production release, we
# need to bump from the new release. So we grab the latest releases from both sources,
# then reverse sort them to get highest version! Simples :D
LATEST_RELEASE_TEST_PYPI=$(curl -s https://test.pypi.org/rss/project/django-jazzmin/releases.xml | sed -n 's/\s*<title>\([{a,b}0-9.]*\).*/\1/p' | head -n 2 | xargs)
LATEST_RELEASE_GITHUB=$(curl -s "https://api.github.com/repos/farridav/django-jazzmin/tags" | jq -r '.[0].name[1:]')
LATEST_RELEASE=$(printf "${LATEST_RELEASE_GITHUB}\n${LATEST_RELEASE_TEST_PYPI}" | sort -V -r | head -n 1)
# Now we can bump the version correctly to release a new version nicely base on the
# latest GH release.
poetry version $LATEST_RELEASE
poetry version prerelease # Using `prerelease` rather than `prepatch` due to a bug in Poetry (latest checked 1.8.1 - https://github.com/python-poetry/poetry/issues/879)
poetry config repositories.test_pypi https://test.pypi.org/legacy/
poetry publish --build -r test_pypi --username __token__ --password ${{ secrets.TEST_PYPI_TOKEN }} || true
update_release_draft:
permissions:
contents: write
pull-requests: read
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}