Skip to content

Commit 9db9bc1

Browse files
ci: add release workflow and update CI to latest action versions
1 parent 770ace8 commit 9db9bc1

2 files changed

Lines changed: 84 additions & 35 deletions

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,46 @@
11
name: ci
2+
23
on:
34
push:
45
workflow_dispatch:
6+
57
jobs:
68
compile:
79
runs-on: ubuntu-latest
810
steps:
911
- name: Checkout repo
10-
uses: actions/checkout@v4
12+
uses: actions/checkout@v6
13+
1114
- name: Set up python
12-
uses: actions/setup-python@v4
15+
uses: actions/setup-python@v6
1316
with:
14-
python-version: 3.8
17+
python-version: '3.8'
18+
1519
- name: Bootstrap poetry
16-
run: |
17-
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
20+
run: curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
21+
1822
- name: Install dependencies
1923
run: poetry install
24+
2025
- name: Compile
2126
run: poetry run mypy .
27+
2228
test:
2329
runs-on: ubuntu-latest
2430
steps:
2531
- name: Checkout repo
26-
uses: actions/checkout@v4
32+
uses: actions/checkout@v6
33+
2734
- name: Set up python
28-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v6
2936
with:
30-
python-version: 3.8
37+
python-version: '3.8'
38+
3139
- name: Bootstrap poetry
32-
run: |
33-
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
40+
run: curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
41+
3442
- name: Install dependencies
3543
run: poetry install
44+
3645
- name: Test
3746
run: poetry run pytest -rP .
38-
39-
publish:
40-
needs: [compile, test]
41-
if: (github.event_name == 'push' && contains(github.ref, 'refs/tags/')) || github.event_name == 'workflow_dispatch'
42-
runs-on: ubuntu-latest
43-
permissions:
44-
id-token: write
45-
steps:
46-
- name: Checkout repo
47-
uses: actions/checkout@v4
48-
- name: Set up python
49-
uses: actions/setup-python@v4
50-
with:
51-
python-version: 3.8
52-
- name: Bootstrap poetry
53-
run: |
54-
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
55-
- name: Install dependencies
56-
run: poetry install
57-
- name: Build package
58-
run: poetry build
59-
- name: Publish to PyPI
60-
uses: pypa/gh-action-pypi-publish@release/v1
61-
with:
62-
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/release.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write # create GitHub Release
13+
id-token: write # PyPI trusted publishing (OIDC)
14+
steps:
15+
- name: Checkout repo
16+
uses: actions/checkout@v6
17+
18+
- name: Set up python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version: '3.8'
22+
23+
- name: Bootstrap poetry
24+
run: curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
25+
26+
- name: Install dependencies
27+
run: poetry install
28+
29+
- name: Compile
30+
run: poetry run mypy .
31+
32+
- name: Test
33+
run: poetry run pytest -rP .
34+
35+
- name: Build
36+
run: poetry build
37+
38+
- name: Extract changelog notes
39+
id: changelog
40+
run: |
41+
VERSION="${GITHUB_REF_NAME}"
42+
NOTES=$(awk -v ver="## [${VERSION}]" '
43+
index($0, ver) == 1 { found=1; next }
44+
found && /^## / { exit }
45+
found { print }
46+
' changelog.md)
47+
echo "notes<<EOF" >> "$GITHUB_OUTPUT"
48+
echo "$NOTES" >> "$GITHUB_OUTPUT"
49+
echo "EOF" >> "$GITHUB_OUTPUT"
50+
51+
- name: Create GitHub Release
52+
env:
53+
GH_TOKEN: ${{ github.token }}
54+
NOTES: ${{ steps.changelog.outputs.notes }}
55+
run: |
56+
echo "$NOTES" > release_notes.md
57+
gh release create "$GITHUB_REF_NAME" \
58+
--title "$GITHUB_REF_NAME" \
59+
--notes-file release_notes.md \
60+
dist/*
61+
62+
- name: Publish to PyPI
63+
uses: pypa/gh-action-pypi-publish@release/v1
64+
with:
65+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)