Skip to content

Commit

Permalink
re-usable build workflow and upload to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
aktech committed Oct 16, 2024
1 parent eda3fa1 commit bd3919d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 43 deletions.
38 changes: 38 additions & 0 deletions .github/reusable-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Resusable steps to build tfx-bsl

inputs:
python-version:
description: 'Python version'
required: true
runs:
using: 'composite'
steps:

- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Upgrade pip
shell: bash
run: |
python -m pip install --upgrade pip pytest
- name: Build the package for Python ${{ inputs.python-version }}
shell: bash
run: |
version="${{ inputs.python-version }}"
docker compose run -e PYTHON_VERSION=$(echo "$version" | sed 's/\.//') manylinux2010
- name: Upload wheel artifact for Python ${{ inputs.python-version }}
uses: actions/upload-artifact@v4.4.0
with:
name: tfx-bsl-wheel-py${{ inputs.python-version }}
path: dist/*.whl

- name: Install built wheel
shell: bash
run: |
pip install twine
twine check dist/*
pip install dist/*.whl
46 changes: 26 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,34 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Build tfx-bsl
id: build-tfx-bsl
uses: ./.github/reusable-build
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
python -m pip install --upgrade pip

- name: Build the manylinux2010 image
run: docker compose build manylinux2010

- name: Build the package for Python ${{ matrix.python-version }}
run: |
version="${{ matrix.python-version }}"
docker compose run -e PYTHON_VERSION=$(echo "$version" | sed 's/\.//') manylinux2010
- name: Upload wheel artifact for Python ${{ matrix.python-version }}
uses: actions/upload-artifact@v3
with:
name: tfx-bsl-wheel-py${{ matrix.python-version }}
path: dist/*.whl
upload_to_pypi:
name: Upload to PyPI
runs-on: ubuntu-latest
if: (github.event_name == 'release' && startsWith(github.ref, 'refs/tags')) || (github.event_name == 'workflow_dispatch')
needs: [build]
environment:
name: pypi
url: https://pypi.org/p/struct2tensor/
permissions:
id-token: write
steps:
- name: Retrieve wheels
uses: actions/download-artifact@v4.1.8
with:
merge-multiple: true
path: wheels

- name: Install built wheel
run: pip install dist/*.whl
- name: List the build artifacts
run: |
ls -lAs wheels/
- name: Upload to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.9
with:
packages_dir: wheels/
26 changes: 3 additions & 23 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,12 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
- name: Build tfx-bsl
id: build-tfx-bsl
uses: ./.github/reusable-build
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Build the manylinux2010 image
run: docker compose build manylinux2010

- name: Build the package for Python ${{ matrix.python-version }}
run: |
version="${{ matrix.python-version }}"
docker compose run -e PYTHON_VERSION=$(echo "$version" | sed 's/\.//') manylinux2010
- name: Upload wheel artifact for Python ${{ matrix.python-version }}
uses: actions/upload-artifact@v3
with:
name: tfx-bsl-wheel-py${{ matrix.python-version }}
path: dist/*.whl

- name: Install built wheel
run: pip install dist/*.whl

- name: Test
run: |
pip install pytest
Expand Down

0 comments on commit bd3919d

Please sign in to comment.