Skip to content

Apply black format #203

Apply black format

Apply black format #203

Workflow file for this run

name: Publish Python package
on:
release:
types:
- published
pull_request:
jobs:
publish:
name: Build and publish python packages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: get release info
id: release_info
run: |
if [ "${{ github.event.release.tag_name }}" != "" ]; then
version=$(echo ${{ github.event.release.tag_name }} | sed 's/^v//')
else
version="$(awk -F= '/^PACKAGE_VERSION/ { print $2}' pyincore_viz/globals.py | sed 's/[ "]//g').${{ github.run_number }}"
fi
echo "VERSION=${version}" >> $GITHUB_ENV
echo "VERSION=${version}"
./version.sh ${version}
testing=$(echo $version | sed 's/[0-9\.]//g')
if [ "$testing" == "" ]; then
echo "REPO_URL=" >> $GITHUB_ENV
echo "TOKEN=${{ secrets.PYPI_API_TOKEN }}" >> $GITHUB_ENV
else
echo "REPO_URL=https://test.pypi.org/legacy/" >> $GITHUB_ENV
echo "TOKEN=${{ secrets.TEST_PYPI_API_TOKEN }}" >> $GITHUB_ENV
fi
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3-gdal
python -m pip install --upgrade pip setuptools wheel
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Cache pip
uses: actions/cache@v2
with:
# This path is specific to Ubuntu
path: ~/.cache/pip
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Build dist file
run: |
python setup.py sdist bdist_wheel
- name: Publish distribution to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ env.TOKEN }}
repository_url: ${{ env.REPO_URL }}
- name: Upload binaries to release
if: github.event_name == 'release'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/pyincore_viz-${{ env.VERSION }}*
file_glob: true
overwrite: true