python-telegram-bot/.github/workflows/release_pypi.yml

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

130 lines
3.7 KiB
YAML
Raw Normal View History

2024-07-12 16:44:41 +02:00
name: Publish to PyPI
on:
2024-09-01 09:34:20 +02:00
# manually trigger the workflow
2024-07-12 16:44:41 +02:00
workflow_dispatch:
jobs:
build:
name: Build Distribution
runs-on: ubuntu-latest
2024-09-01 09:34:20 +02:00
outputs:
TAG: ${{ steps.get_tag.outputs.TAG }}
2024-07-12 16:44:41 +02:00
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m pip install build --user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
2024-09-01 09:34:20 +02:00
- name: Get Tag Name
id: get_tag
run: |
pip install .
TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')")
echo "TAG=$TAG" >> $GITHUB_OUTPUT
2024-07-12 16:44:41 +02:00
publish-to-pypi:
name: Publish to PyPI
needs:
- build
runs-on: ubuntu-latest
environment:
name: release_pypi
url: https://pypi.org/p/python-telegram-bot
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
compute-signatures:
name: Compute SHA1 Sums and Sign with Sigstore
runs-on: ubuntu-latest
needs:
- publish-to-pypi
permissions:
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Compute SHA1 Sums
run: |
# Compute SHA1 sum of the distribution packages and save it to a file with the same name,
# but with .sha1 extension
for file in dist/*; do
sha1sum $file > $file.sha1
done
- name: Sign the dists with Sigstore
2024-09-01 09:34:20 +02:00
uses: sigstore/gh-action-sigstore-python@v3.0.0
2024-07-12 16:44:41 +02:00
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Store the distribution packages and signatures
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-and-signatures
path: dist/
github-release:
name: Upload to GitHub Release
needs:
2024-09-01 09:34:20 +02:00
- build
2024-07-12 16:44:41 +02:00
- compute-signatures
runs-on: ubuntu-latest
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions-and-signatures
path: dist/
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
2024-09-01 09:34:20 +02:00
TAG: ${{ needs.build.outputs.TAG }}
# Create a tag and a GitHub Release. The description can be changed later, as for now
2024-07-12 16:44:41 +02:00
# we don't define it through this workflow.
run: >-
gh release create
2024-09-01 09:34:20 +02:00
'${{ env.TAG }}'
2024-07-12 16:44:41 +02:00
--repo '${{ github.repository }}'
--generate-notes
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
2024-09-01 09:34:20 +02:00
TAG: ${{ needs.build.outputs.TAG }}
2024-07-12 16:44:41 +02:00
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
2024-09-01 09:34:20 +02:00
'${{ env.TAG }}' dist/**
2024-07-12 16:44:41 +02:00
--repo '${{ github.repository }}'