Skip to content

NightlyPublish

NightlyPublish #1033

name: NightlyPublish
on:
workflow_dispatch: # Allow manual triggers
schedule:
# Runs every day at 3:07am UTC.
- cron: '7 3 * * *'
jobs:
check:
name: Check files
# Prevent Publish from running on forks.
if: github.repository == 'tensorflow/similarity'
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 2
ref: 'development'
- name: check modified files
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt
while IFS= read -r file
do
echo $file
if [[ $file = tensorflow_similarity/* && $file != tensorflow_similarity/__init__.py ]]; then
echo "This modified file is under the 'tensorflow_similarity' folder."
echo "::set-output name=run_job::true"
break
else
echo "::set-output name=run_job::false"
fi
done < files.txt
publish:
name: Publish nightly
needs: check
# Prevent Publish from running on forks.
if: |
github.repository == 'tensorflow/similarity' &&
needs.check.outputs.run_job == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: 'development'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Install package
run: |
pip install ".[tensorflow,dev]"
- name: Increment dev version
run: |
# Increments the dev version and pushes the changes to development.
python scripts/increment_version.py
- name: Build package
run: |
python setup.py sdist bdist_wheel --project_name tfsim-nightly
- name: Publish package
run: |
twine upload -u ${{ secrets.PYPI_NIGHTLY_USERNAME }} -p ${{ secrets.PYPI_NIGHTLY_TOKEN }} dist/* --verbose