@@ -4,65 +4,98 @@ name: Build
44
55on :
66 push :
7- branches :
8- - main
97 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]
1413
1514jobs :
1615 build :
17- name : Build
16+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
1817 runs-on : ubuntu-latest
19-
2018 strategy :
19+ fail-fast : false
2120 matrix :
22- python-version : [ "3.11" ]
21+ python-version : ["3.11", "3.x" ]
2322
23+ name : " Build @ ${{ matrix.python-version }}"
2424 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
2729
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
3049 with :
31- python-version : ${{ matrix.python-version }}
50+ python-version : " ${{ matrix.python-version }}"
51+ cache : " poetry"
3252
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
3556 with :
36- poetry-preview : true
57+ path : .venv/
58+ key : venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
3759
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
3963 run : |
40- poetry install --all-extras
64+ poetry install --no-interaction
4165
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 }}"
4371 run : |
4472 poetry run python -c 'import mystbin'
4573
46- - name : " Build wheels ${{ matrix.python-version }}"
74+ - name : " Build wheels @ ${{ matrix.python-version}}"
4775 run : |
4876 poetry build
4977
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
5285 with :
5386 name : distributions
5487 path : dist/*
5588
5689 # Credits to most of this step go to Gorialis (Devon R [https://github.com/Gorialis])
5790 # as I found them in their Jishaku builds (https://github.com/Gorialis/jishaku/blob/d3f50749b5a977b544e5fd14894585f656247486/.github/workflows/deploy.yml#L82-L119)
5891 create_release :
59- needs : [ build ]
92+ name : Create Release
93+ needs : [build]
6094 runs-on : ubuntu-latest
6195 if : github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
6296
6397 steps :
64- - name : Checkout Repository
65- uses : actions/checkout@v2
98+ - uses : actions/checkout@v3
6699 with :
67100 fetch-depth : 0
68101 submodules : true
@@ -73,10 +106,24 @@ jobs:
73106 name : distributions
74107 path : dist
75108
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
78124 with :
79- poetry-preview : true
125+ virtualenvs-create : true
126+ virtualenvs-in-project : false
80127
81128 - name : Publish to PyPI
82129 env :
0 commit comments