77 # Run every Monday at 8am to check latest versions of dependencies
88 - cron : " 0 8 * * WED"
99env :
10- # the target python version. Make sure the Dockerfile uses the same
11- # version for its build and runtime targets.
10+ # Target python version. Make sure Dockerfile FROM's match this.
1211 PYTHON : " 3.10"
1312
1413jobs :
@@ -24,12 +23,12 @@ jobs:
2423 - name : Setup python
2524 uses : actions/setup-python@v4
2625 with :
27- python-version : ${{env.PYTHON}}
26+ python-version : ${{ env.PYTHON }}
2827
2928 - name : Lint
3029 run : |
31- touch requirements_dev .txt requirements.txt
32- pip install -r requirements.txt -r requirements_dev .txt -e .[dev]
30+ touch requirements_dev_py${{ env.PYTHON }} .txt requirements.txt
31+ pip install -r requirements.txt -r requirements_dev_py${{ env.PYTHON }} .txt -e .[dev]
3332 tox -e pre-commit,mypy
3433
3534 test :
6059 run : |
6160 pip install .[dev]
6261 mkdir -p lockfiles
63- pip freeze > lockfiles/requirements-dev-py ${{ matrix.python }}.txt
62+ pip freeze > lockfiles/requirements_dev_py ${{ matrix.python }}.txt
6463
6564 - name : Run tests
6665 run : pytest tests
@@ -90,12 +89,12 @@ jobs:
9089 - name : Setup python
9190 uses : actions/setup-python@v4
9291 with :
93- python-version : ${{env.PYTHON}}
92+ python-version : ${{ env.PYTHON }}
9493
9594 - name : Build Sdist and wheel
9695 run : |
9796 export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && \
98- pipx run --python $(which python${{env.PYTHON}}) build
97+ pipx run --python $(which python${{ env.PYTHON }}) build
9998
10099 # ${GITHUB_REPOSITORY##*/} is the repo name without org
101100 # Replace this with the cli command if different to the repo name
@@ -124,7 +123,6 @@ jobs:
124123
125124 container :
126125 needs : [dist]
127- if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
128126 runs-on : ubuntu-latest
129127
130128 permissions :
@@ -137,11 +135,11 @@ jobs:
137135 with :
138136 fetch-depth : 0
139137
140- - uses : actions/download-artifact@v3
138+ # image names must be all lower case
139+ - run : |
140+ echo IMAGE_REPOSITORY=ghcr.io/$(tr '[:upper:]' '[:lower:]' <<< "${{ github.repository }}") >> $GITHUB_ENV
141141
142- - name : PrepareReg Names
143- run : |
144- echo IMAGE_REPOSITORY=ghcr.io/$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
142+ - uses : actions/download-artifact@v3
145143
146144 - name : Log in to GitHub Docker Registry
147145 if : github.event_name != 'pull_request'
@@ -155,7 +153,7 @@ jobs:
155153 id : meta
156154 uses : docker/metadata-action@v4
157155 with :
158- images : ${{env.IMAGE_REPOSITORY}}
156+ images : ${{ env.IMAGE_REPOSITORY }}
159157 tags : |
160158 type=ref,event=tag
161159 type=raw,value=latest
@@ -167,22 +165,21 @@ jobs:
167165 - name : Build runtime image
168166 uses : docker/build-push-action@v3
169167 with :
170- push : true
171- load : true
168+ push : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
169+ load : ${{ ! (github.event_name == 'push' && startsWith(github.ref, 'refs/tags')) }}
172170 tags : ${{ steps.meta.outputs.tags }}
173171 context : .
172+ cache-from : type=gha
173+ cache-to : type=gha,mode=max
174174
175175 - name : Test cli works in runtime image
176- # check that the first tag can run with --version parameter
177- run : docker run ${{env.IMAGE_REPOSITORY}}:latest --version
178-
179- # TODO upload a tar of the image for later publishing
180- # TODO OR do the publish here ??? if its quick enough - MUCH easier ?
176+ # check that the latest tag can run with --version parameter
177+ run : docker run ${{ env.IMAGE_REPOSITORY }} --version
181178
182179 release :
183180 # upload to PyPI and make a release on every tag
184- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
185181 needs : [lint, dist]
182+ if : ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags') }}
186183 runs-on : ubuntu-latest
187184
188185 steps :
0 commit comments