- Notifications
You must be signed in to change notification settings - Fork5.7k
Improve PyPI Automation#4375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
15 commits Select commitHold shift + click to select a range
6a8f3cc
Split Workflows for PyPI and Test PyPI Upload
Bibo-Joshid87d528
slight changes to the production workflow
Bibo-Joshicbee05d
Copy test_pypi to pypi - dummy commit to show that the workflows are …
Bibo-Joshi6a155d3
revert dummy commit
Bibo-Joshia255ee5
Update name
Bibo-Joshie26a039
Get tag name from `__version__`
Bibo-Joshie620de0
Temporarily run test_pypi_workflow on push for testing
Bibo-Joshi8f1ce9c
Change the version number to get a working testpypi build
Bibo-Joshi2a33269
Try again getting the tag
Bibo-Joshid4c0bce
Try again
Bibo-Joshi9aa72ac
try correctly using the tag in the gh release
Bibo-Joshif399926
Revert "Temporarily run test_pypi_workflow on push for testing"
Bibo-Joshiedac119
Remove a debug leftover
Bibo-Joshi31c9407
update sigstore action
Bibo-Joshif674d92
Merge branch 'refs/heads/master' into improve-pypi-automation
Bibo-JoshiFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
107 changes: 16 additions & 91 deletions.github/workflows/release_pypi.yml
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
name: Publish to PyPI | ||
on: | ||
# manually trigger the workflow | ||
harshil21 marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
name: Build Distribution | ||
runs-on: ubuntu-latest | ||
outputs: | ||
TAG: ${{ steps.get_tag.outputs.TAG }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
@@ -29,11 +27,15 @@ jobs: | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- 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 | ||
publish-to-pypi: | ||
name: Publish to PyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
@@ -52,42 +54,11 @@ jobs: | ||
- 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 | ||
@@ -106,7 +77,7 @@ jobs: | ||
sha1sum $file > $file.sha1 | ||
done | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/gh-action-sigstore-python@v3.0.0 | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
@@ -120,56 +91,9 @@ jobs: | ||
github-release: | ||
name: Upload to GitHub Release | ||
needs: | ||
-build | ||
- compute-signatures | ||
runs-on: ubuntu-latest | ||
permissions: | ||
@@ -184,21 +108,22 @@ jobs: | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
TAG: ${{ needs.build.outputs.TAG }} | ||
# Create a tag and a GitHub Release. The description can be changed later, as for now | ||
# we don't define it through this workflow. | ||
run: >- | ||
gh release create | ||
'${{env.TAG }}' | ||
--repo '${{ github.repository }}' | ||
--generate-notes | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
TAG: ${{ needs.build.outputs.TAG }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{env.TAG }}' dist/** | ||
--repo '${{ github.repository }}' |
132 changes: 132 additions & 0 deletions.github/workflows/release_test_pypi.yml
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: Publish to Test PyPI | ||
on: | ||
# manually trigger the workflow | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
name: Build Distribution | ||
runs-on: ubuntu-latest | ||
outputs: | ||
TAG: ${{ steps.get_tag.outputs.TAG }} | ||
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/ | ||
- 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 | ||
publish-to-test-pypi: | ||
name: Publish to Test PyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: release_test_pypi | ||
url: https://test.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 Test PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
repository-url: https://test.pypi.org/legacy/ | ||
compute-signatures: | ||
name: Compute SHA1 Sums and Sign with Sigstore | ||
runs-on: ubuntu-latest | ||
needs: | ||
- publish-to-test-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 | ||
uses: sigstore/gh-action-sigstore-python@v3.0.0 | ||
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-test-release: | ||
name: Upload to GitHub Release Draft | ||
needs: | ||
- build | ||
- 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 }} | ||
TAG: ${{ needs.build.outputs.TAG }} | ||
# Create a GitHub Release *draft*. The description can be changed later, as for now | ||
# we don't define it through this workflow. | ||
run: >- | ||
gh release create | ||
'${{ env.TAG }}' | ||
--repo '${{ github.repository }}' | ||
--generate-notes | ||
--draft | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
TAG: ${{ needs.build.outputs.TAG }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ env.TAG }}' dist/** | ||
--repo '${{ github.repository }}' |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.