Skip to content

Commit

Permalink
fix: better structure for workflows (ci+cd)
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Jul 13, 2023
1 parent 85b0083 commit 8123dcc
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 59 deletions.
61 changes: 2 additions & 59 deletions {{cookiecutter.project_name}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{%- set compiled = cookiecutter.backend in ["pybind11", "maturin", "skbuild", "mesonpy"] -%}
name: CI

on:
Expand All @@ -9,11 +8,6 @@ on:
- master
- main
- develop
{%- if not compiled %}
release:
types:
- published
{%- endif %}

concurrency:
group: {% raw %}${{ github.workflow }}-${{ github.ref }}{% endraw %}
Expand Down Expand Up @@ -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
Expand All @@ -82,56 +78,3 @@ jobs:
- name: Upload coverage report
uses: codecov/[email protected]

{%- 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 %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
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 %}

0 comments on commit 8123dcc

Please sign in to comment.