1111
1212 workflow_dispatch :
1313
14+ env :
15+ python-version : " 3.11"
16+
1417jobs :
1518 build :
1619 runs-on : ubuntu-latest
17- env :
18- python_version : " 3.11 "
20+ outputs :
21+ artifact-name : ${{ steps.build.outputs.artifact-name }}
1922 steps :
2023 - uses : actions/checkout@v3
21-
22- - uses : actions/setup-python@v4
24+ - uses : ./.github/actions/build-python-package
25+ id : build
2326 with :
24- python-version : ${{ env.python_version }}
25- cache : ' pip'
26-
27- - name : Build python package
28- shell : bash -l {0}
29- run : |
30- pip install build
31- python3 -m build
32-
33- - uses : actions/upload-artifact@v3
34- with :
35- name : " Python package"
36- path : dist
27+ python-version : ${{ env.python-version }}
3728
3829 test :
3930 runs-on : ubuntu-latest
5041 - uses : ./.github/actions/environment
5142 with :
5243 python-version : ${{ matrix.python-version }}
44+ package-artifact-name : ${{ needs.build.outputs.artifact-name }}
5345
5446 - name : Run tests
5547 shell : bash -l {0}
@@ -80,20 +72,18 @@ jobs:
8072 run :
8173 shell : bash -l {0}
8274
83- env :
84- python_version : " 3.11"
85-
8675 steps :
8776 - uses : actions/checkout@v3
8877 - uses : ./.github/actions/environment
8978 with :
90- python-version : ${{ env.python_version }}
79+ python-version : ${{ env.python-version }}
80+ package-artifact-name : ${{ needs.build.outputs.artifact-name }}
9181
9282 - name : ' mypy cache'
9383 uses : actions/cache@v3
9484 with :
9585 path : ' .mypy_cache'
96- key : mypy-${{ runner.os }}-py${{ env.python_version }}-${{ hashFiles('requirements.txt') }}
86+ key : mypy-${{ runner.os }}-py${{ env.python-version }}-${{ hashFiles('requirements.txt') }}
9787
9888 - run : flake8 src/ tests/
9989 - run : isort --diff --check-only src/ tests/
@@ -112,7 +102,8 @@ jobs:
112102 - uses : actions/checkout@v3
113103 - uses : ./.github/actions/environment
114104 with :
115- python-version : " 3.11"
105+ python-version : ${{ env.python-version }}
106+ package-artifact-name : ${{ needs.build.outputs.artifact-name }}
116107
117108 - run : |
118109 cd docs/
@@ -122,38 +113,3 @@ jobs:
122113 with :
123114 name : Docs
124115 path : docs/_build/dirhtml
125-
126- publish :
127- runs-on : ubuntu-latest
128- timeout-minutes : 5
129- needs : ['test', 'lint', 'docs']
130- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
131-
132- steps :
133- - name : Fetch Python package
134- uses : actions/download-artifact@v3
135- with :
136- name : " Python package"
137- path : " dist"
138-
139- - name : " Check tag matches version"
140- shell : bash -l {0}
141- run : |
142- VERSION="$( echo "${{ github.ref }}" | sed 's!refs/tags/v!!' )"
143- echo "Looking for packages with version $VERSION"
144- ls -l dist/*
145- packages=(
146- "dist/emsarray-$VERSION.tar.gz"
147- "dist/emsarray-$VERSION-*.whl"
148- )
149- for package in "${packages[@]}" ; do
150- if ! test -e $package ; then
151- echo "Could not find $package"
152- exit 1
153- fi
154- done
155-
156- - name : " Publish Python package"
157- uses : pypa/gh-action-pypi-publish@release/v1
158- with :
159- password : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments