-
Notifications
You must be signed in to change notification settings - Fork 159
181 lines (163 loc) · 5.84 KB
/
publish.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
181
name: Upload Python Package and Docker Image on Release
on:
release:
types: [created]
jobs:
pypi-publish:
name: Publish release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/optillm
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package
run: |
python setup.py sdist bdist_wheel
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
docker-publish:
name: Publish Docker image
runs-on: ubuntu-22.04
needs: pypi-publish
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
# Add aggressive cleanup before any Docker operations
- name: Free disk space
run: |
# Remove large unnecessary packages
sudo apt-get remove -y '^dotnet-.*' '^llvm-.*' 'php.*' azure-cli google-cloud-sdk mongodb-org
sudo apt-get autoremove -y
sudo apt-get clean
# Remove large directories
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
# Clean Docker
docker system prune -af
docker image prune -af
docker builder prune -af
df -h
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:buildx-stable-1
network=host
buildkitd-flags: --debug
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata for proxy_only image
- name: Extract metadata for proxy_only Docker
id: meta-proxy
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
flavor: |
suffix=-proxy
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest
# Build and push proxy AMD64
- name: Build and push proxy_only Docker image AMD64
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.proxy_only
push: true
platforms: linux/amd64
tags: ${{ steps.meta-proxy.outputs.tags }}
labels: ${{ steps.meta-proxy.outputs.labels }}
cache-from: type=gha,scope=proxy-amd64
cache-to: type=gha,scope=proxy-amd64,mode=max
outputs: type=registry,compression=zstd,compression-level=5
# Cleanup after AMD64 build
- name: Cleanup after AMD64 build
run: |
docker system prune -af
docker builder prune -af
df -h
# Build proxy ARM64
- name: Build and push proxy_only Docker image ARM64
uses: docker/build-push-action@v5
with:
context: .
file: Dockerfile.proxy_only
push: true
platforms: linux/arm64
tags: ${{ steps.meta-proxy.outputs.tags }}
labels: ${{ steps.meta-proxy.outputs.labels }}
cache-from: type=gha,scope=proxy-arm64
cache-to: type=gha,scope=proxy-arm64,mode=max
outputs: type=registry,compression=zstd,compression-level=5
# Cleanup after proxy builds
- name: Cleanup after proxy builds
run: |
docker system prune -af
docker builder prune -af
find /tmp -type f -user $(id -u) -exec rm -f {} + 2>/dev/null || true
df -h
# Extract metadata for full image
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
latest
# Build full image AMD64
- name: Build and push Docker image AMD64
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=full-amd64
cache-to: type=gha,scope=full-amd64,mode=max
outputs: type=registry,compression=zstd,compression-level=5
# Cleanup between architectures
- name: Cleanup between architectures
run: |
docker system prune -af
docker builder prune -af
df -h
# Build full image ARM64
- name: Build and push Docker image ARM64
uses: docker/build-push-action@v5
with:
context: .
push: true
platforms: linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=full-arm64
cache-to: type=gha,scope=full-arm64,mode=max
outputs: type=registry,compression=zstd,compression-level=5