-
Notifications
You must be signed in to change notification settings - Fork 4
105 lines (103 loc) · 2.98 KB
/
deploy-job.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
name: Build, Test, Deploy
on: [push]
jobs:
info:
runs-on: ubuntu-latest
steps:
- name: Print node info
run: |
cat /etc/os-release
build:
runs-on: ubuntu-latest
needs: info
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo apt install pycodestyle
pip install pylint build
- name: Build package
run: |
python -m build .
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: built-artifacts
path: dist
retention-days: 1
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo apt install pycodestyle pylint
pip install -r py-requirements.txt
pip install pytest
- name: Analysing the code with pycodestyle
run: |
pycodestyle src/**/*.py
- name: Analysing the code with pylint
run: |
pylint src/**/*.py
- name: Run Module tests
run: |
python3 -m pytest -sr tests/test_c*.py
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: test
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: built-artifacts
path: dist
- name: Publish package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
release:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: deploy
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: built-artifacts
path: dist
- name: Set version release
run: |
VER="$(cat setup.cfg | grep version | cut -d '=' -f 2 | xargs)"
{
echo 'COMMIT_MESSAGE<<EOF'
git log -1 --pretty=%B
echo EOF
} >> "$GITHUB_ENV"
echo "RELEASE_VERSION=$VER" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=$COMMIT_MESSAGE" >> $GITHUB_ENV
- name: Create release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*
tag: ${{ env.RELEASE_VERSION }}
body: ${{ env.COMMIT_MESSAGE }}
release_name: v${{ env.RELEASE_VERSION }}
overwrite: true
file_glob: true