1+ name : release-main
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ jobs :
8+ set-version :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - uses : actions/checkout@v5
12+
13+ - name : Set up Python
14+ uses : actions/setup-python@v6
15+ with :
16+ python-version : ' 3.10'
17+
18+ - name : Install build tools
19+ run : |
20+ python -m pip install --upgrade pip setuptools wheel build twine
21+
22+ - name : Determine package version
23+ id : vars
24+ run : |
25+ echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
26+
27+ - name : Build package
28+ run : |
29+ python -m build --sdist --wheel
30+
31+ - name : Export tag
32+ id : vars
33+ run : echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
34+ if : ${{ github.event_name == 'release' }}
35+
36+ - name : Update project version
37+ run : |
38+ sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
39+ env :
40+ RELEASE_VERSION : ${{ steps.vars.outputs.tag }}
41+ if : ${{ github.event_name == 'release' }}
42+
43+ - name : Upload updated pyproject.toml
44+ uses : actions/upload-artifact@v4
45+ with :
46+ name : pyproject-toml
47+ path : pyproject.toml
48+
49+ publish :
50+ runs-on : ubuntu-latest
51+ needs : [set-version]
52+ steps :
53+ - name : Check out
54+ uses : actions/checkout@v4
55+
56+ - name : Set up the environment
57+ uses : actions/setup-python@v6
58+ with :
59+ python-version : " 3.10"
60+
61+ - name : Build dist
62+ run : |
63+ python setup.py sdist
64+
65+ - name : Twine check
66+ run : |
67+ pip install twine
68+ last_dist=$(ls -t dist/smac-*.tar.gz | head -n 1)
69+ twine_output=`twine check "$last_dist"`
70+ if [[ "$twine_output" != "Checking $last_dist: PASSED" ]]
71+ then
72+ echo $twine_output
73+ else
74+ pip install $last_dist
75+ fi
76+
77+ - name : Publish package
78+ run : python -m twine upload --repository testpypi dist/*
79+ env :
80+ UV_PUBLISH_TOKEN : ${{ secrets.PYPI_TOKEN }}
81+
82+
83+ deploy-docs :
84+ needs : publish
85+ runs-on : ubuntu-latest
86+ steps :
87+ - name : Check out
88+ uses : actions/checkout@v4
89+
90+ - name : Set up the environment
91+ uses : ./.github/actions/setup-python-env
92+
93+ - name : Deploy documentation
94+ run : uv run mkdocs gh-deploy --force
0 commit comments