-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (162 loc) · 4.99 KB
/
build.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Build & Deploy
run-name: Build & Deploy by @${{ github.actor }}
on:
push:
branches:
- dev
paths:
- somos/**
jobs:
bump:
runs-on: ubuntu-latest
steps:
- name: Git config
run: |
git config --global user.name "thatgaypigeon"
git config --global user.email "pigeon43.stuff@gmail.com"
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install bump-my-version
# run: pip install -r requirements.txt
# Stash version
- name: Stash version
shell: bash
id: set-version
run: |
export cur_ver=$(bump-my-version show new_version build)
export new_ver=$(bump-my-version show new_version --increment build)
echo "cur_version=$cur_ver" >> $GITHUB_OUTPUT
echo "new_version=$new_ver" >> $GITHUB_OUTPUT
# Bump
- name: Bump
id: bump
run: bump-my-version bump build
outputs:
var_cur_version: ${{ steps.set-version.outputs.cur_version }}
var_new_version: ${{ steps.set-version.outputs.new_version }}
lint:
if: success()
runs-on: ubuntu-latest
needs: bump
steps:
- name: Git config
run: |
git config --global user.name "thatgaypigeon"
git config --global user.email "pigeon43.stuff@gmail.com"
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install black flake8 isort mypy
- name: Sort imports (isort)
run: isort .
- name: Format code (black)
run: black .
- name: Lint code (flake8)
run: flake8 .
- name: Type check (mypy)
run: mypy .
# Pre-test commit
- name: Pre-test commit
run: |
git add .
git commit -m "Pre-test commit for ${{ needs.bump.outputs.var_new_version }}"
test:
if: success()
runs-on: ubuntu-latest
needs: [bump, lint]
steps:
- name: Git config
run: |
git config --global user.name "thatgaypigeon"
git config --global user.email "pigeon43.stuff@gmail.com"
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install bandit pytest pytest-cov
# run: pip install -r requirements.txt
# Security checks
- name: Run security checks (bandit)
run: bandit -r .
# Code coverage
- name: Run tests with coverage (pytest)
run: pytest --cov=somos --cov-report=xml tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
# Pre-build commit
- name: Pre-build commit
run: |
git add .
git commit -m "Pre-build commit for ${{ needs.bump.outputs.var_new_version }}"
build:
if: success()
runs-on: ubuntu-latest
needs: [bump, test]
steps:
- name: Git config
run: |
git config --global user.name "thatgaypigeon"
git config --global user.email "pigeon43.stuff@gmail.com"
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install pip
run: python -m pip install --upgrade pip
- name: Install dependencies
run: pip install build
# run: pip install -r requirements.txt
- name: Build
id: build
run: python -m build
deploy:
if: success()
runs-on: ubuntu-latest
needs: [bump, build]
steps:
- name: Git config
run: |
git config --global user.name "thatgaypigeon"
git config --global user.email "pigeon43.stuff@gmail.com"
- name: Checkout
uses: actions/checkout@v4
# Deploy build
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT_TOKEN }}
with:
tag_name: "v${{ needs.bump.outputs.var_new_version }}"
release_name: "Release ${{ needs.bump.outputs.var_new_version }}"
draft: false
prerelease: false
# Deploy to PyPI
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}