Skip to content

Commit

Permalink
Add Github actions to build, test and deploy the package
Browse files Browse the repository at this point in the history
  • Loading branch information
Kanma committed Apr 3, 2024
1 parent 64c6562 commit a37786d
Show file tree
Hide file tree
Showing 2 changed files with 146 additions and 0 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build
run-name: Build and test of commit "${{ github.event.head_commit.message }}"

on:
push:
branches:
- "*"
workflow_call:
inputs:
must_upload_pip_package_artifact:
default: true
required: false
type: boolean

jobs:
build-using-cmake:
name: Build using CMake

runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
compiler: [g++, clang++]

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Setup Eigen3
uses: kupns-aka-kupa/setup-eigen3@v1

- name: Install the Python dependencies
run: |
python3 -m venv /tmp/venv
source /tmp/venv/bin/activate
python -m pip install --upgrade pip
pip install numpy
- name: Configure CMake
run: |
source /tmp/venv/bin/activate
cmake -B ${{ steps.strings.outputs.build-output-dir }} \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} \
-DCMAKE_BUILD_TYPE=Release \
-S ${{ github.workspace }}
- name: Build
run: |
source /tmp/venv/bin/activate
cmake --build ${{ steps.strings.outputs.build-output-dir }}
- name: Install the Python library
run: |
source /tmp/venv/bin/activate
cmake --install ${{ steps.strings.outputs.build-output-dir }}
- name: Ensure the library is installed correctly
run: |
source /tmp/venv/bin/activate
python3 -c "from pygafro import *; robot = UR5()"
build-pip-package:
name: Build pip package

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Set reusable strings
id: strings
shell: bash
run: |
PACKAGE_VERSION=$(grep -e "version =" ${{ github.workspace }}/pyproject.toml)
PACKAGE_VERSION=$(python -c "print('${PACKAGE_VERSION}'.split(' ')[-1].replace('\"', ''))")
echo "package_version=${PACKAGE_VERSION}" >> "$GITHUB_OUTPUT"
- name: Setup Eigen3
uses: kupns-aka-kupa/setup-eigen3@v1

- name: Install the Python dependencies
run: python3 -m pip install --upgrade build

- name: Build the source package
run: python3 -m build --sdist

- name: Install (and compile) it
run: |
python3 -m venv /tmp/venv
source /tmp/venv/bin/activate
pip install dist/pygafro-${{ steps.strings.outputs.package_version }}.tar.gz
- name: Ensure the library is installed correctly
run: |
source /tmp/venv/bin/activate
python3 -c "from pygafro import *; robot = UR5()"
- name: Upload source package artifact
if: ${{ inputs.must_upload_pip_package_artifact == true }}
uses: actions/upload-artifact@v4
with:
name: pygafro_source_package
path: dist/pygafro-${{ steps.strings.outputs.package_version }}.tar.gz
31 changes: 31 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish
run-name: Publish package on PyPI

on:
release:
types: [published]

jobs:
publish-on-pypi:
name: Publish package on PyPI

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Install the Python dependencies
run: |
python -m pip install --upgrade pip
pip install twine build
- name: Build the source package
run: python3 -m build --sdist

- name: Upload to PyPI
run: twine upload dist/pygafro-*.tar.gz
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_KEY }}

0 comments on commit a37786d

Please sign in to comment.