Skip to content

Commit

Permalink
Added release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mingruimingrui committed Sep 14, 2020
1 parent fbff552 commit 5115c5c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/release-pypi.yaml
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 }}
49 changes: 49 additions & 0 deletions scripts/release-pypi.bash
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/*

0 comments on commit 5115c5c

Please sign in to comment.