Skip to content

Commit bc6d050

Browse files
committed
Refactor ci/cd workflow
1 parent 98b6642 commit bc6d050

1 file changed

Lines changed: 40 additions & 8 deletions

File tree

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
name: CI/CD pipeline
2-
on: push
2+
on:
3+
push:
4+
branches:
5+
- master
6+
release:
7+
types: [published, prereleased]
38

49
jobs:
5-
build-n-publish:
6-
name: 🔨 Build and 📦 publish distribution to TestPyPI & PyPI
7-
runs-on: ubuntu-18.04
10+
build:
11+
name: 🔨 Build distribution
12+
runs-on: ubuntu-latest
813
steps:
9-
- uses: actions/checkout@master
14+
- uses: actions/checkout@v2
1015
- name: 🏗 Set up Python 3.7
1116
uses: actions/setup-python@v1
1217
with:
@@ -17,13 +22,40 @@ jobs:
1722
- name: 🔨 Build a binary wheel and a source tarball
1823
run: >-
1924
python setup.py sdist bdist_wheel
20-
- name: 📦 Publish to TestPyPI
25+
- name: ⬆ Upload build result
26+
uses: actions/upload-artifact@v1
27+
with:
28+
name: dist
29+
path: dist
30+
31+
publish-on-testpypi:
32+
name: 📦 Publish on TestPyPI
33+
needs: build
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: ⬇ Download build result
37+
uses: actions/download-artifact@v1
38+
with:
39+
name: dist
40+
path: dist
41+
- name: 📦 Publish to index
2142
uses: pypa/gh-action-pypi-publish@master
2243
with:
2344
password: ${{ secrets.testpypi_password }}
2445
repository_url: https://test.pypi.org/legacy/
25-
- name: 📦 Publish tagged releases to PyPI
26-
if: startsWith(github.event.ref, 'refs/tags')
46+
47+
publish-on-pypi:
48+
name: 📦 Publish tagged releases to PyPI
49+
if: startsWith(github.event.ref, 'refs/tags')
50+
needs: build
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: ⬇ Download build result
54+
uses: actions/download-artifact@v1
55+
with:
56+
name: dist
57+
path: dist
58+
- name: 📦 Publish to index
2759
uses: pypa/gh-action-pypi-publish@master
2860
with:
2961
password: ${{ secrets.pypi_password }}

0 commit comments

Comments
 (0)