-
-
Notifications
You must be signed in to change notification settings - Fork 755
192 lines (172 loc) · 6.26 KB
/
release.yml
File metadata and controls
192 lines (172 loc) · 6.26 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
name: Create Release and Publish Docker Images
on:
push:
branches:
- release # Auto-trigger only on release branch
paths-ignore:
- '**.md'
- 'docs/**'
workflow_dispatch: # Manual trigger - explicitly specify branch
inputs:
branch_name:
description: 'Branch to build from (required)'
required: true
type: string
jobs:
prepare-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
version_tag: ${{ steps.get-version.outputs.version_tag }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get version from VERSION file
id: get-version
run: |
VERSION_PLAIN=$(cat VERSION)
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
BRANCH_NAME="${{ inputs.branch_name }}"
else
BRANCH_NAME="${{ github.ref_name }}"
fi
if [[ "$BRANCH_NAME" == "release" ]]; then
echo "version=${VERSION_PLAIN}" >> $GITHUB_OUTPUT
echo "version_tag=v${VERSION_PLAIN}" >> $GITHUB_OUTPUT
else
SAFE_BRANCH=$(echo "$BRANCH_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "version=${VERSION_PLAIN}-${SAFE_BRANCH}" >> $GITHUB_OUTPUT
echo "version_tag=v${VERSION_PLAIN}-${SAFE_BRANCH}" >> $GITHUB_OUTPUT
fi
build-images:
needs: prepare-release
permissions:
packages: write
env:
DOCKER_BUILDKIT: 1
BUILDKIT_STEP_LOG_MAX_SIZE: 10485760
VERSION: ${{ needs.prepare-release.outputs.version_tag }}
REGISTRY: ${{ vars.REGISTRY || 'ghcr.io' }}
OWNER: ${{ vars.OWNER || 'remsky' }}
REPO: ${{ vars.REPO || 'kokoro-fastapi' }}
strategy:
matrix:
include:
- build_target: "cpu"
platform: "linux/amd64"
runs_on: "ubuntu-latest"
- build_target: "gpu"
platform: "linux/amd64"
runs_on: "ubuntu-latest"
- build_target: "cpu"
platform: "linux/arm64"
runs_on: "ubuntu-24.04-arm"
- build_target: "gpu"
platform: "linux/arm64"
runs_on: "ubuntu-24.04-arm"
- build_target: "rocm"
platform: "linux/amd64"
runs_on: "ubuntu-latest"
runs-on: ${{ matrix.runs_on }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to check for existing tags
- name: Check if tag already exists
run: |
TAG_NAME="${{ needs.prepare-release.outputs.version_tag }}"
echo "Checking for existing tag: $TAG_NAME"
git fetch --tags
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "::error::Tag $TAG_NAME already exists. Please increment the version in the VERSION file."
exit 1
else
echo "Tag $TAG_NAME does not exist. Proceeding with release."
fi
- name: Free disk space
run: |
echo "Listing current disk space"
df -h
echo "Cleaning up disk space..."
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache
docker system prune -af
echo "Disk space after cleanup"
df -h
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 # Use v3
with:
driver-opts: |
image=moby/buildkit:latest
network=host
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3 # Use v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push single-platform image
run: |
PLATFORM="${{ matrix.platform }}"
BUILD_TARGET="${{ matrix.build_target }}"
VERSION_TAG="${{ needs.prepare-release.outputs.version_tag }}"
echo "Building ${PLATFORM} image for ${BUILD_TARGET} version ${VERSION_TAG}"
TARGET="${BUILD_TARGET}-$(echo ${PLATFORM} | cut -d'/' -f2)"
echo "Using bake target: $TARGET"
docker buildx bake $TARGET --push --progress=plain
create-manifests:
needs: [prepare-release, build-images]
runs-on: ubuntu-latest
permissions:
packages: write
env:
REGISTRY: ${{ vars.REGISTRY || 'ghcr.io' }}
OWNER: ${{ vars.OWNER || 'remsky' }}
REPO: ${{ vars.REPO || 'kokoro-fastapi' }}
strategy:
matrix:
build_target: ["cpu", "gpu", "rocm"]
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create multi-platform manifest
run: |
VERSION_TAG="${{ needs.prepare-release.outputs.version_tag }}"
TARGET="${{ matrix.build_target }}"
REGISTRY="${{ env.REGISTRY }}"
OWNER="${{ env.OWNER }}"
REPO="${{ env.REPO }}"
docker buildx imagetools create -t \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG} \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-amd64 \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-arm64
if [[ "$VERSION_TAG" != *"-"* ]]; then
docker buildx imagetools create -t \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:latest \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-amd64 \
${REGISTRY}/${OWNER}/${REPO}-${TARGET}:${VERSION_TAG}-arm64
fi
create-release:
needs: [prepare-release, create-manifests]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ needs.prepare-release.outputs.version_tag }}
name: Release ${{ needs.prepare-release.outputs.version_tag }}
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}