From dff7de7dd95028b4562de53d8adbc4aa58e90ec5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 12 Jul 2023 23:54:25 -0500 Subject: [PATCH] fix: better structure for workflows (ci+cd) Signed-off-by: Henry Schreiner --- .../.github/workflows/ci.yml | 61 +-------------- ...r.__type != 'compiled' %}cd.yml{% endif %} | 74 +++++++++++++++++++ ....__type == 'compiled' %}cd.yml{% endif %}} | 0 3 files changed, 76 insertions(+), 59 deletions(-) create mode 100644 {{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type != 'compiled' %}cd.yml{% endif %} rename {{cookiecutter.project_name}}/.github/workflows/{{% if cookiecutter.__type == 'compiled' %}wheels.yml{% endif %} => {% if cookiecutter.__type == 'compiled' %}cd.yml{% endif %}} (100%) diff --git a/{{cookiecutter.project_name}}/.github/workflows/ci.yml b/{{cookiecutter.project_name}}/.github/workflows/ci.yml index 75c89874..3faecd00 100644 --- a/{{cookiecutter.project_name}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_name}}/.github/workflows/ci.yml @@ -1,4 +1,3 @@ -{%- set compiled = cookiecutter.backend in ["pybind11", "maturin", "skbuild", "mesonpy"] -%} name: CI on: @@ -9,11 +8,6 @@ on: - master - main - develop - {%- if not compiled %} - release: - types: - - published - {%- endif %} concurrency: group: {% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %} @@ -66,9 +60,11 @@ jobs: allow-prereleases: true {%- if cookiecutter.backend == "mesonpy" %} + - name: Activate MSVC for Meson if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@v1 + {%- endif %} - name: Install package @@ -82,56 +78,3 @@ jobs: - name: Upload coverage report uses: codecov/codecov-action@v3.1.4 - {%- if not compiled %} - - dist: - needs: [pre-commit] - name: Distribution build - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Build sdist and wheel - run: pipx run build - - - uses: actions/upload-artifact@v3 - with: - path: dist - - {%- if cookiecutter.backend != "trampolim" %} - - - name: Check products - run: pipx run twine check dist/* - - {%- endif %} - - publish: - needs: [dist] - name: Publish to PyPI - environment: pypi - permissions: - id-token: write - runs-on: ubuntu-latest - if: github.event_name == 'release' && github.event.action == 'published' - - steps: - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@release/v1 - if: github.event_name == 'release' && github.event.action == 'published' - with: - # Remember to tell (test-)pypi about this repo before publishing - # Remove this line to publish to PyPI - repository-url: https://test.pypi.org/legacy/ - {%- if cookiecutter.backend == "trampolim" %} - # Check not supported currently by twine + trampolim - verify-metadata: false - {%- endif %} - - {%- endif %} diff --git a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type != 'compiled' %}cd.yml{% endif %} b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type != 'compiled' %}cd.yml{% endif %} new file mode 100644 index 00000000..e24a4f41 --- /dev/null +++ b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type != 'compiled' %}cd.yml{% endif %} @@ -0,0 +1,74 @@ +{%- set compiled = cookiecutter.backend in ["pybind11", "maturin", "skbuild", "mesonpy"] -%} +name: CD + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - main + - develop + release: + types: + - published + +concurrency: + group: {% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %} + cancel-in-progress: true + +env: + FORCE_COLOR: 3 + +jobs: + dist: + needs: [pre-commit] + name: Distribution build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Build sdist and wheel + run: pipx run build + + - uses: actions/upload-artifact@v3 + with: + path: dist + + {%- if cookiecutter.backend != "trampolim" %} + + - name: Check products + run: pipx run twine check dist/* + + {%- endif %} + + publish: + needs: [dist] + name: Publish to PyPI + environment: pypi + permissions: + id-token: write + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + if: github.event_name == 'release' && github.event.action == 'published' + with: + # Remember to tell (test-)pypi about this repo before publishing + # Remove this line to publish to PyPI + repository-url: https://test.pypi.org/legacy/ + {%- if cookiecutter.backend == "trampolim" %} + # Check not supported currently by twine + trampolim + verify-metadata: false + {%- endif %} + + {%- endif %} diff --git a/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type == 'compiled' %}wheels.yml{% endif %} b/{{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type == 'compiled' %}cd.yml{% endif %} similarity index 100% rename from {{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type == 'compiled' %}wheels.yml{% endif %} rename to {{cookiecutter.project_name}}/.github/workflows/{% if cookiecutter.__type == 'compiled' %}cd.yml{% endif %}