From 6a8f3ccc7f59b4f563162ab30135d35161b32242 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:08:51 +0200 Subject: [PATCH 01/14] Split Workflows for PyPI and Test PyPI Upload --- .github/workflows/release_pypi.yml | 86 +---------------- .github/workflows/release_test_pypi.yml | 120 ++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 85 deletions(-) create mode 100644 .github/workflows/release_test_pypi.yml diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index bcd1794c468..4978b05ca93 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -1,11 +1,7 @@ name: Publish to PyPI on: - # Run on any tag - push: - tags: - - '**' - # manually trigger the workflow - for testing only + # manually trigger the workflow workflow_dispatch: jobs: @@ -52,42 +48,11 @@ jobs: - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - 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-pypi - - publish-to-test-pypi - # run if either of the publishing jobs ran successfully - # see also: - # https://github.com/actions/runner/issues/491#issuecomment-850884422 - if: | - always() && ( - (needs.publish-to-pypi.result == 'success') || - (needs.publish-to-test-pypi.result == 'success') - ) permissions: id-token: write # IMPORTANT: mandatory for sigstore @@ -120,13 +85,7 @@ jobs: github-release: name: Upload to GitHub Release needs: - - publish-to-pypi - compute-signatures - if: | - always() && ( - (needs.publish-to-pypi.result == 'success') && - (needs.compute-signatures.result == 'success') - ) runs-on: ubuntu-latest @@ -159,46 +118,3 @@ jobs: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository }}' - - github-test-release: - name: Upload to GitHub Release Draft - needs: - - publish-to-test-pypi - - compute-signatures - if: | - always() && ( - (needs.publish-to-test-pypi.result == 'success') && - (needs.compute-signatures.result == 'success') - ) - 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 }} - # 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 - '${{ github.ref_name }}' - --repo '${{ github.repository }}' - --generate-notes - --draft - - name: Upload artifact signatures to GitHub Release - env: - GITHUB_TOKEN: ${{ github.token }} - # Upload to GitHub Release using the `gh` CLI. - # `dist/` contains the built packages, and the - # sigstore-produced signatures and certificates. - run: >- - gh release upload - '${{ github.ref_name }}' dist/** - --repo '${{ github.repository }}' diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml new file mode 100644 index 00000000000..496c1d9b967 --- /dev/null +++ b/.github/workflows/release_test_pypi.yml @@ -0,0 +1,120 @@ +name: Publish to PyPI + +on: + # manually trigger the workflow + workflow_dispatch: + +jobs: + build: + name: Build Distribution + runs-on: ubuntu-latest + + 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/ + + 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@v2.1.1 + 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: + - 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 }} + # 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 + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --generate-notes + --draft + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. + # `dist/` contains the built packages, and the + # sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' From d87d528561d95533e91e2b79b88d0c9698e78ba7 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:11:56 +0200 Subject: [PATCH 02/14] slight changes to the production workflow --- .github/workflows/release_pypi.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 4978b05ca93..c3e93c26618 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -28,8 +28,6 @@ jobs: publish-to-pypi: name: Publish to PyPI - # only publish to PyPI on tag pushes - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') needs: - build runs-on: ubuntu-latest @@ -101,7 +99,7 @@ jobs: - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} - # Create a GitHub Release for this tag. The description can be changed later, as for now + # 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 From cbee05dc1d35ccc118fc4cd37373c211aca0a3c5 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:13:22 +0200 Subject: [PATCH 03/14] Copy test_pypi to pypi - dummy commit to show that the workflows are basically the same --- .github/workflows/release_pypi.yml | 21 ++++++++++++--------- .github/workflows/release_test_pypi.yml | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index c3e93c26618..b12502be222 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -26,14 +26,14 @@ jobs: name: python-package-distributions path: dist/ - publish-to-pypi: - name: Publish to PyPI + publish-to-test-pypi: + name: Publish to Test PyPI needs: - build runs-on: ubuntu-latest environment: - name: release_pypi - url: https://pypi.org/p/python-telegram-bot + name: release_test_pypi + url: https://test.pypi.org/p/python-telegram-bot permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -43,14 +43,16 @@ jobs: with: name: python-package-distributions path: dist/ - - name: Publish to PyPI + - 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-pypi + - publish-to-test-pypi permissions: id-token: write # IMPORTANT: mandatory for sigstore @@ -80,8 +82,8 @@ jobs: name: python-package-distributions-and-signatures path: dist/ - github-release: - name: Upload to GitHub Release + github-test-release: + name: Upload to GitHub Release Draft needs: - compute-signatures @@ -99,13 +101,14 @@ jobs: - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} - # Create a tag and a GitHub Release. The description can be changed later, as for now + # 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 '${{ github.ref_name }}' --repo '${{ github.repository }}' --generate-notes + --draft - name: Upload artifact signatures to GitHub Release env: GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index 496c1d9b967..b12502be222 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -86,6 +86,7 @@ jobs: name: Upload to GitHub Release Draft needs: - compute-signatures + runs-on: ubuntu-latest permissions: From 6a155d369507267b93229c1e83dd43f8a87934ac Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:13:53 +0200 Subject: [PATCH 04/14] revert dummy commit --- .github/workflows/release_pypi.yml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index b12502be222..c3e93c26618 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -26,14 +26,14 @@ jobs: name: python-package-distributions path: dist/ - publish-to-test-pypi: - name: Publish to Test PyPI + publish-to-pypi: + name: Publish to PyPI needs: - build runs-on: ubuntu-latest environment: - name: release_test_pypi - url: https://test.pypi.org/p/python-telegram-bot + name: release_pypi + url: https://pypi.org/p/python-telegram-bot permissions: id-token: write # IMPORTANT: mandatory for trusted publishing @@ -43,16 +43,14 @@ jobs: with: name: python-package-distributions path: dist/ - - name: Publish to Test PyPI + - name: Publish to 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 + - publish-to-pypi permissions: id-token: write # IMPORTANT: mandatory for sigstore @@ -82,8 +80,8 @@ jobs: name: python-package-distributions-and-signatures path: dist/ - github-test-release: - name: Upload to GitHub Release Draft + github-release: + name: Upload to GitHub Release needs: - compute-signatures @@ -101,14 +99,13 @@ jobs: - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} - # Create a GitHub Release *draft*. The description can be changed later, as for now + # 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 '${{ github.ref_name }}' --repo '${{ github.repository }}' --generate-notes - --draft - name: Upload artifact signatures to GitHub Release env: GITHUB_TOKEN: ${{ github.token }} From a255ee5df68e7bb1132c81c58ce50c2ce0b77737 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:14:26 +0200 Subject: [PATCH 05/14] Update name --- .github/workflows/release_test_pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index b12502be222..ffc88b06576 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -1,4 +1,4 @@ -name: Publish to PyPI +name: Publish to Test PyPI on: # manually trigger the workflow From e26a039aaf2f68143499f2628b27bcaedb13091a Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:34:01 +0200 Subject: [PATCH 06/14] Get tag name from `__version__` --- .github/workflows/release_pypi.yml | 8 ++++++-- .github/workflows/release_test_pypi.yml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index c3e93c26618..f725c32bb49 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -96,6 +96,10 @@ jobs: with: name: python-package-distributions-and-signatures path: dist/ + - name: Get Tag Name + run: | + TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')") + echo "TAG=$TAG" >> $GITHUB_ENV - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} @@ -103,7 +107,7 @@ jobs: # we don't define it through this workflow. run: >- gh release create - '${{ github.ref_name }}' + '$TAG' --repo '${{ github.repository }}' --generate-notes - name: Upload artifact signatures to GitHub Release @@ -114,5 +118,5 @@ jobs: # sigstore-produced signatures and certificates. run: >- gh release upload - '${{ github.ref_name }}' dist/** + '$TAG' dist/** --repo '${{ github.repository }}' diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index ffc88b06576..3ea62e306a1 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -98,6 +98,10 @@ jobs: with: name: python-package-distributions-and-signatures path: dist/ + - name: Get Tag Name + run: | + TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')") + echo "TAG=$TAG" >> $GITHUB_ENV - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} @@ -105,7 +109,7 @@ jobs: # we don't define it through this workflow. run: >- gh release create - '${{ github.ref_name }}' + '$TAG' --repo '${{ github.repository }}' --generate-notes --draft @@ -117,5 +121,5 @@ jobs: # sigstore-produced signatures and certificates. run: >- gh release upload - '${{ github.ref_name }}' dist/** + '$TAG' dist/** --repo '${{ github.repository }}' From e620de050d7839e0f96742b36a92e2cdfcc58709 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:35:03 +0200 Subject: [PATCH 07/14] Temporarily run test_pypi_workflow on push for testing --- .github/workflows/release_test_pypi.yml | 3 +++ telegram/_version.py | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index 3ea62e306a1..e42ee5905a9 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -3,6 +3,9 @@ name: Publish to Test PyPI on: # manually trigger the workflow workflow_dispatch: + push: + branches: + - improve-pypi-automation jobs: build: diff --git a/telegram/_version.py b/telegram/_version.py index ec3f5618c21..9b581fa57f3 100644 --- a/telegram/_version.py +++ b/telegram/_version.py @@ -17,6 +17,7 @@ # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. # pylint: disable=missing-module-docstring +import random from typing import Final, NamedTuple __all__ = ("__version__", "__version_info__") @@ -51,6 +52,6 @@ def __str__(self) -> str: __version_info__: Final[Version] = Version( - major=21, minor=4, micro=0, releaselevel="final", serial=0 + major=21, minor=4, micro=0, releaselevel="final", serial=random.randint(0, 9999) ) __version__: Final[str] = str(__version_info__) From 8f1ce9c7ef5c89b71a51caa30137f83e8b7212c8 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:48:52 +0200 Subject: [PATCH 08/14] Change the version number to get a working testpypi build --- telegram/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegram/_version.py b/telegram/_version.py index 9b581fa57f3..1904e260557 100644 --- a/telegram/_version.py +++ b/telegram/_version.py @@ -52,6 +52,6 @@ def __str__(self) -> str: __version_info__: Final[Version] = Version( - major=21, minor=4, micro=0, releaselevel="final", serial=random.randint(0, 9999) + major=21, minor=5, micro=0, releaselevel="alpha", serial=random.randint(0, 9999) ) __version__: Final[str] = str(__version_info__) From 2a33269d56065d870acd8f2c89e1c67ac6895a01 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 17 Jul 2024 22:05:53 +0200 Subject: [PATCH 09/14] Try again getting the tag --- .github/workflows/release_pypi.yml | 9 +++++++++ .github/workflows/release_test_pypi.yml | 13 +++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index f725c32bb49..502e75321a4 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -8,6 +8,8 @@ jobs: build: name: Build Distribution runs-on: ubuntu-latest + outputs: + TAG: ${{ steps.get_tag.outputs.TAG }} steps: - uses: actions/checkout@v4 @@ -79,10 +81,16 @@ jobs: with: name: python-package-distributions-and-signatures path: dist/ + - name: Get Tag Name + id: get_tag + run: | + TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')") + echo "TAG=$TAG" >> $GITHUB_OUTPUT github-release: name: Upload to GitHub Release needs: + - build - compute-signatures runs-on: ubuntu-latest @@ -113,6 +121,7 @@ jobs: - 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. diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index e42ee5905a9..e61aeb672dd 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -11,6 +11,8 @@ jobs: build: name: Build Distribution runs-on: ubuntu-latest + outputs: + TAG: ${{ steps.get_tag.outputs.TAG }} steps: - uses: actions/checkout@v4 @@ -28,6 +30,11 @@ jobs: with: name: python-package-distributions path: dist/ + - name: Get Tag Name + id: get_tag + run: | + 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 @@ -88,6 +95,7 @@ jobs: github-test-release: name: Upload to GitHub Release Draft needs: + - build - compute-signatures runs-on: ubuntu-latest @@ -101,10 +109,6 @@ jobs: with: name: python-package-distributions-and-signatures path: dist/ - - name: Get Tag Name - run: | - TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')") - echo "TAG=$TAG" >> $GITHUB_ENV - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} @@ -119,6 +123,7 @@ jobs: - 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. From d4c0bcee89bb2dc66f606c095038f45383457b50 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 17 Jul 2024 22:21:44 +0200 Subject: [PATCH 10/14] Try again --- .github/workflows/release_pypi.yml | 11 ++++++----- .github/workflows/release_test_pypi.yml | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 502e75321a4..81b59a53ab6 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -27,6 +27,12 @@ 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 @@ -81,11 +87,6 @@ jobs: with: name: python-package-distributions-and-signatures path: dist/ - - name: Get Tag Name - id: get_tag - run: | - TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')") - echo "TAG=$TAG" >> $GITHUB_OUTPUT github-release: name: Upload to GitHub Release diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index e61aeb672dd..c1022908ff2 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -33,6 +33,7 @@ jobs: - 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 From 9aa72acee93d9f6d77852dc53e427684203b08dd Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 17 Jul 2024 22:38:40 +0200 Subject: [PATCH 11/14] try correctly using the tag in the gh release --- .github/workflows/release_pypi.yml | 5 +++-- .github/workflows/release_test_pypi.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 81b59a53ab6..211378bde05 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -112,11 +112,12 @@ 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 - '$TAG' + '${{ env.TAG }}' --repo '${{ github.repository }}' --generate-notes - name: Upload artifact signatures to GitHub Release @@ -128,5 +129,5 @@ jobs: # sigstore-produced signatures and certificates. run: >- gh release upload - '$TAG' dist/** + '${{ env.TAG }}' dist/** --repo '${{ github.repository }}' diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index c1022908ff2..c302acb948f 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -113,11 +113,12 @@ jobs: - 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 - '$TAG' + '${{ env.TAG }}' --repo '${{ github.repository }}' --generate-notes --draft @@ -130,5 +131,5 @@ jobs: # sigstore-produced signatures and certificates. run: >- gh release upload - '$TAG' dist/** + '${{ env.TAG }}' dist/** --repo '${{ github.repository }}' From f399926e5f49b84226c16b0bace8e88ad67a7275 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:41:59 +0200 Subject: [PATCH 12/14] Revert "Temporarily run test_pypi_workflow on push for testing" This reverts commit e620de05 --- .github/workflows/release_test_pypi.yml | 3 --- telegram/_version.py | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index c302acb948f..a8caeb95e3f 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -3,9 +3,6 @@ name: Publish to Test PyPI on: # manually trigger the workflow workflow_dispatch: - push: - branches: - - improve-pypi-automation jobs: build: diff --git a/telegram/_version.py b/telegram/_version.py index 1904e260557..ec3f5618c21 100644 --- a/telegram/_version.py +++ b/telegram/_version.py @@ -17,7 +17,6 @@ # You should have received a copy of the GNU Lesser Public License # along with this program. If not, see [http://www.gnu.org/licenses/]. # pylint: disable=missing-module-docstring -import random from typing import Final, NamedTuple __all__ = ("__version__", "__version_info__") @@ -52,6 +51,6 @@ def __str__(self) -> str: __version_info__: Final[Version] = Version( - major=21, minor=5, micro=0, releaselevel="alpha", serial=random.randint(0, 9999) + major=21, minor=4, micro=0, releaselevel="final", serial=0 ) __version__: Final[str] = str(__version_info__) From edac119922cec85c87e162f4f80dc001036bc4cb Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Fri, 26 Jul 2024 18:28:34 +0200 Subject: [PATCH 13/14] Remove a debug leftover --- .github/workflows/release_pypi.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index 211378bde05..e4707cd4f0d 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -105,10 +105,6 @@ jobs: with: name: python-package-distributions-and-signatures path: dist/ - - name: Get Tag Name - run: | - TAG=$(python -c "from telegram import __version__; print(f'v{__version__}')") - echo "TAG=$TAG" >> $GITHUB_ENV - name: Create GitHub Release env: GITHUB_TOKEN: ${{ github.token }} From 31c94076e3342fdcc0f5ce5223aa3f6337c2f754 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:09:41 +0200 Subject: [PATCH 14/14] update sigstore action --- .github/workflows/release_pypi.yml | 2 +- .github/workflows/release_test_pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release_pypi.yml b/.github/workflows/release_pypi.yml index e4707cd4f0d..8ebfd48887e 100644 --- a/.github/workflows/release_pypi.yml +++ b/.github/workflows/release_pypi.yml @@ -77,7 +77,7 @@ jobs: sha1sum $file > $file.sha1 done - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v2.1.1 + uses: sigstore/gh-action-sigstore-python@v3.0.0 with: inputs: >- ./dist/*.tar.gz diff --git a/.github/workflows/release_test_pypi.yml b/.github/workflows/release_test_pypi.yml index a8caeb95e3f..6009a98d7e0 100644 --- a/.github/workflows/release_test_pypi.yml +++ b/.github/workflows/release_test_pypi.yml @@ -79,7 +79,7 @@ jobs: sha1sum $file > $file.sha1 done - name: Sign the dists with Sigstore - uses: sigstore/gh-action-sigstore-python@v2.1.1 + uses: sigstore/gh-action-sigstore-python@v3.0.0 with: inputs: >- ./dist/*.tar.gz