Periodic update of stubs from typeshed to PyPI #8366
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: Periodic update of stubs from typeshed to PyPI | |
on: | |
# Triggers the workflow each day at 02:00 UTC. | |
schedule: | |
- cron: 0 2 * * * | |
# If needed, allows to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
FORCE_COLOR: 1 | |
jobs: | |
build-and-upload: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository == 'typeshed-internal/stub_uploader' || github.event_name == 'workflow_dispatch' }} | |
steps: | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Checkout main | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
- name: Checkout typeshed | |
uses: actions/checkout@v4 | |
with: | |
repository: python/typeshed | |
path: typeshed | |
# It is unlikely there will be more commits between two runs. | |
# We could set this to 0 to fetch everything, but we want this to be fast. | |
fetch-depth: 100 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r main/requirements.txt | |
- name: Execute diff build and upload tasks | |
env: | |
TWINE_USERNAME: __token__ | |
TWINE_PASSWORD: ${{ secrets.TYPESHED_BOT_API_TOKEN }} | |
run: | | |
cd main | |
python -m stub_uploader.upload_changed ../typeshed $(cat data/last_typeshed_commit.sha1) | |
(cd ../typeshed; git rev-parse HEAD) > data/last_typeshed_commit.sha1 | |
if [ -z "$(git status --porcelain)" ]; then | |
exit 0; | |
fi | |
git config user.name github-actions && git config user.email github-actions@github.com | |
# This will also commit any new and changed changelogs. | |
git add . && git commit -m "Update last typeshed commit" && git push |