From d276165ab4b95bddadba93b68d83c2ce5111c2ad Mon Sep 17 00:00:00 2001 From: Benjamin Lefaudeux Date: Wed, 6 Nov 2024 22:25:28 +0100 Subject: [PATCH] giving this a go --- .github/workflows/ci-cd.yml | 89 +++++++++++++++++++++++++++++++++++++ README.md | 2 +- generate_python_package.sh | 2 +- pyproject.toml | 2 +- 4 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci-cd.yml diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml new file mode 100644 index 0000000..770bbfb --- /dev/null +++ b/.github/workflows/ci-cd.yml @@ -0,0 +1,89 @@ +name: Push to PyPI + +on: + release: + types: [published] + + pull_request: + branches: ["main"] + +jobs: + pypi-publish: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/p/datago + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + + - name: Install linux deps + run: | + sudo apt-get update + sudo apt-get -y install libvips-dev libjpeg-turbo8-dev + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23" + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.11.10" + + - name: Install pybindgen + run: | + python3 -m pip install pybindgen + go install golang.org/x/tools/cmd/goimports@latest + go install github.com/go-python/gopy@latest + + - name: Get next version + uses: reecetech/version-increment@2024.10.1 + id: version + with: + scheme: calver + increment: patch + + - name: Build python module + run: | + cd pkg + gopy pkg -author="Photoroom" -email="team@photoroom.com" -name="datago" -version="${{ steps.version.outputs.version }}" . + export DESTINATION="../build" + mkdir -p $DESTINATION/datago + mv datago/* $DESTINATION/datago/. + mv setup.py $DESTINATION/. + mv Makefile $DESTINATION/. + mv README.md $DESTINATION/. + rm LICENSE MANIFEST.in + ls + cd ../build + + - name: Install python module + run: | + ls + cd build + python3 -m pip install --user -v -e . + + - name: Run the python unit tests + env: + DATAROOM_API_KEY: ${{ secrets.DATAROOM_API_KEY }} + DATAROOM_TEST_SOURCE: ${{ secrets.DATAROOM_TEST_SOURCE }} + DATAROOM_API_URL: ${{ secrets.DATAROOM_API_URL }} + run: | + ls + python3 -m pip install -r requirements.txt + pytest -xv python/tests/* + + - name: Build the package + run: | + cd build + python3 setup.py sdist + mv dist ../. + cd .. + ls + + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index ebbb6b4..a0bbecd 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ $ sudo ldconfig From the root of this project: ```bash -$ go build cmd/main/main.go +$ go build cmd/main.go ``` Running it: diff --git a/generate_python_package.sh b/generate_python_package.sh index 32a3f51..df3d465 100755 --- a/generate_python_package.sh +++ b/generate_python_package.sh @@ -12,7 +12,7 @@ rm -rf $DESTINATION # Build the python package via the gopy toolchain cd pkg -gopy pkg -author="Photoroom" -email="team@photoroom.com" -url="" -name="datago" -version="0.3" . +gopy pkg -author="Photoroom" -email="team@photoroom.com" -url="" -name="datago" -version="0.0.1". mkdir -p $DESTINATION/datago mv datago/* $DESTINATION/datago/. mv setup.py $DESTINATION/. diff --git a/pyproject.toml b/pyproject.toml index 56ccdfb..0dfacd8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "datago" -version = "0.0.1" +version = "0.6" authors = [ { name="Photoroom", email="team@photoroom.com" }, ]