1+ name : Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*.*.*'
7+ workflow_dispatch :
8+
9+ jobs :
10+ test :
11+ uses : ./.github/workflows/test.yml
12+
13+ build_package :
14+ runs-on : ubuntu-latest
15+ needs : test
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
20+ - name : Set up Python
21+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
22+ with :
23+ python-version : ' 3.13'
24+
25+ - name : Install Poetry
26+ uses : snok/install-poetry@v1
27+ with :
28+ version : latest
29+ virtualenvs-create : true
30+ virtualenvs-in-project : true
31+
32+ - name : Check tag matches pyproject.toml version
33+ run : |
34+ TAG_VERSION="${GITHUB_REF##*/}"
35+ TAG_VERSION_NO_PREFIX="${TAG_VERSION#v}"
36+ echo "Tag version: $TAG_VERSION (stripped: $TAG_VERSION_NO_PREFIX)"
37+ PYPROJECT_VERSION=$(grep '^version =' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
38+ echo "pyproject.toml version: $PYPROJECT_VERSION"
39+ if [ "$TAG_VERSION_NO_PREFIX" != "$PYPROJECT_VERSION" ]; then
40+ echo "Tag version ($TAG_VERSION_NO_PREFIX) does not match pyproject.toml version ($PYPROJECT_VERSION)" >&2
41+ exit 1
42+ fi
43+ shell : bash
44+
45+ - name : Cache Poetry dependencies
46+ uses : actions/cache@v3
47+ with :
48+ path : .venv
49+ key : venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
50+ restore-keys : |
51+ venv-${{ runner.os }}-
52+
53+ - name : Install dependencies
54+ run : poetry install
55+
56+ - name : Build package
57+ run : poetry build
58+
59+ - name : Upload build artifacts
60+ uses : actions/upload-artifact@v3
61+ with :
62+ name : dist
63+ path : dist/
64+
65+ - name : Publish to PyPI
66+ uses : pypa/gh-action-pypi-publish@release/v1
67+ with :
68+ user : __token__
69+ password : ${{ secrets.PYPI_API_TOKEN }}
70+
71+ - name : Upload Python artifacts
72+ uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
73+ with :
74+ name : python-dist
75+ path : dist/
76+
77+ deploy_docs :
78+ runs-on : ubuntu-latest
79+ needs : build_package
80+ steps :
81+ - name : Checkout code
82+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83+
84+ - name : Set up Python
85+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
86+ with :
87+ python-version : ' 3.13'
88+
89+ - name : Install Poetry
90+ uses : snok/install-poetry@v1
91+ with :
92+ version : latest
93+ virtualenvs-create : true
94+ virtualenvs-in-project : true
95+
96+ - name : Cache Poetry dependencies
97+ uses : actions/cache@v3
98+ with :
99+ path : .venv
100+ key : venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
101+ restore-keys : |
102+ venv-${{ runner.os }}-
103+
104+ - name : Install dependencies
105+ run : poetry install
106+
107+ - name : Build Sphinx documentation
108+ run : cd docs && poetry run sphinx-build -b html . _build
109+
110+ - name : Setup SSH key
111+ uses :
webfactory/[email protected] 112+ with :
113+ ssh-private-key : ${{ secrets.DOCS_DEPLOY_SSH_KEY }}
114+
115+ - name : Add server to known hosts
116+ run : |
117+ ssh-keyscan -H ssh.pythonanywhere.com >> ~/.ssh/known_hosts
118+
119+ - name : Deploy to PythonAnywhere
120+ run : |
121+ rsync -av --delete docs/_build/ [email protected] :/home/core/docs/ 122+
123+ create_release :
124+ runs-on : ubuntu-latest
125+ needs : build_package
126+ steps :
127+ - name : Download Python artifacts
128+ uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
129+ with :
130+ name : python-dist
131+ path : dist/
132+
133+ - name : Create Release
134+ uses : softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
135+ with :
136+ files : |
137+ dist/*
138+ env :
139+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments