-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (116 loc) · 3.52 KB
/
ci-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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
name: CI/CD Pipeline
on: [ push, pull_request, workflow_dispatch ]
env:
PIP_CACHE_DIR: /tmp/pipcache
HOME_REPO: datakortet/dkfileutils
jobs:
ci-lint:
name: CI:Lint
runs-on: ubuntu-latest
env:
LINTDIR: ./ghlint
steps:
# setup environment
- uses: actions/checkout@v3
- name: setup directories
shell: bash
run: |
mkdir -p $PIP_CACHE_DIR
mkdir -p $LINTDIR
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- run: pip install flake8
- run: flake8 dkfileutils/** --max-line-length=199
docs:
name: CI:Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: setup directories
shell: bash
run: |
mkdir -p build
- run: pip install sphinx
- run: pip install -e .
- run: sphinx-build -W -b html docs build/sphinx/html
- run: sphinx-build -W -n -T -b man docs build/sphinx/man
- name: Upload docs as artifact
uses: actions/upload-artifact@v3
with:
name: Docs
path: build/sphinx/
ci-test:
name: CI:Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest]
include:
- python-version: '3.12'
os: windows-latest
- python-version: '3.12'
os: macos-latest
steps:
# setup environment
- uses: actions/checkout@v3
- name: setup global directories
shell: bash
run: mkdir -p $PIP_CACHE_DIR
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- run: pip install -r requirements.txt
- run: pip list
- run: pytest -vv --cov=dkfileutils tests
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN}}
fail_ci_if_error: false
cd:
name: CD
needs: ci-test
runs-on: ubuntu-latest
steps:
# setup environment
- uses: actions/checkout@v3
- name: setup directories
shell: bash
run: mkdir -p $PIP_CACHE_DIR
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Cleanup
run: |
rm -rf dist
rm -rf build
- run: pip install -U build twine
- run: python -m build
- name: Upload packages as artifact
uses: actions/upload-artifact@v3
with:
name: Packages
path: dist/
- name: Deploy to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == env.HOME_REPO
shell: bash
run: |
twine upload -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} dist/*
# - name: Publish package
# uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
# with:
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
- name: Create Github release
uses: ncipollo/release-action@v1
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && github.repository == env.HOME_REPO
with:
artifacts: "dist/*"
owner: datakortet
repo: dkfileutils
token: ${{ secrets.GITHUB_TOKEN }}