|
| 1 | +# This action assumes that there is a REL-commit which already has a |
| 2 | +# Markdown-formatted git tag. Hence the CHANGELOG is already adjusted |
| 3 | +# and it's decided what should be in the release. |
| 4 | +# This action only ensures the release is done with the proper contents |
| 5 | +# and that it's announced with a Github release. |
| 6 | +name: Publish Python Package to PyPI |
| 7 | +on: |
| 8 | + push: |
| 9 | + tags: |
| 10 | + - '*.*.*' |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_and_publish: |
| 14 | + # this doesn't make sense if you don't have the PyPI secret |
| 15 | + if: github.repository == 'py-pdf/pypdf' |
| 16 | + name: Publish a new version of pypdf |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + # Ensure it's on PyPI |
| 21 | + - name: Checkout Repository |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v4 |
| 26 | + with: |
| 27 | + python-version: 3.x |
| 28 | + |
| 29 | + - name: Install Flit |
| 30 | + run: | |
| 31 | + python -m pip install --upgrade pip |
| 32 | + pip install flit |
| 33 | +
|
| 34 | + - name: Publish Package to PyPI🚀 |
| 35 | + env: |
| 36 | + FLIT_USERNAME: '__token__' |
| 37 | + FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }} |
| 38 | + run: | |
| 39 | + flit publish |
| 40 | +
|
| 41 | + # Create the Github Page |
| 42 | + - name: Prepare variables |
| 43 | + id: prepare_variables |
| 44 | + run: | |
| 45 | + git fetch --tags --force |
| 46 | + latest_tag=$(git describe --tags --abbrev=0) |
| 47 | + echo "latest_tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_ENV" |
| 48 | + echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_ENV" |
| 49 | + tag_body=$(git tag -l "${latest_tag}" --format='%(contents:body)') |
| 50 | + - name: Create GitHub Release 🚀 |
| 51 | + uses: actions/create-release@v1 |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 54 | + with: |
| 55 | + tag_name: ${{ github.ref }} |
| 56 | + release_name: Version ${{ env.latest_tag }}, ${{ env.date }} |
| 57 | + draft: false |
| 58 | + prerelease: false |
| 59 | + body: Body is ${{ env.tag_body }} |
0 commit comments