-
Notifications
You must be signed in to change notification settings - Fork 6
133 lines (119 loc) · 4.82 KB
/
container_builds_weekly.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Weekly wheel build images
on:
schedule:
- cron: "42 5 * * 1"
workflow_dispatch:
inputs:
use_cache:
description: Use GH Actions cache
type: boolean
required: false
default: true
env:
CONTAINER_REGISTRY: ghcr.io
jobs:
build_wheel_linux_dockers:
name: Build wheel containers
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
# 64-bit linux
- system: "manylinux"
type: "2010"
arch: "x86_64"
py_minors: "8 9"
- system: "manylinux"
type: "2014"
arch: "x86_64"
py_minors: "8 9 10 11 12"
- system: "manylinux"
type: "_2_28"
arch: "x86_64"
py_minors: "8 9 10 11 12"
- system: "musllinux"
type: "_1_1"
arch: "x86_64"
py_minors: "8 9 10 11"
- system: "musllinux"
type: "_1_2"
arch: "x86_64"
py_minors: "8 9 10 11"
# 32-bit linux
- system: "manylinux"
type: "2010"
arch: "i686"
py_minors: "8 9"
- system: "manylinux"
type: "2014"
arch: "i686"
py_minors: "8 9 10 11 12"
- system: "musllinux"
type: "_1_1"
arch: "i686"
py_minors: "8 9 10 11"
- system: "musllinux"
type: "_1_2"
arch: "i686"
py_minors: "8 9 10 11"
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Setup cache
if: github.event_name != 'workflow_dispatch' || fromJSON(github.event.inputs.use_cache)
uses: actions/cache@v4
with:
path: .buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
key: buildx-cache-${{ matrix.system }}${{ matrix.type }}-${{ matrix.arch }}-${{ github.sha }}
restore-keys: buildx-cache-${{ matrix.system }}${{ matrix.type }}-${{ matrix.arch }}-
- name: Check 'latest' parent image SHA
run: |
IMAGE=quay.io/pypa/${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}:latest
SHA_FILENAME=${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}:latest.sha.txt
docker pull ${IMAGE}
docker images --no-trunc --quiet ${IMAGE} > ${SHA_FILENAME}
CACHE_DIR=.buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
if [ -f "${CACHE_DIR}/${SHA_FILENAME}" ] && [ "$( cat ${SHA_FILENAME} )" == "$( cat ${CACHE_DIR}/${SHA_FILENAME} )" ]; then
echo "BUILD_NEW_IMAGE=false" >> $GITHUB_ENV
else
echo "BUILD_NEW_IMAGE=true" >> $GITHUB_ENV
fi
- name: Create docker file
if: env.BUILD_NEW_IMAGE == 'true'
run: |
mkdir -p docker_build_wheel
bash .github/docker/gen_dockerfile.sh ${{ matrix.system }} ${{ matrix.type }} ${{ matrix.arch }} \
> docker_build_wheel/Dockerfile-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
- name: Login to GitHub Container Registry
if: env.BUILD_NEW_IMAGE == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
if: env.BUILD_NEW_IMAGE == 'true'
uses: docker/build-push-action@v6
with:
context: .
file: docker_build_wheel/Dockerfile-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
tags: ${{ env.CONTAINER_REGISTRY }}/sintef/dlite-python-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}:latest
push: true
build-args: |
PY_MINORS=${{ matrix.py_minors }}
cache-from: type=local,src=.buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
cache-to: type=local,dest=.buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}-new,mode=max
# Temporary fix from https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
if: env.BUILD_NEW_IMAGE == 'true'
run: |
rm -rf .buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
mv .buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}-new .buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}
- name: Add sha.txt to cache
if: env.BUILD_NEW_IMAGE == 'true'
run: mv ${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}:latest.sha.txt .buildx-cache-${{ matrix.system }}${{ matrix.type }}_${{ matrix.arch }}