Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python package build validation #822

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,36 @@ jobs:
run: python setup.py build_ext install
- name: Test with pytest
run: cd python && pytest

test-pypi:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v1

- name: Build package and upload from docker (Linux)
if: runner.os == 'Linux'
run: |
docker run --rm -v "${PWD}:/opt/OpenCC" \
-e TWINE_USERNAME=__token__ \
-e TWINE_PASSWORD=${{ secrets.PYPI_TOKEN }} \
ubuntu:22.04 /bin/bash /opt/OpenCC/release-pypi-linux.sh testonly

- name: Build package and upload (macOS)
if: runner.os == 'macOS'
run: bash release-pypi-macos.sh testonly
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}

- name: Build package and upload (Windows)
if: runner.os == 'Windows'
run: |
C:\Miniconda/condabin/conda.bat init powershell
./release-pypi-windows.cmd testonly
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
10 changes: 6 additions & 4 deletions release-pypi-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ for VERSION in 3.8 3.9 3.10 3.11 3.12; do
rm -rf build python/opencc/clib OpenCC.egg-info
done

# Upload to PyPI
conda activate py3.8
python -m pip install twine
python -m twine upload dist/*
if [ "$1" != "testonly" ]; then
# Upload to PyPI
conda activate py3.8
python -m pip install twine
python -m twine upload dist/*
fi
10 changes: 6 additions & 4 deletions release-pypi-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ for VERSION in 3.8 3.9 3.10 3.11 3.12; do
rm -rf build python/opencc/clib OpenCC.egg-info
done

# Upload to PyPI
conda activate py3.8
python -m pip install twine
python -m twine upload dist/*
if [ "$1" != "testonly" ]; then
# Upload to PyPI
conda activate py3.8
python -m pip install twine
python -m twine upload dist/*
fi
10 changes: 6 additions & 4 deletions release-pypi-windows.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ for %%v in (%VERSIONS%) do (
rmdir /S /Q build python\opencc\clib OpenCC.egg-info
)

REM Upload to PyPI
C:\Miniconda/condabin/conda.bat activate py3.8
python -m pip install twine
python -m twine upload dist/*
if NOT "%~1"=="testonly" (
REM Upload to PyPI
C:\Miniconda/condabin/conda.bat activate py3.8
python -m pip install twine
python -m twine upload dist/*
)