Skip to content

Commit

Permalink
WIP: pypi upload by github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
r9y9 committed Jan 22, 2025
1 parent eaed6bb commit 7590add
Showing 1 changed file with 76 additions and 2 deletions.
78 changes: 76 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,76 @@ 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
path: dist/

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

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/

0 comments on commit 7590add

Please sign in to comment.