From b087a7ed11453f88c28d3ddf21be99f3c62f18da Mon Sep 17 00:00:00 2001 From: Valentin LE BESCOND Date: Fri, 26 Jul 2024 11:19:04 +0200 Subject: [PATCH] Add release ci (#8) * feat: Add GitHub workflows for building and publishing Python package distributions --- .github/workflows/build-dist.yml | 27 ++++++++++++++++++ .github/workflows/publish-to-pypi.yml | 30 ++++++++++++++++++++ .github/workflows/publish-to-test-pypi.yml | 32 ++++++++++++++++++++++ .github/workflows/test.yml | 8 ++++-- pyproject.toml | 2 +- setup.cfg | 15 ---------- 6 files changed, 95 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/build-dist.yml create mode 100644 .github/workflows/publish-to-pypi.yml create mode 100644 .github/workflows/publish-to-test-pypi.yml delete mode 100644 setup.cfg diff --git a/.github/workflows/build-dist.yml b/.github/workflows/build-dist.yml new file mode 100644 index 0000000..6d901ff --- /dev/null +++ b/.github/workflows/build-dist.yml @@ -0,0 +1,27 @@ +name: Build package + +on: [workflow_call] + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install pypa/build + run: python3 -m pip install build --user + + - name: Build a binary wheel and a source tarball + run: python3 -m build + + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..481ab76 --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,30 @@ +name: Publish package to PyPi + +on: + release: + types: [published] + workflow_dispatch: + +jobs: + test: + uses: ./.github/workflows/test.yml + build: + uses: ./.github/workflows/build-dist.yml + publish-to-pypi: + name: Publish to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: [test, build] + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/acoustic-tools + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..35373c3 --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -0,0 +1,32 @@ +name: Publish package to TestPyPi + +on: + # push: + # branches: + # - 'main' + workflow_dispatch: + +jobs: + test: + uses: ./.github/workflows/test.yml + build: + uses: ./.github/workflows/build-dist.yml + publish-to-testpypi: + name: Publish to TestPyPI + needs: [test, build] + runs-on: ubuntu-latest + environment: + name: testpypi + url: https://test.pypi.org/p/acoustic-tools + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + 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/ \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fda6836..4d90575 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,11 @@ -name: Run Unit Test via Pytest +name: Test package -on: [push] +on: [push, workflow_call] jobs: - build: + test-pytest: + name: Test with Pytest + runs-on: ubuntu-latest strategy: matrix: diff --git a/pyproject.toml b/pyproject.toml index 769a053..51c24d9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "flit_core.buildapi" [project] name = "acoustic-toolbox" -version = "0.1.0" +version = "0.1.1" authors = [ { name = "Valentin LE BESCOND", email = "valentin.lebescond@univ-eiffel.fr" } ] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7a78817..0000000 --- a/setup.cfg +++ /dev/null @@ -1,15 +0,0 @@ -[tools:pytest] -norecursedirs = build .eggs .tox - -[yapf] -based_on_style = pep8 -allow_multiline_lambdas = true -coalesce_brackets = true -column_limit = 120 -indent_dictionary_value = true -split_before_named_assigns = false -split_penalty_for_added_line_split = 0 -split_before_logical_operator = false -split_all_comma_separated_values = false -split_before_expression_after_opening_paren = true -split_arguments_when_comma_terminated = true