forked from google-deepmind/meltingpot
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (109 loc) · 3.25 KB
/
pypi-publish.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
# A workflow to publish releases to PyPi and TestPyPi.
name: pypi-publish
on:
release:
types: [published]
workflow_dispatch:
inputs:
run_tests:
description: 'Test sdist before upload'
type: boolean
default: true
upload_to_test_pypi:
description: 'Upload to Test PyPi'
type: boolean
default: false
upload_to_pypi:
description: 'Upload to PyPi'
type: boolean
default: false
permissions: read-all
jobs:
build:
name: Build
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout Melting Pot
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- name: Show Python setup
run: |
python --version
pip list
- name: Build distribution
run: python setup.py sdist
- name: Save artifact
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
with:
name: dist
path: ./dist
retention-days: 1
test:
name: Test
needs: build
if: github.event_name == 'release' || inputs.run_tests
runs-on: ${{ matrix.os }}
env:
SYSTEM_VERSION_COMPAT: 0 # See https://github.com/actions/setup-python/issues/279.
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
os:
- macos-12
- macos-latest
- ubuntu-20.04
- ubunutu-latest
python-version:
- '3.11'
steps:
- name: Load artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: dist
path: ./dist
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install --upgrade setuptools
pip install pytest-xdist
- name: Install source distribution
run: |
pip install dist/*.tar.gz
pip list
- name: Test source distribution
run: |
pytest -n auto --pyargs meltingpot
publish:
name: Publish
needs: [build, test]
if: always() && needs.build.result == 'success' && needs.test.result != 'failure'
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/dm-meltingpot
permissions:
id-token: write
timeout-minutes: 10
steps:
- name: Load artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: dist
path: ./dist
- name: Publish to TestPyPI
if: github.event_name == 'release' || inputs.upload_to_test_pypi
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Publish to PyPI
if: github.event_name == 'release' || inputs.upload_to_pypi
uses: pypa/gh-action-pypi-publish@897895f1e160c830e369f9779632ebc134688e1b
with:
verbose: true