Skip to content

Commit c3c635f

Browse files
committed
Add test and release workflows
1 parent 72c7de2 commit c3c635f

File tree

2 files changed

+119
-7
lines changed

2 files changed

+119
-7
lines changed

.github/workflows/release.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- 'v*' # Triggers on new version tags
6+
7+
jobs:
8+
tests:
9+
uses: ./.github/workflows/test.yml
10+
11+
publish-to-pypi:
12+
name: Publish to PyPI
13+
needs:
14+
- tests
15+
runs-on: ubuntu-latest
16+
environment:
17+
name: pypi
18+
# TODO
19+
url: https://pypi.org/p/project-name
20+
permissions:
21+
id-token: write
22+
steps:
23+
- uses: actions/checkout@v3
24+
25+
- name: Install poetry
26+
run: pipx install poetry
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: '3.10'
32+
33+
- name: Build a binary wheel
34+
run: poetry build
35+
36+
- name: Publish distribution 📦 to PyPI
37+
uses: pypa/gh-action-pypi-publish@release/v1
38+
39+
github-release:
40+
name: Create GitHub Release
41+
needs:
42+
- publish-to-pypi
43+
runs-on: ubuntu-latest
44+
permissions:
45+
contents: write
46+
steps:
47+
- uses: actions/checkout@v3
48+
49+
- name: Check package version matches tag
50+
id: check-version
51+
uses: samuelcolvin/[email protected]
52+
with:
53+
version_file_path: 'pyproject.toml'
54+
55+
- name: Create GitHub Release
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
tag: ${{ github.ref_name }}
59+
run: |
60+
gh release create "$tag" \
61+
--repo="$GITHUB_REPOSITORY" \
62+
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
63+
--generate-notes
64+
65+
update_docs:
66+
name: Update Documentation
67+
needs:
68+
- github-release
69+
runs-on: ubuntu-latest
70+
permissions:
71+
contents: write
72+
steps:
73+
- uses: actions/checkout@v3
74+
with:
75+
fetch-depth: 0
76+
77+
- name: Install poetry
78+
run: pipx install poetry
79+
80+
- name: Setup Python
81+
uses: actions/setup-python@v4
82+
with:
83+
python-version: '3.10'
84+
cache: 'poetry'
85+
86+
- name: Configure Git user
87+
run: |
88+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
89+
git config --local user.name "github-actions[bot]"
90+
91+
- name: Retrieve version
92+
id: check-version
93+
uses: samuelcolvin/[email protected]
94+
with:
95+
version_file_path: 'pyproject.toml'
96+
skip_env_check: true
97+
98+
- name: Deploy the docs
99+
run: |
100+
poetry run mike deploy \
101+
--update-aliases \
102+
--push \
103+
--branch docs-site \
104+
${{ steps.check-version.outputs.VERSION_MAJOR_MINOR }} latest

.github/workflows/main.yaml renamed to .github/workflows/test.yaml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
name: test
2-
run-name: Test
3-
on: [ push ]
1+
name: Test
2+
on:
3+
workflow_call: # Allows this workflow to be called by other workflows
4+
push:
5+
branches:
6+
- master
7+
- main
8+
pull_request:
9+
410
jobs:
511
test:
12+
name: Test
613
strategy:
714
fail-fast: false
815
matrix:
916
python-version: [ '3.10', '3.11', '3.12' ]
10-
os: [ ubuntu-latest ]
17+
os: [ 'ubuntu-latest' ]
1118
runs-on: ${{ matrix.os }}
1219
steps:
1320
- uses: actions/checkout@v3
@@ -18,14 +25,15 @@ jobs:
1825
- uses: actions/setup-python@v4
1926
with:
2027
python-version: ${{ matrix.python-version }}
28+
cache: 'poetry'
2129

2230
- name: Install dependencies
23-
run: poetry install
31+
run: poetry install --all-extras
2432

25-
- name: Check Format
33+
- name: Check format
2634
run: make check_format
2735

28-
- name: Run Linter
36+
- name: Run linters
2937
run: make lint
3038

3139
- name: Run tests

0 commit comments

Comments
 (0)