Skip to content

Commit 6113608

Browse files
authored
Merge pull request #24 from rjw57/release-stages
Build packages and docs using post-release bump contents
2 parents 4c865d9 + efe8c96 commit 6113608

File tree

6 files changed

+89
-56
lines changed

6 files changed

+89
-56
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: install dependencies
2+
description: install poetry and package dependencies in a dedicated venv
3+
inputs:
4+
python-version:
5+
description: Version of Python to use to install poetry
6+
required: false
7+
default: "3.13"
8+
cache-key-prefix:
9+
description: Prefix used to form dependency cache key
10+
required: false
11+
default: "poetry"
12+
runs:
13+
using: composite
14+
steps:
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.13"
19+
- name: Install poetry
20+
uses: abatilo/actions-poetry@v3
21+
- name: Setup a local virtual environment
22+
shell: bash
23+
run: |
24+
poetry config virtualenvs.create true --local
25+
poetry config virtualenvs.in-project true --local
26+
- uses: actions/cache@v4
27+
name: Define a cache for the virtual environment based on the dependencies lock file
28+
with:
29+
path: ./.venv
30+
key: ${{ inputs.cache-key-prefix }}|${{ env.pythonLocation }}|${{ hashFiles('poetry.lock') }}
31+
- name: Install the project dependencies
32+
shell: bash
33+
run: poetry install
Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
name: pre-commit
22
description: run pre-commit
33
inputs:
4-
extra_args:
4+
extra-args:
55
description: options to pass to pre-commit run
66
required: false
77
default: "--all-files"
8+
python-version:
9+
description: Version of Python to use to install pre-commit
10+
required: false
11+
default: "3.13"
12+
cache-key-prefix:
13+
description: Prefix used to form pre-commit cache key
14+
required: false
15+
default: "pre-commit"
816
runs:
917
using: composite
1018
steps:
11-
- uses: actions/checkout@v4
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "${{ inputs.python-version }}"
1223
- name: Install pre-commit
1324
run: pipx install pre-commit
1425
shell: bash
@@ -19,6 +30,6 @@ runs:
1930
- uses: actions/cache@v4
2031
with:
2132
path: ~/.cache/pre-commit
22-
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
23-
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra_args }}
33+
key: ${{ inputs.cache-key-prefix}}|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
34+
- run: pre-commit run --show-diff-on-failure --color=always ${{ inputs.extra-args }}
2435
shell: bash
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: prepare release
2+
description: modify working directory as if a release is going to be made
3+
runs:
4+
using: composite
5+
steps:
6+
- uses: actions/setup-node@v4
7+
with:
8+
cache: npm
9+
node-version: lts/*
10+
cache-dependency-path: "./.github/workflows/*.yml"
11+
- name: Prepare release
12+
shell: bash
13+
run: |
14+
npx -p @release-it/bumper -p @release-it/conventional-changelog release-it \
15+
--no-git.commit --no-git.push --no-git.tag --no-github

.github/workflows/main.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,19 @@ jobs:
1919
uses: actions/checkout@v4
2020
with:
2121
fetch-depth: 0
22-
- name: Set up Python
23-
uses: actions/setup-python@v5
24-
with:
25-
python-version: "3.12"
26-
- name: Install poetry
27-
uses: abatilo/actions-poetry@v3
2822
- name: Configure git
2923
run: |
3024
git config user.name "${GITHUB_ACTOR}"
3125
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
26+
- name: Download release artifacts
27+
uses: actions/download-artifact@v4
28+
with:
29+
name: python-dist
30+
path: dist/
3231
- name: Create release
3332
run: npx -p @release-it/bumper -p @release-it/conventional-changelog release-it
3433
env:
3534
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
- name: Upload artifacts for publication
37-
uses: actions/upload-artifact@v4
38-
with:
39-
name: python-dist
40-
path: dist/*
4135
pages:
4236
name: GitHub pages
4337
needs: [release]

.github/workflows/tests.yml

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ jobs:
1111
runs-on: ubuntu-24.04
1212
steps:
1313
- uses: actions/checkout@v4
14-
- name: Set up Python
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: "3.12"
1814
- uses: ./.github/actions/pre-commit
1915
commitlint:
2016
name: commitlint
@@ -30,51 +26,38 @@ jobs:
3026
python-version: ["3.10", "3.11", "3.12", "3.13"]
3127
steps:
3228
- uses: actions/checkout@v4
33-
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v5
29+
- uses: ./.github/actions/install-deps
3530
with:
3631
python-version: ${{ matrix.python-version }}
37-
- name: Install poetry
38-
uses: abatilo/actions-poetry@v3
39-
- name: Setup a local virtual environment
40-
run: |
41-
poetry config virtualenvs.create true --local
42-
poetry config virtualenvs.in-project true --local
43-
- uses: actions/cache@v4
44-
name: Define a cache for the virtual environment based on the dependencies lock file
45-
with:
46-
path: ./.venv
47-
key: venv-${{ hashFiles('poetry.lock') }}
48-
- name: Install the project dependencies
49-
run: poetry install
5032
- name: Run tests
5133
run: poetry run pytest -v
34+
build:
35+
name: build distribution artifacts
36+
runs-on: ubuntu-24.04
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0 # required for release-bumper action
41+
- uses: ./.github/actions/release-bumper
42+
- uses: ./.github/actions/install-deps
43+
- name: Build the Python package
44+
run: poetry build
45+
- name: Upload Python build artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: python-dist
49+
path: dist/*
5250
mkdocs:
5351
name: build documentation
5452
runs-on: ubuntu-24.04
5553
steps:
5654
- uses: actions/checkout@v4
57-
- name: Set up Python
58-
uses: actions/setup-python@v5
59-
with:
60-
python-version: "3.13"
61-
- name: Install poetry
62-
uses: abatilo/actions-poetry@v3
63-
- name: Setup a local virtual environment
64-
run: |
65-
poetry config virtualenvs.create true --local
66-
poetry config virtualenvs.in-project true --local
67-
- uses: actions/cache@v4
68-
name: Define a cache for the virtual environment based on the dependencies lock file
6955
with:
70-
path: ./.venv
71-
key: venv-docs-${{ hashFiles('poetry.lock') }}
72-
- name: Install the project dependencies
73-
run: poetry install
56+
fetch-depth: 0 # required for release-bumper action
57+
- uses: ./.github/actions/install-deps
58+
- uses: ./.github/actions/release-bumper
7459
- name: Build the documentation
75-
run: |
76-
poetry run mkdocs build
77-
touch site/.nojekyll
60+
run: poetry run mkdocs build
7861
- name: Upload GitHub pages artefact
7962
uses: actions/upload-pages-artifact@v3
8063
with:

.release-it.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,5 @@
2222
"path": "tool.poetry.version"
2323
}
2424
}
25-
},
26-
"hooks": {
27-
"after:bump": "poetry build"
2825
}
2926
}

0 commit comments

Comments
 (0)