Skip to content

Commit

Permalink
manage latest python version more elegantly
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Dec 11, 2023
1 parent 8a8f532 commit c34e64e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/build_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ env:
jobs:
build_docker_images:
runs-on: 'ubuntu-20.04'
env:
latest_python: '3.11'
strategy:
matrix:
version:
- {'python': '3.7', 'latest': false}
- {'python': '3.8', 'latest': false}
- {'python': '3.9', 'latest': false}
- {'python': '3.10', 'latest': false}
- {'python': '3.11', 'latest': true}
python_version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
Expand All @@ -30,9 +32,9 @@ jobs:
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-python${{ matrix.version.python }}-${{ github.sha }}
key: ${{ runner.os }}-buildx-python${{ matrix.python_version }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-python${{ matrix.version.python }}-
${{ runner.os }}-buildx-python${{ matrix.python_version }}-
- name: Login to DockerHub
uses: docker/login-action@v3
Expand All @@ -45,13 +47,13 @@ jobs:
with:
context: .
file: Dockerfile
build-args: 'PYTHON_VERSION=${{ matrix.version.python }}'
build-args: 'PYTHON_VERSION=${{ matrix.python_version }}'
push: ${{ github.ref_type == 'tag' }}
tags: |
${{ env.IMAGE_NAME }}:latest-python${{ matrix.version.python }}
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python${{ matrix.version.python }}
${{ matrix.version.latest && format('{0}:{1}', env.IMAGE_NAME, github.ref_name) || '' }}
${{ matrix.version.latest && format('{0}:latest', env.IMAGE_NAME) || '' }}
${{ env.IMAGE_NAME }}:latest-python${{ matrix.python_version }}
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python${{ matrix.python_version }}
${{ (matrix.python_version == env.latest_python) && format('{0}:{1}', env.IMAGE_NAME, github.ref_name) || '' }}
${{ (matrix.python_version == env.latest_python) && format('{0}:latest', env.IMAGE_NAME) || '' }}
cache-from: |
type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
Expand Down

0 comments on commit c34e64e

Please sign in to comment.