CI #703
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
name: CI | |
on: | |
release: | |
types: [published] | |
schedule: | |
- cron: '00 08 * * *' # early morning (04:00 UTC) every day | |
jobs: | |
check_date: | |
runs-on: ubuntu-latest | |
name: Check latest commit | |
outputs: | |
WAS_EDITED: ${{ steps.check_date.outputs.WAS_EDITED }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: develop | |
- id: check_date | |
name: Check if there were commits in the last day | |
if: ${{ github.event_name == 'schedule' }} | |
run: echo '::set-output name=WAS_EDITED::'$(test -n "$(git log --format=%H --since='72 hours ago')" && echo 'true' || echo 'false') | |
build: | |
needs: [check_date] | |
if: ${{ github.event_name == 'release' || needs.check_date.outputs.WAS_EDITED == 'true' }} | |
name: Build Package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: develop | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- uses: actions/cache@v2 | |
with: | |
path: ${{ env.pythonLocation }} | |
key: ${{ runner.os }}-pydeps-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }} | |
- name: Install requirements | |
run: | | |
pip install -r requirements.txt | |
- name: Set version name | |
if: ${{ github.event_name == 'schedule' }} | |
run: | | |
# You can't set env variables to bash commands, we need | |
# to export them this way instead. | |
echo "CLASSY_VERSION_SUFFIX=dev$(date -u +%Y%m%d)" >> $GITHUB_ENV | |
- name: Build wheel | |
run: | | |
echo "Building packages for pypi push" | |
python setup.py bdist_wheel sdist | |
- name: Save package | |
uses: actions/upload-artifact@v1 | |
with: | |
name: package | |
path: dist | |
- name: Clean up | |
if: always() | |
run: | | |
pip uninstall -y classy-core | |
publish: | |
name: Publish to PyPI | |
needs: [build] | |
if: ${{ (github.repository == 'sunglasses-ai/classy') && (github.event_name == 'release' || github.event_name == 'schedule') }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
ref: develop | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install requirements | |
run: | | |
pip install --upgrade pip setuptools wheel twine | |
- name: Download package | |
uses: actions/download-artifact@v1 | |
with: | |
name: package | |
path: dist | |
- name: Publish core package | |
run: | | |
twine upload -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} dist/* |