Skip to content

Commit 363003c

Browse files
seismanweiji14
andauthored
Migrate PyPI release to GitHub Actions (#679)
* Migrate PyPI release to GitHub Actions from Travis CI * Update MAINTENANCE.md * Disable the workflow for pull requests Co-authored-by: Wei Ji <[email protected]>
1 parent 5d5dc1f commit 363003c

File tree

3 files changed

+74
-11
lines changed

3 files changed

+74
-11
lines changed

.github/workflows/publish-to-pypi.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Publish archives to PyPI and TestPyPI using GitHub Actions
2+
3+
name: Publish to PyPI
4+
5+
# Only run for pushes to the master branch and releases.
6+
on:
7+
push:
8+
branches:
9+
- master
10+
release:
11+
types:
12+
- published
13+
# Runs for pull requests should be disabled other than for testing purposes
14+
#pull_request:
15+
# branches:
16+
# - master
17+
18+
jobs:
19+
publish-pypi:
20+
name: Publish to PyPI
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- name: Checkout
25+
uses: actions/[email protected]
26+
with:
27+
# fecth all history so that versioneer works
28+
fetch-depth: 0
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: 3.8
34+
35+
- name: Install dependencies
36+
run: python -m pip install setuptools wheel
37+
38+
- name: Fix up version string
39+
run: |
40+
# Change the versioneer format to "pre" so that the commit hash isn't
41+
# included (PyPI doesn't allow it). Can't do this permanently because
42+
# we rely on the hash to tell the tests that this is a local version
43+
# instead of a published version.
44+
#
45+
# The step is only necessary for testing purpose
46+
sed --in-place "s/pep440/pep440-pre/g" setup.cfg
47+
48+
- name: Build source and wheel distributions
49+
run: |
50+
python setup.py sdist bdist_wheel
51+
echo ""
52+
echo "Generated files:"
53+
ls -lh dist/
54+
55+
- name: Publish to Test PyPI
56+
uses: pypa/[email protected]
57+
with:
58+
password: ${{ secrets.test_pypi_password }}
59+
repository_url: https://test.pypi.org/legacy/
60+
61+
- name: Publish to PyPI
62+
if: startsWith(github.ref, 'refs/tags')
63+
uses: pypa/[email protected]
64+
with:
65+
password: ${{ secrets.pypi_password }}

.travis.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ env:
2020
# Encrypted variables
2121
# GitHub Token for pushing the built docs (GH_TOKEN)
2222
- secure: "QII0477v0mmCCW3qSNXLCOtqraJaCICtSghiyrxYsuUdJTrXzXBNhX2KLIjcKYXOK1HdwYOFGf8xBVLl44clHlAW7R32ecEGeTJizr0yqTBvT3rNG1Xb7+E6jdXqrIs//PmPRaF8zOZxPl1SJKDK4jJpCx5HnAflg7wl/6tQLD6K3/dQ6FG2s3UKsc8o4qchOiEfxYhOuKo3jt2S0HdsNAQFw3mFHCCrclxDr3llSQtWSY0mirZnta7AI4nMvzxl2nUhdHEpxgzIjWxCWLAwmj3/NxLz0VSgNCtl2bNYk6AYrc5RcANGk2fcYaZr9mTU3Aax60S4389B39Pq95hBN21jYdbw9vCN810dYpTUk2siLysx8gF6r2JWEF8SskXlF79r3phtaFTMOS4GqeiuwjifZeaLAL/H1PTQFDDG/UKEwBpLuzrPMDw/84iRtyWKqWR/f14YdKhH4YAkcOuRglEXiI/1A0qWKiZ1iZfky8Tys+wN5nyss23w/JeYXVgBdTkNzvp3diFWK8+Wl9j3HYpX9LlEHJwASA1wHLL85t4ToymgLjo9gvLvwzB7T+fWNtEbh4ELbvI7jaKrvir8uSGYy4bGbfRclh5CktD//mTLhDyAsQDS8obF/Ri9mVqFzjK6417ORfu8qnpXU+mIHPRBoKvpS2WqnPtSwF8KPv8="
23-
# TWINE_PASSWORD to deploy to PyPI
24-
- secure: "md4fgPt9RC/sCoN5//5PcNHLUd9gWQGewV5hFpWW88MRTjxTng1Zfs8r7SqlF2AkEEepFfyzq0BEe9c3FMAnFbec3KmqdlQen4V8xDbLrcTlvkPlTrYGbAScUvdhhqojB//hMHoTD4KvxAv9CiUwFBO4hCMmj2buWHUbV9Ksu5WCW9mF/gkt/hIuYAU6Mbwt8PiYyMgUpzMHO1vruofcWRaVnvKwmBqHB0ae86D4/drpwn4CWjlM12WUnphT2bssiyPkw24FZtCN6kPVta6bLZKBxu0bZpw2vbXuUG+Yh19Q4mp8wNYT3XSHJf8Hl5LfujF48+cLWu+6rlCkdcelyVylhWLFc3rGOONAv4G8jWW2yNSz/bLQfJnMpd81fQEu5eySmFxB7mdB0uyKpvIG1jMJQ73LlYKakKLAPdYhMFyQAHoX9gvCE3S4QR95DBMi5gM/pZubOCcMLdjPHB5JKpJHSjxbOzyVwgmsUIEgd5Bi2vZvvYQXn1plk4xpQ3PhXc+/gi33bzY89mKcfOn0HJ2pD1vLqDXRCBsMCakoLZ0JB/6bacaz4FngbsGWuQ+I1cz20lJGL/MSi9bW1G7Uoidt3GXXWDmXrWt70vIXlLIxr8XV0Mu/rPbauGgWE+ZSYEfvdM5sP+FNF7vQ5de+Fkvzg5Z3tTfR+O1W+d7+vM4="
2523
- TWINE_USERNAME=Leonardo.Uieda
2624
# The file with the listed requirements to be installed by conda
2725
- CONDA_REQUIREMENTS=requirements.txt
@@ -60,12 +58,6 @@ script:
6058
- make -C doc all
6159

6260
deploy:
63-
# Make a release on PyPI
64-
- provider: script
65-
script: continuous-integration/travis/deploy-pypi.sh
66-
on:
67-
tags: true
68-
condition: '$DEPLOY == "true"'
6961
# Push the built HTML in doc/_build/html to the gh-pages branch
7062
- provider: script
7163
script: continuous-integration/travis/deploy-gh-pages.sh

MAINTENANCE.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ conda and the `Makefile` to run the tests and checks.
4747

4848
### GitHub Actions
4949

50-
There are 3 configuration files located in `.github/workflows`:
50+
There are 4 configuration files located in `.github/workflows`:
5151

5252
1. `ci_tests.yaml` (Style Checks, Tests on Linux/macOS/Windows)
5353

@@ -65,14 +65,20 @@ This is scheduled to run every Sunday at 12 noon.
6565
If new remote files are needed urgently, maintainers can manually uncomment
6666
the 'pull_request:' line in that `cache_data.yaml` file to refresh the cache.
6767

68+
4. `publish-to-pypi.yml` (Publish wheels to PyPI and TestPyPI)
69+
70+
This workflow is ran to publish wheels to PyPI and TestPyPI (for testing only).
71+
Archives will be pushed to TestPyPI on every commit to the *master* branch and
72+
tagged releases, and to PyPI for tagged releases only.
73+
74+
6875
### Travis CI
6976

7077
The configuration file is at `.travis.yml`.
71-
Travis runs tests (Linux only) and handles all of our deployments automatically:
78+
Travis runs tests (Linux only) and handles the documentation deployment automatically:
7279

7380
* Updating the development documentation by pushing the built HTML pages from the
7481
*master* branch onto the `dev` folder of the *gh-pages* branch.
75-
* Uploading new releases to PyPI (only when the build was triggered by a git tag).
7682
* Updated the `latest` documentation link to the new release.
7783

7884
This way, most day-to-day maintenance operations are automatic.

0 commit comments

Comments
 (0)