2020-04-02 15:47:37 +00:00
|
|
|
name: PyPI Release
|
|
|
|
|
2020-04-07 15:55:27 +00:00
|
|
|
# https://help.github.com/en/actions/reference/events-that-trigger-workflows
|
2020-09-10 22:38:29 +00:00
|
|
|
on: # Trigger the workflow on push or pull request, but only for the master branch
|
2020-04-07 15:55:27 +00:00
|
|
|
push:
|
2021-01-12 12:56:20 +00:00
|
|
|
branches: [master, "release/*"]
|
2020-04-07 18:04:32 +00:00
|
|
|
release:
|
2021-05-06 19:05:35 +00:00
|
|
|
types: [published]
|
2020-04-02 15:47:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
jobs:
|
2020-10-02 09:26:21 +00:00
|
|
|
# based on https://github.com/pypa/gh-action-pypi-publish
|
2021-01-13 19:02:22 +00:00
|
|
|
build-package:
|
2020-06-27 20:25:33 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2020-04-02 15:47:37 +00:00
|
|
|
steps:
|
2020-04-26 20:10:58 +00:00
|
|
|
- uses: actions/checkout@v2
|
2020-06-27 01:38:25 +00:00
|
|
|
- uses: actions/setup-python@v2
|
2020-04-02 15:47:37 +00:00
|
|
|
with:
|
2021-10-26 11:58:20 +00:00
|
|
|
python-version: 3.9
|
2020-04-02 15:47:37 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: >-
|
|
|
|
python -m pip install --user --upgrade setuptools wheel
|
2020-11-18 14:15:41 +00:00
|
|
|
|
|
|
|
- name: Build packages
|
2020-09-25 12:15:06 +00:00
|
|
|
run: |
|
2020-04-02 15:47:37 +00:00
|
|
|
python setup.py sdist bdist_wheel
|
2020-09-25 12:15:06 +00:00
|
|
|
ls -lh dist/
|
2020-04-26 20:10:58 +00:00
|
|
|
|
2021-01-13 19:02:22 +00:00
|
|
|
- uses: actions/upload-artifact@v2
|
|
|
|
with:
|
2021-01-21 16:12:29 +00:00
|
|
|
name: pypi-packages-${{ github.sha }}
|
2021-01-13 19:02:22 +00:00
|
|
|
path: dist
|
|
|
|
|
2021-02-03 17:35:42 +00:00
|
|
|
upload-package:
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs: build-package
|
2021-05-19 19:15:58 +00:00
|
|
|
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
|
2021-02-03 17:35:42 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: pypi-packages-${{ github.sha }}
|
|
|
|
path: dist
|
|
|
|
- run: ls -lh dist/
|
|
|
|
|
2020-12-09 09:59:44 +00:00
|
|
|
- name: Upload to release
|
2021-02-03 17:35:42 +00:00
|
|
|
uses: AButler/upload-release-assets@v2.0
|
2020-12-09 09:59:44 +00:00
|
|
|
with:
|
2021-02-03 17:35:42 +00:00
|
|
|
files: 'dist/*'
|
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
2020-12-09 09:59:44 +00:00
|
|
|
|
2021-01-21 16:12:29 +00:00
|
|
|
publish-package:
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs: build-package
|
2021-05-19 19:15:58 +00:00
|
|
|
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
|
2021-01-21 16:12:29 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: pypi-packages-${{ github.sha }}
|
|
|
|
path: dist
|
2021-02-03 17:35:42 +00:00
|
|
|
- run: ls -lh dist/
|
2021-01-21 16:12:29 +00:00
|
|
|
|
2020-11-18 14:15:41 +00:00
|
|
|
- name: Delay releasing
|
|
|
|
uses: juliangruber/sleep-action@v1
|
|
|
|
with:
|
|
|
|
time: 10m
|
|
|
|
|
2020-04-02 15:47:37 +00:00
|
|
|
# We do this, since failures on test.pypi aren't that bad
|
|
|
|
- name: Publish to Test PyPI
|
2020-11-06 10:48:27 +00:00
|
|
|
uses: pypa/gh-action-pypi-publish@v1.4.1
|
2020-04-02 15:47:37 +00:00
|
|
|
with:
|
2020-04-07 13:49:38 +00:00
|
|
|
user: __token__
|
2020-04-02 15:47:37 +00:00
|
|
|
password: ${{ secrets.test_pypi_password }}
|
|
|
|
repository_url: https://test.pypi.org/legacy/
|
2020-09-30 12:37:52 +00:00
|
|
|
verbose: true
|
2020-04-02 15:47:37 +00:00
|
|
|
|
|
|
|
- name: Publish distribution 📦 to PyPI
|
2020-11-06 10:48:27 +00:00
|
|
|
uses: pypa/gh-action-pypi-publish@v1.4.1
|
2020-04-02 15:47:37 +00:00
|
|
|
with:
|
2020-04-07 13:49:38 +00:00
|
|
|
user: __token__
|
2020-04-02 15:47:37 +00:00
|
|
|
password: ${{ secrets.pypi_password }}
|
2021-01-08 15:36:49 +00:00
|
|
|
|
2021-01-13 19:02:22 +00:00
|
|
|
create-legacy-ckpt:
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
needs: [build-package, publish-package]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
2021-05-25 22:53:38 +00:00
|
|
|
|
2021-01-13 19:02:22 +00:00
|
|
|
- uses: actions/setup-python@v2
|
|
|
|
with:
|
2021-10-26 11:58:20 +00:00
|
|
|
python-version: 3.9
|
2021-05-25 22:53:38 +00:00
|
|
|
|
|
|
|
- name: Weekly reset caching
|
|
|
|
run: echo "::set-output name=period::$(python -c 'import time ; days = time.time() / 60 / 60 / 24 ; print(int(days / 7))' 2>&1)"
|
|
|
|
id: times
|
|
|
|
|
2021-01-08 15:36:49 +00:00
|
|
|
# Note: This uses an internal pip API and may not always work
|
|
|
|
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
|
|
|
|
- name: Cache pip
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.cache/pip
|
2021-05-25 22:53:38 +00:00
|
|
|
key: ${{ runner.os }}-pip-td${{ steps.times.outputs.period }}-${{ hashFiles('requirements.txt') }}
|
|
|
|
restore-keys: ${{ runner.os }}-pip-td${{ steps.times.outputs.period }}-
|
2021-01-08 15:36:49 +00:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
run: |
|
|
|
|
pip install -r requirements.txt --find-links https://download.pytorch.org/whl/cpu/torch_stable.html --quiet
|
|
|
|
pip install awscli
|
|
|
|
|
|
|
|
- name: Configure AWS credentials
|
|
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
|
|
with:
|
|
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_ID }}
|
|
|
|
aws-region: us-east-1
|
|
|
|
|
2021-01-13 19:02:22 +00:00
|
|
|
- uses: actions/download-artifact@v2
|
|
|
|
with:
|
2021-01-21 16:12:29 +00:00
|
|
|
name: pypi-packages-${{ github.sha }}
|
2021-01-13 19:02:22 +00:00
|
|
|
path: dist
|
|
|
|
|
2021-01-08 15:36:49 +00:00
|
|
|
- name: Pull files from S3
|
|
|
|
run: |
|
|
|
|
aws s3 cp --recursive s3://pl-public-data/legacy/checkpoints/ legacy/checkpoints/ # --acl public-read
|
|
|
|
ls -l legacy/checkpoints/
|
|
|
|
|
|
|
|
- name: Generate checkpoint
|
|
|
|
run: |
|
2021-01-13 19:02:22 +00:00
|
|
|
ls -lh dist/
|
2021-01-12 21:35:43 +00:00
|
|
|
pip install dist/*.whl
|
2021-01-08 15:36:49 +00:00
|
|
|
|
|
|
|
pl_ver=$(python -c "import pytorch_lightning as pl ; print(pl.__version__)" 2>&1)
|
|
|
|
# generate checkpoint to this version
|
|
|
|
bash legacy/generate_checkpoints.sh $pl_ver
|
|
|
|
|
|
|
|
- name: Push files to S3
|
2021-06-08 16:30:13 +00:00
|
|
|
working-directory: ./legacy
|
2021-01-08 15:36:49 +00:00
|
|
|
run: |
|
|
|
|
aws s3 sync legacy/checkpoints/ s3://pl-public-data/legacy/checkpoints/
|
|
|
|
zip -r checkpoints.zip checkpoints
|
|
|
|
aws s3 cp checkpoints.zip s3://pl-public-data/legacy/ --acl public-read
|