@@ -4,65 +4,98 @@ name: Build
4
4
5
5
on :
6
6
push :
7
- branches :
8
- - main
9
7
tags :
10
- - ' *.*.*'
11
- pull_request :
12
- branches :
13
- - main
8
+ - " *.*.*"
9
+ workflow_run :
10
+ workflows : ["Type Coverage and Linting"]
11
+ types : [completed]
12
+ branches : [main]
14
13
15
14
jobs :
16
15
build :
17
- name : Build
16
+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
18
17
runs-on : ubuntu-latest
19
-
20
18
strategy :
19
+ fail-fast : false
21
20
matrix :
22
- python-version : [ "3.11" ]
21
+ python-version : ["3.11", "3.x" ]
23
22
23
+ name : " Build @ ${{ matrix.python-version }}"
24
24
steps :
25
- - name : Checkout source
26
- uses : actions/checkout@v2
25
+ - name : " Checkout Repository"
26
+ uses : actions/checkout@v3
27
+ with :
28
+ fetch-depth : 0
27
29
28
- - name : " Set up Python ${{ matrix.python-version }}"
29
- uses : actions/setup-python@v1
30
+ - name : " Load cached poetry installation @ ${{ matrix.python-version }}"
31
+ id : cached-poetry
32
+ uses : actions/cache@v3
33
+ with :
34
+ path : ~/.local
35
+ key : poetry-0
36
+
37
+ - name : " Setup Poetry @ ${{ matrix.python-version }}"
38
+ if : steps.cached-poetry.outputs.cache-hit != 'true'
39
+ uses : snok/install-poetry@v1
40
+ with :
41
+ version : latest
42
+ virtualenvs-create : true
43
+ virtualenvs-in-project : true
44
+ virtualenvs-path : .venv
45
+
46
+ - name : " Setup Python @ ${{ matrix.python-version }}"
47
+ id : setup-python
48
+ uses : actions/setup-python@v4
30
49
with :
31
- python-version : ${{ matrix.python-version }}
50
+ python-version : " ${{ matrix.python-version }}"
51
+ cache : " poetry"
32
52
33
- - name : " Set up Poetry ${{ matrix.python-version }}"
34
- uses : Gr1N/setup-poetry@v7
53
+ - name : " Load cached venv @ ${{ matrix.python-version }}"
54
+ id : cached-pip-wheels
55
+ uses : actions/cache@v3
35
56
with :
36
- poetry-preview : true
57
+ path : .venv/
58
+ key : venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
37
59
38
- - name : " Install Python deps ${{ matrix.python-version }}"
60
+ - name : " Install Python deps @ ${{ matrix.python-version }}"
61
+ if : ${{ steps.cached-pip-wheels.outputs.cache-hit != 'true' }}
62
+ id : install-deps
39
63
run : |
40
- poetry install --all-extras
64
+ poetry install --no-interaction
41
65
42
- - name : " Check it imports ${{ matrix.python-version }}"
66
+ - name : Activate venv @ ${{ matrix.python-version }}
67
+ run : |
68
+ echo "$(poetry env info --path)/bin" >> $GITHUB_PATH
69
+
70
+ - name : " Check it imports @ ${{ matrix.python-version }}"
43
71
run : |
44
72
poetry run python -c 'import mystbin'
45
73
46
- - name : " Build wheels ${{ matrix.python-version }}"
74
+ - name : " Build wheels @ ${{ matrix.python-version}}"
47
75
run : |
48
76
poetry build
49
77
50
- - name : " Upload artifacts ${{ matrix.python-version }}"
51
- uses : actions/upload-artifact@v2
78
+ - name : " Build docs @ ${{ matrix.python-version}}"
79
+ run : |
80
+ cd docs/
81
+ poetry run sphinx-build -aETW --keep-going . build
82
+
83
+ - name : " Upload artifacts @ ${{ matrix.python-version}}"
84
+ uses : actions/upload-artifact@v3
52
85
with :
53
86
name : distributions
54
87
path : dist/*
55
88
56
89
# Credits to most of this step go to Gorialis (Devon R [https://github.com/Gorialis])
57
90
# as I found them in their Jishaku builds (https://github.com/Gorialis/jishaku/blob/d3f50749b5a977b544e5fd14894585f656247486/.github/workflows/deploy.yml#L82-L119)
58
91
create_release :
59
- needs : [ build ]
92
+ name : Create Release
93
+ needs : [build]
60
94
runs-on : ubuntu-latest
61
95
if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
62
96
63
97
steps :
64
- - name : Checkout Repository
65
- uses : actions/checkout@v2
98
+ - uses : actions/checkout@v3
66
99
with :
67
100
fetch-depth : 0
68
101
submodules : true
@@ -73,10 +106,24 @@ jobs:
73
106
name : distributions
74
107
path : dist
75
108
76
- - name : Set up Poetry
77
- uses : Gr1N/setup-poetry@v7
109
+ - name : Create GitHub release
110
+ shell : bash
111
+ env :
112
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
113
+ run : |
114
+ set -x
115
+ assets=()
116
+ for asset in ./dist/*.{whl,tar.gz}; do
117
+ assets+=("-a" "$asset")
118
+ done
119
+ tag_name="${GITHUB_REF##*/}"
120
+ hub release create "${assets[@]}" -F "CHANGELOG.md" "$tag_name"
121
+
122
+ - name : " Set up Poetry"
123
+ uses : snok/install-poetry@v1
78
124
with :
79
- poetry-preview : true
125
+ virtualenvs-create : true
126
+ virtualenvs-in-project : false
80
127
81
128
- name : Publish to PyPI
82
129
env :
0 commit comments