Skip to content

Commit 641255b

Browse files
authored
ci: separate workflows for build and deploy (#73)
1 parent 5559d41 commit 641255b

3 files changed

Lines changed: 73 additions & 46 deletions

File tree

.github/workflows/build.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
jobs:
8+
build:
9+
name: Build Package
10+
runs-on: ${{ matrix.os }}-latest
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [windows, ubuntu, macos]
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4.1.1
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v5.0.0
21+
with:
22+
python-version: 3.11
23+
24+
- name: Setup Poetry
25+
uses: threeal/setup-poetry-action@v1.0.0
26+
27+
- name: Cache Dependencies
28+
id: cache-deps
29+
uses: actions/cache@v3.3.2
30+
with:
31+
path: .venv
32+
key: poetry-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
33+
34+
- name: Install Dependencies
35+
if: steps.cache-deps.outputs.cache-hit != 'true'
36+
run: poetry install --with dev
37+
38+
- name: Check Format
39+
run: poetry run poe format && git diff --exit-code HEAD
40+
41+
- name: Check Lint
42+
run: poetry run poe lint
43+
44+
- name: Test Package
45+
run: poetry run poe test
46+
47+
- name: Generate Documentation
48+
run: poetry run poe docs
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
name: CI
1+
name: Deploy
22
on:
33
workflow_dispatch:
4-
pull_request:
54
push:
65
branches: [main]
76
jobs:
8-
build:
9-
name: Build
10-
runs-on: ${{ matrix.os }}-latest
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
os: [windows, ubuntu, macos]
7+
deploy-pages:
8+
name: Deploy Pages
9+
runs-on: ubuntu-latest
10+
permissions:
11+
pages: write
12+
id-token: write
13+
environment:
14+
name: github-pages
15+
url: ${{ steps.deploy-pages.outputs.page_url }}
16+
concurrency:
17+
group: pages
18+
cancel-in-progress: false
1519
steps:
20+
- name: Setup Pages
21+
uses: actions/configure-pages@v4.0.0
22+
1623
- name: Checkout
1724
uses: actions/checkout@v4.1.1
1825

@@ -24,54 +31,25 @@ jobs:
2431
- name: Setup Poetry
2532
uses: threeal/setup-poetry-action@v1.0.0
2633

27-
- name: Cache deps
28-
id: cache_deps
34+
- name: Cache Dependencies
35+
id: cache-deps
2936
uses: actions/cache@v3.3.2
3037
with:
3138
path: .venv
3239
key: poetry-${{ runner.os }}-${{ hashFiles('pyproject.toml') }}
3340

34-
- name: Install deps
35-
if: steps.cache_deps.outputs.cache-hit != 'true'
41+
- name: Install Dependencies
42+
if: steps.cache-deps.outputs.cache-hit != 'true'
3643
run: poetry install --with dev
3744

38-
- name: Check format
39-
run: poetry run poe format && git diff --exit-code HEAD
40-
41-
- name: Check lint
42-
run: poetry run poe lint
43-
44-
- name: Run testing
45-
run: poetry run poe test
46-
47-
- name: Generate docs
45+
- name: Generate Documentation
4846
run: poetry run poe docs
4947

50-
- name: Upload docs artifact
51-
if: ${{ matrix.os }} == 'ubuntu'
48+
- name: Upload Documentation
5249
uses: actions/upload-pages-artifact@v3.0.0
5350
with:
5451
path: docs
5552

56-
deploy:
57-
name: Deploy
58-
if: github.event_name != 'pull_request' && github.ref_name == 'main'
59-
needs: build
60-
runs-on: ubuntu-latest
61-
permissions:
62-
contents: read
63-
pages: write
64-
id-token: write
65-
environment:
66-
name: github-pages
67-
url: ${{ steps.deployment.outputs.page_url }}
68-
concurrency:
69-
group: pages
70-
cancel-in-progress: false
71-
steps:
72-
- name: Setup Pages
73-
uses: actions/configure-pages@v4.0.0
74-
7553
- name: Deploy Pages
76-
id: deployment
54+
id: deploy-pages
7755
uses: actions/deploy-pages@v4.0.2

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
[![version](https://img.shields.io/github/v/release/threeal/python-starter?style=flat-square)](https://github.com/threeal/python-starter/releases)
44
[![license](https://img.shields.io/github/license/threeal/python-starter?style=flat-square)](./LICENSE)
5-
[![build status](https://img.shields.io/github/actions/workflow/status/threeal/python-starter/ci.yaml?branch=main&style=flat-square)](https://github.com/threeal/python-starter/actions/workflows/ci.yaml)
5+
[![build status](https://img.shields.io/github/actions/workflow/status/threeal/python-starter/build.yaml?branch=main&style=flat-square)](https://github.com/threeal/python-starter/actions/workflows/build.yaml)
6+
[![deploy status](https://img.shields.io/github/actions/workflow/status/threeal/python-starter/deploy.yaml?branch=main&label=deploy&style=flat-square)](https://github.com/threeal/python-starter/actions/workflows/deploy.yaml)
67

78
The Python Starter is a [GitHub repository template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) that provides a minimalistic boilerplate to kickstart your [Python](https://www.python.org/) project. This template offers a streamlined foundation, complete with predefined file structures, essential tools, and recommended settings, ensuring a swift and efficient start to your Python development journey.
89

0 commit comments

Comments
 (0)