1
- name : Test/ Build/Publish
1
+ name : Build and publish
2
2
on :
3
3
push :
4
4
branches :
5
- - dev
6
5
- main
6
+ paths :
7
+ - http_csp/**
8
+ - pyproject.toml
9
+ - poetry.lock
7
10
pull_request :
8
11
branches :
9
- - dev
10
12
- main
13
+ paths :
14
+ - http_csp/**
15
+ - pyproject.toml
16
+ - poetry.lock
11
17
12
18
jobs :
13
- test :
14
- name : Run tests
19
+ version-tag :
20
+ name : Version tagging
15
21
runs-on : ubuntu-latest
22
+ outputs :
23
+ new_tag : ${{ steps.tag-version.outputs.new_tag }}
16
24
steps :
17
25
- name : Checkout code
18
26
uses : actions/checkout@v3
19
-
27
+
28
+ - name : Determine new version number
29
+ id : tag-version
30
+ uses :
mathieudutour/[email protected]
31
+ with :
32
+ github_token : ${{ secrets.GITHUB_TOKEN }}
33
+ dry_run : true
34
+
20
35
- name : Set up Poetry
21
36
uses : snok/install-poetry@v1
22
37
with :
@@ -25,46 +40,37 @@ jobs:
25
40
virtualenvs-in-project : false
26
41
installer-parallel : true
27
42
28
- - name : Set up Python
29
- uses : actions/setup-python@v4
30
- with :
31
- python-version : 3.11
32
- cache : poetry
33
-
34
- - name : Install dependencies
35
- run : poetry install --with dev
36
-
37
- - name : Lint with flake8
43
+ - name : Set up Git
38
44
run : |
39
- # stop the build if there are Python syntax errors or undefined names
40
- poetry run flake8 . --count --select=E9,F63,F7,F82 \
41
- --show-source --statistics
42
-
43
- # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
44
- poetry run flake8 . --count --exit-zero --max-complexity=10 \
45
- --max-line-length=127 --statistics
45
+ git config user.name "github-actions[bot]"
46
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
46
47
47
- - name : Run tests
48
- run : poetry run pytest
48
+ - name : Bump Poetry version
49
+ run : |
50
+ poetry version ${{ steps.tag-version.outputs.new_version }}
51
+ git add pyproject.toml
52
+ git commit -m "chore: Bump poetry version [skip ci]"
53
+ git push
49
54
50
- - name : Dependencies safety check
55
+ - name : Create Git tag
51
56
run : |
52
- poetry export --without-hashes -f requirements.txt | \
53
- poetry run safety check --full-report --stdin
57
+ git tag ${{ steps.tag-version.outputs.new_tag }}
58
+ git push origin --tags
54
59
55
- - name : Create code coverage report
56
- uses : MishaKav/pytest-coverage-comment@main
60
+ - name : Create Git release if pushed to main
61
+ if : github.ref_name == 'main'
62
+ uses : ncipollo/release-action@v1
63
+ with :
64
+ tag : ${{ steps.tag-version.outputs.new_tag }}
65
+ name : Release ${{ steps.tag-version.outputs.new_tag }}
66
+ body : ${{ steps.tag-version.outputs.changelog }}
57
67
58
68
build-publish :
59
69
name : Build and publish
60
70
runs-on : ubuntu-latest
61
71
permissions :
62
72
id-token : write
63
- needs : test
64
- if : |
65
- needs.test.result == 'success' &&
66
- github.ref_name == 'main' &&
67
- github.event_name == 'push'
73
+ needs : version-tag
68
74
steps :
69
75
- name : Checkout code
70
76
uses : actions/checkout@v3
85
91
with :
86
92
verbose : true
87
93
print-hash : true
94
+
95
+ - name : Upload build artifacts
96
+ uses : actions/upload-artifact@v3
97
+ with :
98
+ path : dist
99
+ name : python-package-build
0 commit comments