-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fbff552
commit 5115c5c
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Build and upload python package to PyPI | ||
|
||
on: | ||
workflow_dispatch | ||
|
||
jobs: | ||
release-pypi: | ||
strategy: | ||
matrix: | ||
os: [macos-10.15, ubuntu-18.04] | ||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Build package and upload from docker (Linux) | ||
if: runner.os == 'Linux' | ||
run: | | ||
docker run --rm -v "${PWD}:/opt/FastTokenizer" \ | ||
ubuntu:16.04 /bin/bash /opt/FastTokenizer/script/release-pypi.bash | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
|
||
- name: Build package and upload (macOS) | ||
if: runner.os == 'macOS' | ||
run: bash release-pypi.bash | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Determine OS | ||
if [[ "$OSTYPE" == "darwin"* ]]; then | ||
MINICONDA_FILENAME=Miniconda3-latest-MacOSX-x86_64.sh | ||
EXTRA_SETUP_ARGS="" | ||
else | ||
MINICONDA_FILENAME=Miniconda3-latest-Linux-x86_64.sh | ||
EXTRA_SETUP_ARGS="--plat-name manylinux1_x86_64" | ||
|
||
export DEBIAN_FRONTEND=noninteractive | ||
apt update | ||
apt upgrade -y | ||
apt install -y g++ make cmake curl | ||
fi | ||
|
||
# Download and init miniconda | ||
curl -L -o $MINICONDA_FILENAME \ | ||
"https://repo.continuum.io/miniconda/$MINICONDA_FILENAME" | ||
bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3 | ||
export PATH=$HOME/miniconda3/bin:$PATH | ||
eval "$(conda shell.bash hook)" | ||
|
||
cd /opt/FastTokenizer | ||
|
||
# Download and build static deps | ||
make download-build-static-deps | ||
|
||
# Build packages | ||
for VERSION in 3.6 3.7 3.8; do | ||
# Create and activate environment | ||
conda create -y -n py${VERSION} python=${VERSION} | ||
conda activate py${VERSION} | ||
|
||
# Build and package | ||
pip install --no-cache-dir setuptools wheel | ||
python setup.py build_ext bdist_wheel ${EXTRA_SETUP_ARGS} | ||
|
||
# Cleanup | ||
conda deactivate | ||
make clean | ||
done | ||
|
||
# Upload to PyPI | ||
conda create -y -n twine python=3.8 | ||
conda activate twine | ||
python -m pip install twine | ||
python -m twine upload dist/* |