-
Notifications
You must be signed in to change notification settings - Fork 67
113 lines (91 loc) · 2.76 KB
/
cd.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
name: Deploy
on:
push:
tags:
- '*.*.*'
jobs:
version_check:
runs-on: ubuntu-20.04
outputs:
v_tracker: ${{ steps.version.outputs.PYTHON_TRACKER_VERSION}}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
- name: Get tag and tracker versions
id: version
run: |
echo "TAG_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "PYTHON_TRACKER_VERSION=$(python setup.py --version)" >> $GITHUB_OUTPUT
- name: Fail if version mismatch
if: ${{ steps.version.outputs.TAG_VERSION != steps.version.outputs.PYTHON_TRACKER_VERSION }}
run: |
echo "Tag version (${{ steps.version.outputs.TAG_VERSION }}) doesn't match version in project (${{ steps.version.outputs.PYTHON_TRACKER_VERSION }})"
exit 1
build:
needs: ["version_check"]
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.8]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Pin pip version
run: |
echo "pip_v=pip" >> $GITHUB_ENV
- name: Build
run: |
python -m pip install --upgrade "${{ env.pip_v }}" setuptools wheel
python setup.py sdist bdist_wheel
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: distfiles_${{ github.run_id }}
path: dist
publish:
needs: ["build"]
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Download artifacts
uses: actions/[email protected]
with:
name: distfiles_${{ github.run_id }}
path: ${{ github.workspace }}/dist
- name: Twine check
run: |
python -m pip install --upgrade pip twine
twine check ${{ github.workspace }}/dist/*
- name: Publish to PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: ${{ github.workspace }}/dist/
verbose: true
release:
needs: ["publish", "version_check"]
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Version ${{ needs.version_check.outputs.v_tracker }}
draft: false
prerelease: ${{ contains(needs.version_check.outputs.v_tracker, 'rc') }}