1+ name : Publish to PyPI
2+
3+ on :
4+ push :
5+ tags :
6+ - " v*"
7+
8+ jobs :
9+ rename-version :
10+ name : Rename version
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Check out repository
15+ uses : actions/checkout@v4
16+
17+ - name : Update version in pyproject.toml
18+ run : |
19+ TAG_VERSION="${GITHUB_REF_NAME#v}"
20+ echo "Setting version to $TAG_VERSION in pyproject.toml"
21+ python -c "import toml; data = toml.load('pyproject.toml'); data['project']['version'] = '$TAG_VERSION'; toml.dump(data, open('pyproject.toml', 'w'))"
22+
23+ build :
24+ name : Build and publish
25+ runs-on : ubuntu-latest
26+
27+ steps :
28+ - name : Check out repository
29+ uses : actions/checkout@v4
30+ with :
31+ persist-credentials : false
32+ fetch-depth : 1
33+
34+ - name : Set up Python
35+ uses : actions/setup-python@v5
36+ with :
37+ python-version : " 3.12"
38+
39+ - name : Install pypa/build
40+ run : >-
41+ python3 -m
42+ pip install
43+ build
44+ --user
45+
46+ - name : Build a binary wheel and a source tarball
47+ run : python3 -m build
48+
49+ - name : Store the distribution packages
50+ uses : actions/upload-artifact@v4
51+ with :
52+ name : python-package-distributions
53+ path : dist/
54+
55+ publish-to-testpypi :
56+ name : Publish Python distribution to TestPyPI
57+ needs :
58+ - build
59+ runs-on : ubuntu-latest
60+
61+ environment :
62+ name : testpypi
63+ url : https://test.pypi.org/p/elysia-ai
64+
65+ permissions :
66+ id-token : write
67+
68+ steps :
69+ - name : Download all the dists
70+ uses : actions/download-artifact@v4
71+ with :
72+ name : python-package-distributions
73+ path : dist/
74+
75+ - name : Publish distribution to TestPyPI
76+ uses : pypa/gh-action-pypi-publish@release/v1
77+ with :
78+ repository-url : https://test.pypi.org/legacy/
79+
80+ # publish-to-pypi:
81+ # name: >-
82+ # Publish Python distribution to PyPI
83+
84+ # if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
85+
86+ # needs:
87+ # - build
88+
89+ # runs-on: ubuntu-latest
90+
91+ # environment:
92+ # name: pypi
93+ # url: https://pypi.org/p/elysia-ai
94+
95+ # permissions:
96+ # id-token: write
97+
98+ # steps:
99+ # - name: Download all the dists
100+ # uses: actions/download-artifact@v4
101+ # with:
102+ # name: python-package-distributions
103+ # path: dist/
104+
105+ # - name: Publish distribution to PyPI
106+ # uses: pypa/gh-action-pypi-publish@release/v1
0 commit comments