Skip to content

Commit bcf81cb

Browse files
authored
Merge pull request #93 from r9y9/pypi
pypi upload by github actions
2 parents eaed6bb + 0ad5462 commit bcf81cb

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed

.github/workflows/ci.yaml

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ name: Python package
66
on:
77
push:
88
branches: [ master ]
9+
tags:
10+
- 'v*'
911
pull_request:
1012
branches: [ master ]
1113

1214
jobs:
13-
build:
14-
15+
test:
1516
runs-on: ${{ matrix.os }}
1617
strategy:
1718
matrix:
@@ -49,3 +50,78 @@ jobs:
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

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ version_file = "pyopenjtalk/version.py"
7878
version_file_template = '''
7979
__version__ = "{version}"
8080
'''
81+
# local_scheme = "no-local-version"
8182

8283
[tool.pysen]
8384
version = "0.10.2"

0 commit comments

Comments
 (0)