Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Update deployment action with trusted publisher #1423

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
workflow_dispatch:

jobs:
build-n-publish:
name: Build and publish Python distribution
build:
name: Build Python distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
Expand All @@ -21,14 +21,29 @@ jobs:
- name: Build a wheel and a source tarball
run: |
python -m build --sdist --wheel --outdir dist/
- name: Publish distribution to Test PyPI
if: ${{ github.event_name == 'release' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
publish-pypi:
name: Publish Python distribution to test.pypi.org
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'workflow_dispatch' }}
environment:
name: pypi
url: https://pypi.org/project/gt4py
permissions:
id-token: write
steps:
- name: Publish distribution to PyPI
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
publish-test-pypi:
name: Publish Python distribution to test.pypi.org
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'release' }}
environment:
name: testpypi
url: https://test.pypi.org/project/gt4py/
permissions:
id-token: write
steps:
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing url?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on the documentation here (https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#separate-workflow-for-publishing-to-testpypi), it looks like the repository-url key might be missing:

      with:
        repository-url: https://test.pypi.org/legacy/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sorry, that comment was for me to add exactly that

8 changes: 6 additions & 2 deletions docs/development/tools/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ Currently, GT4Py releases are published in PyPI (and TestPyPI) and also as commi

5. On the GitHub website go to _Releases_ and _Draft a new release_. Choose `v0.{M}.{m}.{p}` as tag and select a branch (usually `main`). Follow the style of the previous releases for the title (`GT4Py v0.{M}.{m}.{p}`) and description. Then _Publish release_.

6. Upload distribution package to TestPyPI and quickly test that it works properly.
6. Publishing the release will trigger a Github action to deploy to TestPyPI. Install the package from TestPyPi and do basic tests.

7. Upload distribution package to PyPI and quickly that test it works properly.
7. If tests are ok, manually trigger the deploy Github action selecting the release tag as target. This will publish the package to PyPI. Install the package and test if it works.

## PyPi and TestPyPi accounts

The account is called `gridtools`. Credentials can be found in the bitwarden of CSCS. For 2FA, the recovery keys are stored in bitwarden, too. In case a new developer should get access, the recovery keys can be used to setup the authentication app (for all developers who should have access).

<!-- Reference links -->

Expand Down
Loading