Skip to content

Commit

Permalink
pypi upload by github actions
Browse files Browse the repository at this point in the history
confirmed it works ok with testpypi
  • Loading branch information
r9y9 committed Jan 22, 2025
1 parent eaed6bb commit 0ad5462
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
80 changes: 78 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ name: Python package
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]

jobs:
build:

test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -49,3 +50,78 @@ jobs:
run: |
pip install pytest
pytest
build-for-publish:
name: Build distribution πŸ“¦
runs-on: ubuntu-latest
if: "startsWith(github.ref, 'refs/tags')"
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade build
- name: Build a source tarball and wheel
run: python -m build .

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
# NOTE: for now upload sdist only to prevent errors like unsupported platform tag 'linux_x86_64'.
path: dist/*.tar.gz

publish-to-pypi:
name: >-
Publish Python 🐍 distribution πŸ“¦ to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build-for-publish
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyopenjtalk
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true

# NOTE: for testing purposes only
# publish-to-testpypi:
# name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
# needs:
# - build-for-publish
# runs-on: ubuntu-latest
# environment:
# name: testpypi
# url: https://test.pypi.org/p/pyopenjtalk
# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing
# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution πŸ“¦ to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# verbose: true
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ version_file = "pyopenjtalk/version.py"
version_file_template = '''
__version__ = "{version}"
'''
# local_scheme = "no-local-version"

[tool.pysen]
version = "0.10.2"
Expand Down

0 comments on commit 0ad5462

Please sign in to comment.