From f4069288757361e3d653c7a6c5e9ee6f5bc75fa7 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Wed, 24 Jan 2024 14:53:34 +0000 Subject: [PATCH 1/4] update deployment and add docs --- .github/workflows/deploy-release.yml | 37 +++++++++++++++++++--------- docs/development/tools/release.md | 8 ++++-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 27ddfaf8ed..86e9e3b31c 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -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 @@ -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 diff --git a/docs/development/tools/release.md b/docs/development/tools/release.md index c47d4d7c42..1430a6eff8 100644 --- a/docs/development/tools/release.md +++ b/docs/development/tools/release.md @@ -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). From 50250474a10268dccdd182a6f36c324a52320844 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Wed, 24 Jan 2024 16:25:00 +0100 Subject: [PATCH 2/4] Apply suggestions from code review Co-authored-by: Rico Haeuselmann --- .github/workflows/deploy-release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 86e9e3b31c..1eb3be0e9c 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -22,10 +22,10 @@ jobs: run: | python -m build --sdist --wheel --outdir dist/ publish-pypi: - name: Publish Python distribution to test.pypi.org + name: Publish Python distribution to pypi.org runs-on: ubuntu-latest needs: build - if: ${{ github.event_name == 'workflow_dispatch' }} + if: ${{ github.event_name == 'workflow_dispatch' }} # the action was triggered manually environment: name: pypi url: https://pypi.org/project/gt4py @@ -38,7 +38,7 @@ jobs: name: Publish Python distribution to test.pypi.org runs-on: ubuntu-latest needs: build - if: ${{ github.event_name == 'release' }} + if: ${{ github.event_name == 'release' }} # triggered by releasing on github, test first before manually triggering the deployment to PyPI (see release documentation) environment: name: testpypi url: https://test.pypi.org/project/gt4py/ From 8adba4ebd8e97c10cc0c03fec875b18f6b9d6cf1 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Wed, 31 Jan 2024 18:09:17 +0100 Subject: [PATCH 3/4] add repository url and artifact step.yml --- .github/workflows/deploy-release.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 1eb3be0e9c..46ffcca9fd 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -1,6 +1,10 @@ name: Deploy Python Distribution on: + push: + branches: [ main ] + pull_request: + branches: [ main ] release: types: [published] workflow_dispatch: @@ -21,6 +25,11 @@ jobs: - name: Build a wheel and a source tarball run: | python -m build --sdist --wheel --outdir dist/ + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: gt4py-dist + path: ./dist/** publish-pypi: name: Publish Python distribution to pypi.org runs-on: ubuntu-latest @@ -32,6 +41,11 @@ jobs: permissions: id-token: write steps: + - name: Download wheel + uses: actions/download-artifact@v3 + with: + name: gt4py-dist + path: dist - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 publish-test-pypi: @@ -45,5 +59,12 @@ jobs: permissions: id-token: write steps: + - name: Download wheel + uses: actions/download-artifact@v3 + with: + name: gt4py-dist + path: dist - name: Publish distribution to Test PyPI uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ From aa7952c356d24f7e5d9cfd4dc296a3fa12349b62 Mon Sep 17 00:00:00 2001 From: Hannes Vogt Date: Wed, 31 Jan 2024 18:28:32 +0100 Subject: [PATCH 4/4] format --- .github/workflows/deploy-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-release.yml b/.github/workflows/deploy-release.yml index 46ffcca9fd..048a6f73e1 100644 --- a/.github/workflows/deploy-release.yml +++ b/.github/workflows/deploy-release.yml @@ -2,9 +2,9 @@ name: Deploy Python Distribution on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] release: types: [published] workflow_dispatch: