-
Notifications
You must be signed in to change notification settings - Fork 4
137 lines (125 loc) · 4.76 KB
/
build-engine-container.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
name: Build Docker
on:
push:
branches:
- master
release:
types:
- created
workflow_dispatch:
inputs:
version:
description: "バージョン情報(A.BB.C / A.BB.C-preview.D)"
required: true
env:
PYTHON_VERSION: "3.11.9"
IMAGE_NAME: ghcr.io/aivis-project/aivisspeech-engine
defaults:
run:
shell: bash
jobs:
config: # 全 jobs で利用する定数の定義. `env` が利用できないコンテキストでも利用できる.
runs-on: ubuntu-latest
outputs:
version_or_latest: ${{ steps.vars.outputs.version_or_latest }}
steps:
- name: <Setup> Declare variables
id: vars
run: |
: # releaseタグ名か、workflow_dispatchでのバージョン名か、latestが入る
echo "version_or_latest=${{ github.event.release.tag_name || github.event.inputs.version || 'latest' }}" >> "$GITHUB_OUTPUT"
build-docker:
needs: [config]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
tag:
- ""
- cpu
- nvidia
include:
# Ubuntu 22.04
- tag: ""
target: runtime-env
base_image: ubuntu:22.04
base_runtime_image: ubuntu:22.04
platforms: linux/amd64,linux/arm64/v8
- tag: cpu
target: runtime-env
base_image: ubuntu:22.04
base_runtime_image: ubuntu:22.04
platforms: linux/amd64,linux/arm64/v8
- tag: nvidia
target: runtime-nvidia-env
base_image: ubuntu:22.04
base_runtime_image: nvidia/cuda:12.3.2-cudnn9-runtime-ubuntu22.04
platforms: linux/amd64
steps:
- name: <Setup> Check out the repository
uses: actions/checkout@v4
- name: <Setup> Prepare Python version
id: prepare-python
uses: ./.github/actions/prepare_python
with:
only-export-python-version: true
- name: <Setup> Set up QEMU
uses: docker/setup-qemu-action@v3
- name: <Setup> Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: <Setup> Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: <Build/Deploy> Build and Deploy Docker image
uses: docker/build-push-action@v5
env:
IMAGE_TAG:
|- # If it's a release, add the version, otherwise add the `latest`
${{ (
matrix.tag != '' && (
format('{0}:{1}-{2}', env.IMAGE_NAME, matrix.tag, needs.config.outputs.version_or_latest)
) || format('{0}:{1}', env.IMAGE_NAME, needs.config.outputs.version_or_latest)
) }}
IMAGE_CACHE_FROM:
|- # Always use the `latest` buildcache. :latest-buildcache or :{tag}-latest-buildcache
${{ (
matrix.tag != '' && (
format('type=registry,ref={0}:{1}-latest-buildcache', env.IMAGE_NAME, matrix.tag)
) || format('type=registry,ref={0}:latest-buildcache', env.IMAGE_NAME)
) }}
IMAGE_CACHE_TO:
|- # If it's a release, do not create buildcache, otherwise create the `latest` buildcache. :latest-buildcache or :{tag}-latest-buildcache
${{ (
needs.config.outputs.version_or_latest == 'latest' && (
matrix.tag != '' && (
format('type=registry,ref={0}:{1}-latest-buildcache,mode=max', env.IMAGE_NAME, matrix.tag)
) || format('type=registry,ref={0}:latest-buildcache,mode=max', env.IMAGE_NAME)
) || ''
) }}
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
build-args: |
BASE_IMAGE=${{ matrix.base_image }}
BASE_RUNTIME_IMAGE=${{ matrix.base_runtime_image }}
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
AIVISSPEECH_ENGINE_VERSION=${{ needs.config.outputs.version_or_latest }}
target: ${{ matrix.target }}
push: true
tags: ${{ env.IMAGE_TAG }}
cache-from: ${{ env.IMAGE_CACHE_FROM }}
cache-to: ${{ env.IMAGE_CACHE_TO }}
platforms: ${{ matrix.platforms }}
run-release-test-workflow:
# version が指定されている場合のみ実行する
if: needs.config.outputs.version_or_latest != 'latest'
needs: [config, build-docker]
uses: ./.github/workflows/test-engine-container.yml
with:
version: ${{ needs.config.outputs.version_or_latest }}
repo_url: ${{ format('{0}/{1}', github.server_url, github.repository) }} # このリポジトリのURL