-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (161 loc) · 7.04 KB
/
release_docker.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Release (Docker Images)
run-name: |
docker release [${{github.ref_type == 'tag' && 'stable' || 'nightly' }}, ${{github.ref_name}}]
on:
workflow_dispatch:
workflow_call:
concurrency:
group: docker-release-${{github.ref_type == 'tag' && 'stable' || 'nightly' }}
cancel-in-progress: false
permissions:
contents: write
packages: write
env:
CLONE_DIR: src/repo
jobs:
build:
runs-on: ubuntu-latest
outputs:
TEST_RUNNERS_MATRIX: ${{ steps.config.outputs.TEST_RUNNERS_MATRIX }}
steps:
- name: Clone source repository
uses: actions/checkout@v4
with:
path: ${{ env.CLONE_DIR }}
submodules: true
- name: Load configuration
uses: mentalsmash/actions/pyconfig/configuration@master
with:
clone-dir: ${{ env.CLONE_DIR }}
- name: Configure workflow
id: config
run: |
(
printf -- "BUILD_SETTINGS_ARTIFACT=%s\n" "$(jq '.build.settings.artifact' -j pyconfig.json)"
printf -- "DOCKER_BASE_IMAGE=%s\n" "$(jq '.release.base_image' -j pyconfig.json)"
printf -- "%s\n" "DOCKER_TAGS_CONFIG<<EOF"
# printf -- "%s\n" "$(jq '.release.tags_config' -j pyconfig.json)"
jq '.release.tags_config' -j pyconfig.json
echo
printf -- "%s\n" EOF
printf -- "%s\n" "DOCKER_FLAVOR_CONFIG<<EOF"
# printf -- "%s\n" "$(jq '.release.flavor_config' -j pyconfig.json)"
jq '.release.flavor_config' -j pyconfig.json
echo
printf -- "%s\n" EOF
printf -- "DOCKER_BUILD_PLATFORMS=%s\n" "$(jq '.release.build_platforms_config' -j pyconfig.json)"
printf -- "PRERELEASE_REPO=%s\n" "$(jq '.release.prerelease_repo' -j pyconfig.json)"
printf -- "TEST_RUNNERS_MATRIX=%s\n" "$(jq '.release.test_runners_matrix' -j pyconfig.json)"
printf -- "ADMIN_IMAGE=%s\n" "$(jq '.ci.images.admin.image' -r pyconfig.json)"
printf -- "PRERELEASE_PACKAGE=%s\n" "$(jq '.release.prerelease_package' -j pyconfig.json)"
printf -- "PRERELEASE_PACKAGE_ORG=%s\n" "$(jq '.release.prerelease_package_org' -j pyconfig.json)"
printf -- "LOGIN_DOCKERHUB=%s\n" "$(jq '.ci.images.admin.login.dockerhub' -r pyconfig.json)"
printf -- "LOGIN_GITHUB=%s\n" "$(jq '.ci.images.admin.login.github' -r pyconfig.json)"
) | tee -a ${GITHUB_OUTPUT}
- name: Upload project settings
uses: actions/upload-artifact@v4
with:
name: ${{ steps.config.outputs.BUILD_SETTINGS_ARTIFACT }}
path: pyconfig.json
- name: Delete all versions of the prerelease package
if: steps.config.outputs.PRERELEASE_PACKAGE
uses: mentalsmash/actions/ci/admin@master
with:
image: ${{ steps.config.outputs.ADMIN_IMAGE }}
token: ${{ secrets.PACKAGE_VERSIONS_PAT }}
github-token: ${{ steps.config.outputs.LOGIN_GITHUB && secrets.GITHUB_TOKEN || '' }}
github-user: ${{ steps.config.outputs.LOGIN_GITHUB && github.actor || '' }}
dockerhub-token: ${{ steps.config.outputs.LOGIN_DOCKERHUB && secrets.DOCKERHUB_TOKEN || '' }}
dockerhub-user: ${{ steps.config.outputs.LOGIN_DOCKERHUB && vars.DOCKERHUB_USERNAME || '' }}
args: |
-c
${{ github.run_id }}
delete-versions
-o
${{ steps.config.outputs.PRERELEASE_PACKAGE_ORG }}
-p
${{ steps.config.outputs.PRERELEASE_PACKAGE }}
--if-package-exists
- name: Build image
uses: mentalsmash/actions/docker/builder@master
with:
base-image: ${{ steps.config.outputs.DOCKER_BASE_IMAGE }}
build-platforms: ${{ steps.config.outputs.DOCKER_BUILD_PLATFORMS }}
context: ${{ env.CLONE_DIR }}
dockerfile: ${{ env.CLONE_DIR }}/docker/Dockerfile
image-flavor-config: ${{ steps.config.outputs.DOCKER_FLAVOR_CONFIG }}
image-tags-config: ${{ steps.config.outputs.DOCKER_TAGS_CONFIG }}
image-repos: ${{ steps.config.outputs.PRERELEASE_REPO }}
github-token: ${{ secrets.GITHUB_TOKEN }}
github-user: ${{ github.actor }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
dockerhub-user: ${{ vars.DOCKERHUB_USERNAME }}
action: push
test:
needs:
- build
strategy:
matrix:
runner: ${{ fromJson(needs.build.outputs.TEST_RUNNERS_MATRIX) }}
runs-on: ${{ fromJson(matrix.runner) }}
steps:
- name: Clone source repository
uses: actions/checkout@v4
with:
path: ${{ env.CLONE_DIR }}
submodules: true
- name: Load configuration
uses: mentalsmash/actions/pyconfig/configuration@master
with:
clone-dir: ${{ env.CLONE_DIR }}
- name: Configure workflow
id: config
run: |
(
printf -- "LOCAL_TESTER_IMAGE=%s\n" "$(jq '.ci.images.local_tester.image' -j pyconfig.json)"
printf -- "LOCAL_TESTER_RESULTS=%s\n" "$(jq '.ci.test.results_dir' -j pyconfig.json)"
printf -- "PRERELEASE_IMAGE=%s\n" "$(jq '.release.prerelease_image' -j pyconfig.json)"
printf -- "TEST_ARTIFACT=%s\n" "$(jq '.release.test_artifact' -j pyconfig.json)"
printf -- "TEST_DATE=%s\n" "$(jq '.build.date' -j pyconfig.json)"
printf -- "TEST_ID=%s\n" "$(jq '.release.test_id' -j pyconfig.json)"
) | tee -a ${GITHUB_OUTPUT}
- name: Build image
uses: mentalsmash/actions/docker/builder@master
with:
base-image: ${{ steps.config.outputs.PRERELEASE_IMAGE }}
dockerfile: ${{ env.CLONE_DIR }}/docker/test/Dockerfile
context: ${{ env.CLONE_DIR }}
image-tags: ${{ steps.config.outputs.LOCAL_TESTER_IMAGE }}
github-token: ${{ secrets.GITHUB_TOKEN }}
github-user: ${{ github.actor }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
dockerhub-user: ${{ vars.DOCKERHUB_USERNAME }}
action: load
- name: Generate architecture ID
id: arch
run: |
(
case "$(uname -m)" in
x86_64)
echo ARCH=amd64
;;
aarch64)
echo ARCH=arm64
;;
esac
) | tee -a ${GITHUB_OUTPUT}
- name: Run tests
run: |
make -C ${{ env.CLONE_DIR }} test-release
env:
DEBUG: ${{ runner.debug }}
LOCAL_TESTER_IMAGE: ${{ steps.config.outputs.LOCAL_TESTER_IMAGE }}
LOCAL_TESTER_RESULTS: ${{ steps.config.outputs.LOCAL_TESTER_RESULTS }}
TEST_DATE: ${{ steps.config.outputs.TEST_DATE }}
TEST_ID: ${{ steps.config.outputs.TEST_ID }}__${{ steps.arch.outputs.ARCH }}
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ steps.config.outputs.TEST_ARTIFACT }}__${{ steps.arch.outputs.ARCH }}
path: ${{ env.CLONE_DIR }}/${{ steps.config.outputs.LOCAL_TESTER_RESULTS }}/**