@@ -6,12 +6,13 @@ name: Python package
66on :
77 push :
88 branches : [ master ]
9+ tags :
10+ - ' v*'
911 pull_request :
1012 branches : [ master ]
1113
1214jobs :
13- build :
14-
15+ test :
1516 runs-on : ${{ matrix.os }}
1617 strategy :
1718 matrix :
4950 run : |
5051 pip install pytest
5152 pytest
53+
54+ build-for-publish :
55+ name : Build distribution 📦
56+ runs-on : ubuntu-latest
57+ if : " startsWith(github.ref, 'refs/tags')"
58+ needs : test
59+ steps :
60+ - uses : actions/checkout@v4
61+ with :
62+ fetch-depth : 0
63+ submodules : true
64+ - name : Set up Python
65+ uses : actions/setup-python@v5
66+ with :
67+ python-version : ' 3.11'
68+
69+ - name : Install dependencies
70+ run : |
71+ python -m pip install --upgrade build
72+
73+ - name : Build a source tarball and wheel
74+ run : python -m build .
75+
76+ - name : Store the distribution packages
77+ uses : actions/upload-artifact@v4
78+ with :
79+ name : python-package-distributions
80+ # NOTE: for now upload sdist only to prevent errors like unsupported platform tag 'linux_x86_64'.
81+ path : dist/*.tar.gz
82+
83+ publish-to-pypi :
84+ name : >-
85+ Publish Python 🐍 distribution 📦 to PyPI
86+ if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
87+ needs :
88+ - build-for-publish
89+ runs-on : ubuntu-latest
90+ environment :
91+ name : pypi
92+ url : https://pypi.org/p/pyopenjtalk
93+ permissions :
94+ id-token : write # IMPORTANT: mandatory for trusted publishing
95+ steps :
96+ - name : Download all the dists
97+ uses : actions/download-artifact@v4
98+ with :
99+ name : python-package-distributions
100+ path : dist/
101+ - name : Publish distribution 📦 to PyPI
102+ uses : pypa/gh-action-pypi-publish@release/v1
103+ with :
104+ verbose : true
105+
106+ # NOTE: for testing purposes only
107+ # publish-to-testpypi:
108+ # name: Publish Python 🐍 distribution 📦 to TestPyPI
109+ # needs:
110+ # - build-for-publish
111+ # runs-on: ubuntu-latest
112+ # environment:
113+ # name: testpypi
114+ # url: https://test.pypi.org/p/pyopenjtalk
115+ # permissions:
116+ # id-token: write # IMPORTANT: mandatory for trusted publishing
117+ # steps:
118+ # - name: Download all the dists
119+ # uses: actions/download-artifact@v4
120+ # with:
121+ # name: python-package-distributions
122+ # path: dist/
123+ # - name: Publish distribution 📦 to TestPyPI
124+ # uses: pypa/gh-action-pypi-publish@release/v1
125+ # with:
126+ # repository-url: https://test.pypi.org/legacy/
127+ # verbose: true
0 commit comments