Skip to content

Commit

Permalink
Add build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
angelhof committed Dec 17, 2024
1 parent 5f79dea commit a1cdd1f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Main workflow

on:
pull_request:
push:
schedule:
- cron: '5 14 * * *'

jobs:
check-version-numbers:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Check version numbers
run: ./version.sh

package-python:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Upgrade pip and build
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build
- name: Build wheel
run: python3 -m build

- name: Upload binary wheel
uses: actions/upload-artifact@v4
with:
name: dist
path: ./dist/*.whl

deploy:
needs:
- check-version-numbers
- package-python
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags')

steps:
- name: Download distributions
uses: actions/download-artifact@v4

# - name: Deploy test distribution to Test PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# verbose: true
# repository_url: https://test.pypi.org/legacy/
# skip_existing: true

- name: Deploy tagged release on PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true
12 changes: 12 additions & 0 deletions version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

PYTHON_VERSION=$(grep -e '^version =' pyproject.toml | cut -d'=' -f2 | tr -d ' "')

PYTHON_VERSION2=$(grep -e 'version=' setup.py | cut -d'=' -f2 | tr -d "',")

[ "$PYTHON_VERSION" = "$PYTHON_VERSION2" ] && echo "$PYTHON_VERSION" && exit 0

echo "Version numbers don't match!"
echo " Python is '$PYTHON_VERSION' in pyproject.toml"
echo " Python is '$PYTHON_VERSION2' in setup.py"
exit 1

0 comments on commit a1cdd1f

Please sign in to comment.