forked from Lightning-AI/pytorch-lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
144 lines (121 loc) · 4.29 KB
/
release-pypi.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
name: PyPI
# https://help.github.com/en/actions/reference/events-that-trigger-workflows
on: # Trigger the workflow on push or pull request, but only for the master branch
push:
branches: [master, "release/*"]
release:
types: [published]
jobs:
# based on https://github.com/pypa/gh-action-pypi-publish
build-package:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: >-
python -m pip install --user --upgrade setuptools wheel
- name: Build packages
run: |
python setup.py sdist bdist_wheel
ls -lh dist/
- uses: actions/upload-artifact@v2
with:
name: pypi-packages-${{ github.sha }}
path: dist
upload-package:
runs-on: ubuntu-20.04
needs: build-package
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: pypi-packages-${{ github.sha }}
path: dist
- run: ls -lh dist/
- name: Upload to release
uses: AButler/upload-release-assets@v2.0
with:
files: 'dist/*'
repo-token: ${{ secrets.GITHUB_TOKEN }}
publish-package:
runs-on: ubuntu-20.04
needs: build-package
if: startsWith(github.event.ref, 'refs/tags') || github.event_name == 'release'
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: pypi-packages-${{ github.sha }}
path: dist
- run: ls -lh dist/
- name: Delay releasing
uses: juliangruber/sleep-action@v1
with:
time: 10m
# We do this, since failures on test.pypi aren't that bad
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
verbose: true
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@v1.4.1
with:
user: __token__
password: ${{ secrets.pypi_password }}
create-legacy-ckpt:
runs-on: ubuntu-20.04
needs: [build-package, publish-package]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- 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
# 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
key: ${{ runner.os }}-pip-td${{ steps.times.outputs.period }}-${{ hashFiles('requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-td${{ steps.times.outputs.period }}-
- 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
- uses: actions/download-artifact@v2
with:
name: pypi-packages-${{ github.sha }}
path: dist
- 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: |
ls -lh dist/
pip install dist/*.whl
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
working-directory: ./legacy
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