From 8381865cf76eb6b05dfae7ae833d95dd3b2b5cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Paw=C5=82owski?= Date: Thu, 16 Jan 2025 12:21:15 +0000 Subject: [PATCH 1/4] pip publish workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Pawłowski --- .github/workflows/build_wheels.yaml | 109 ++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 .github/workflows/build_wheels.yaml diff --git a/.github/workflows/build_wheels.yaml b/.github/workflows/build_wheels.yaml new file mode 100644 index 00000000..8b94c106 --- /dev/null +++ b/.github/workflows/build_wheels.yaml @@ -0,0 +1,109 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License + +name: PyPi releases + +on: + push: + workflow_dispatch: + inputs: + testpypi: + type: boolean + required: false + default: false + tag: + type: string + required: true + + +jobs: + build: + # to build only on push to tags or on custom dispatched workflows + if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') + name: Build distribution 📦 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - 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: Clone xpk from tag + if: github.event_name == 'worfklow_dispatch' + run: git clone --branch=${{inputs.tag}} https://github.com/AI-Hypercomputer/xpk.git + - name: Enter directory + if: github.event_name == 'worfklow_dispatch' + run: cd xpk + - 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-testpypi: + if: ${{inputs.testpypi}} == true + name: Publish Python 🐍 distribution 📦 to TestPyPI + needs: + - build + runs-on: ubuntu-latest + environment: + # We should configure trusted publishing as specified here: + # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing + name: testpypi + url: https://test.pypi.org/p/xpk + 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 distribution 📦 to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + + publish-to-pypi: + name: >- + Publish new xpk version to pypi + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + # We should configure trusted publishing as specified here: + # https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/#configuring-trusted-publishing + name: pypi + url: https://pypi.org/p/xpk # Replace with your PyPI project name + 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 distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From 08b625e1ad52402a3f67ea168ddd2663e4ea2263 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Paw=C5=82owski?= Date: Mon, 20 Jan 2025 13:46:01 +0000 Subject: [PATCH 2/4] fix typos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Pawłowski --- .github/workflows/build_wheels.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_wheels.yaml b/.github/workflows/build_wheels.yaml index 8b94c106..4bc03b40 100644 --- a/.github/workflows/build_wheels.yaml +++ b/.github/workflows/build_wheels.yaml @@ -62,7 +62,7 @@ jobs: path: dist/ publish-to-testpypi: if: ${{inputs.testpypi}} == true - name: Publish Python 🐍 distribution 📦 to TestPyPI + name: Publish Python distribution to TestPyPI needs: - build runs-on: ubuntu-latest @@ -105,5 +105,5 @@ jobs: with: name: python-package-distributions path: dist/ - - name: Publish distribution 📦 to PyPI + - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file From a3e86002a55f74d988e6e0fc8c0274095dbc6244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Paw=C5=82owski?= Date: Mon, 27 Jan 2025 12:45:15 +0000 Subject: [PATCH 3/4] test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Pawłowski --- .github/workflows/build_wheels.yaml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_wheels.yaml b/.github/workflows/build_wheels.yaml index 4bc03b40..0be235fb 100644 --- a/.github/workflows/build_wheels.yaml +++ b/.github/workflows/build_wheels.yaml @@ -15,7 +15,6 @@ name: PyPi releases on: - push: workflow_dispatch: inputs: testpypi: @@ -29,10 +28,10 @@ on: jobs: build: + name: Build distribution + runs-on: ubuntu-latest # to build only on push to tags or on custom dispatched workflows if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') - name: Build distribution 📦 - runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: From 4b5c0ff183d9376812804eeec068f8f7c0029624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Paw=C5=82owski?= Date: Mon, 27 Jan 2025 12:51:01 +0000 Subject: [PATCH 4/4] review fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piotr Pawłowski --- .github/workflows/build_wheels.yaml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_wheels.yaml b/.github/workflows/build_wheels.yaml index 0be235fb..229b37f5 100644 --- a/.github/workflows/build_wheels.yaml +++ b/.github/workflows/build_wheels.yaml @@ -15,6 +15,7 @@ name: PyPi releases on: + push: workflow_dispatch: inputs: testpypi: @@ -41,7 +42,7 @@ jobs: with: python-version: "3.x" - name: Install pypa/build - run: >- + run: | python3 -m pip install build @@ -81,11 +82,9 @@ jobs: - name: Publish distribution 📦 to TestPyPI uses: pypa/gh-action-pypi-publish@release/v1 with: - repository-url: https://test.pypi.org/legacy/ - + repository-url: https://test.pypi.org/legacy/ ` publish-to-pypi: - name: >- - Publish new xpk version to pypi + name: Publish Python distribution to PyPI if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes needs: - build