forked from iiasa/ixmp
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (47 loc) · 1.47 KB
/
publish.yaml
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
name: Build package / publish
on:
push:
branches: [ main ]
tags: [ "v*" ]
release:
types: [ published ]
# Check that package can be built even on PRs
pull_request:
branches: [ main ]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
# If the "Latest version testable on GitHub Actions" in pytest.yaml
# is not the latest 3.x stable version, adjust here to match:
python-version: "3.10"
- name: Upgrade pip, wheel, setuptools-scm
run: |
python -m pip install --upgrade pip wheel setuptools-scm twine
# Locate pip cache directory
echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_ENV
- name: Cache Python packages
uses: actions/cache@v3
with:
path: ${{ env.pip-cache-dir }}
key: publish-${{ runner.os }}
- name: Build package
run: |
python3 setup.py bdist_wheel sdist
twine check dist/*
- name: Publish to TestPyPI
uses: pypa/[email protected]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
repository_url: https://test.pypi.org/legacy/
- name: Publish to PyPI
uses: pypa/[email protected]
if: github.event_name == 'release'
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}