Release to PyPi #261
This file contains hidden or 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
name: Release to PyPi | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'version override' | |
required: false | |
repository_dispatch: | |
types: [release-python] | |
env: | |
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} | |
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} | |
VERSION_OVERRIDE: ${{ github.event.inputs.version }} | |
jobs: | |
test-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
pip install build twine pytest pyarrow | |
- name: Set version | |
run: | | |
# Get version from latest release or use override | |
if [[ $VERSION_OVERRIDE ]]; then | |
echo $VERSION_OVERRIDE > sling/VERSION | |
else | |
# Get latest version from GitHub releases | |
LATEST_VERSION=$(curl -s https://api.github.com/repos/slingdata-io/sling-cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/^v//') | |
echo $LATEST_VERSION > sling/VERSION | |
fi | |
echo "Version set to: $(cat sling/VERSION)" | |
- name: Run tests | |
run: | | |
cd sling | |
# Install sling package in development mode | |
pip install -e . | |
# Run the tests | |
python -m pytest tests/tests.py -v | |
SLING_USE_ARROW=false python -m pytest tests/test_sling_class.py -v | |
SLING_USE_ARROW=true python -m pytest tests/test_sling_class.py -v | |
- name: Build and release sling to PyPi | |
run: | | |
cp README.md sling/ | |
cd sling | |
python -m build && twine upload --verbose --skip-existing dist/* |