Skip to content

Commit 45de52e

Browse files
feat: add v5 CI and publish workflows
1 parent 7c492bf commit 45de52e

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

.github/workflows/v5-ci.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- v5
7+
jobs:
8+
compile:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repo
12+
uses: actions/checkout@v4
13+
- name: Set up python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: 3.8
17+
- name: Bootstrap poetry
18+
run: |
19+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
20+
- name: Install dependencies
21+
run: poetry install
22+
- name: Compile
23+
run: poetry run mypy .
24+
test:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repo
28+
uses: actions/checkout@v4
29+
- name: Set up python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: 3.8
33+
- name: Bootstrap poetry
34+
run: |
35+
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
36+
- name: Install dependencies
37+
run: poetry install
38+
39+
- name: Test
40+
run: poetry run pytest -rP .

.github/workflows/v5-publish.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Publish Release (v5)
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Target environment'
8+
type: choice
9+
required: true
10+
options:
11+
- testpypi
12+
- pypi
13+
default: 'testpypi'
14+
15+
permissions:
16+
contents: write
17+
id-token: write
18+
19+
jobs:
20+
publish-pypi:
21+
name: "PyPI"
22+
runs-on: ubuntu-latest
23+
environment: ${{ github.event.inputs.environment }}
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v5
28+
with:
29+
fetch-depth: 0
30+
fetch-tags: true
31+
32+
- id: get_version
33+
name: Get version from pyproject.toml
34+
run: |
35+
VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
36+
echo "version=$VERSION" >> $GITHUB_OUTPUT
37+
echo "Version: $VERSION"
38+
39+
- id: get_prerelease
40+
name: Determine if pre-release
41+
run: |
42+
VERSION="${{ steps.get_version.outputs.version }}"
43+
if [[ "$VERSION" =~ (a|alpha|b|beta|rc)[0-9]* ]]; then
44+
echo "prerelease=true" >> $GITHUB_OUTPUT
45+
echo "Pre-release: true"
46+
else
47+
echo "prerelease=false" >> $GITHUB_OUTPUT
48+
echo "Stable release"
49+
fi
50+
51+
- name: Create GitHub Release
52+
if: github.event.inputs.environment == 'pypi'
53+
id: create_release
54+
uses: actions/create-release@v1
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
tag_name: v${{ steps.get_version.outputs.version }}
59+
release_name: v${{ steps.get_version.outputs.version }}
60+
body: |
61+
See [v5_MIGRATION_GUIDE.md](https://github.com/${{ github.repository }}/blob/main/v5_MIGRATION_GUIDE.md) for migration instructions.
62+
draft: false
63+
prerelease: ${{ steps.get_prerelease.outputs.prerelease }}
64+
65+
- name: Configure Python
66+
uses: actions/setup-python@v6
67+
with:
68+
python-version: "3.10"
69+
70+
- name: Configure dependencies
71+
run: |
72+
pip install --user --upgrade pip
73+
pip install --user pipx
74+
pipx ensurepath
75+
pipx install poetry
76+
poetry config virtualenvs.in-project true
77+
poetry install
78+
79+
- name: Build release
80+
run: |
81+
poetry build
82+
ls -lh dist/
83+
84+
- name: Publish to Test PyPI
85+
if: github.event.inputs.environment == 'testpypi'
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
with:
88+
repository-url: https://test.pypi.org/legacy/
89+
skip-existing: true
90+
print-hash: true
91+
92+
- name: Publish to PyPI
93+
if: github.event.inputs.environment == 'pypi'
94+
uses: pypa/gh-action-pypi-publish@release/v1
95+
with:
96+
print-hash: true
97+
98+
- name: Summary
99+
run: |
100+
echo "### Release Summary" >> $GITHUB_STEP_SUMMARY
101+
echo "" >> $GITHUB_STEP_SUMMARY
102+
echo "- Version: ${{ steps.get_version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
103+
echo "- Environment: ${{ github.event.inputs.environment }}" >> $GITHUB_STEP_SUMMARY
104+
echo "- Pre-release: ${{ steps.get_prerelease.outputs.prerelease }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)