Skip to content

Commit 086b349

Browse files
committed
Create release.yml
1 parent 23b0495 commit 086b349

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

.github/workflows/release.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: Upload Python Package and Docker Image on Release
2+
on:
3+
release:
4+
types: [created]
5+
6+
jobs:
7+
pypi-publish:
8+
name: Publish release to PyPI
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: pypi
12+
url: https://pypi.org/p/openevolve
13+
permissions:
14+
id-token: write
15+
steps:
16+
- uses: actions/checkout@v4
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: "3.x"
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install build
25+
- name: Build package
26+
run: |
27+
python -m build
28+
- name: Publish package distributions to PyPI
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
31+
docker-publish:
32+
name: Publish Docker image
33+
runs-on: ubuntu-22.04
34+
needs: pypi-publish
35+
permissions:
36+
contents: read
37+
packages: write
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
# Add aggressive cleanup before any Docker operations
42+
- name: Free disk space
43+
run: |
44+
# Clean Docker
45+
docker system prune -af
46+
docker image prune -af
47+
docker builder prune -af
48+
49+
df -h
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@v3
53+
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
with:
57+
driver-opts: |
58+
image=moby/buildkit:buildx-stable-1
59+
network=host
60+
buildkitd-flags: --debug
61+
62+
- name: Log in to GitHub Container Registry
63+
uses: docker/login-action@v3
64+
with:
65+
registry: ghcr.io
66+
username: ${{ github.actor }}
67+
password: ${{ secrets.GITHUB_TOKEN }}
68+
69+
# Extract metadata for Docker image
70+
- name: Extract metadata for Docker
71+
id: meta
72+
uses: docker/metadata-action@v5
73+
with:
74+
images: ghcr.io/${{ github.repository }}
75+
tags: |
76+
type=semver,pattern={{version}}
77+
type=semver,pattern={{major}}.{{minor}}
78+
type=raw,value=latest
79+
80+
# Build and push Docker image for AMD64
81+
- name: Build and push Docker image AMD64
82+
uses: docker/build-push-action@v5
83+
with:
84+
context: .
85+
file: Dockerfile
86+
push: true
87+
platforms: linux/amd64
88+
tags: ${{ steps.meta.outputs.tags }}
89+
labels: ${{ steps.meta.outputs.labels }}
90+
cache-from: type=gha,scope=openevolve-amd64
91+
cache-to: type=gha,scope=openevolve-amd64,mode=max
92+
outputs: type=registry,compression=zstd,compression-level=5
93+
94+
# Cleanup after AMD64 build
95+
- name: Cleanup after AMD64 build
96+
run: |
97+
docker system prune -af
98+
docker builder prune -af
99+
df -h
100+
101+
# Build and push Docker image for ARM64
102+
- name: Build and push Docker image ARM64
103+
uses: docker/build-push-action@v5
104+
with:
105+
context: .
106+
file: Dockerfile
107+
push: true
108+
platforms: linux/arm64
109+
tags: ${{ steps.meta.outputs.tags }}
110+
labels: ${{ steps.meta.outputs.labels }}
111+
cache-from: type=gha,scope=openevolve-arm64
112+
cache-to: type=gha,scope=openevolve-arm64,mode=max
113+
outputs: type=registry,compression=zstd,compression-level=5
114+
115+
# Final cleanup
116+
- name: Final cleanup
117+
run: |
118+
docker system prune -af
119+
docker builder prune -af
120+
find /tmp -type f -user $(id -u) -exec rm -f {} + 2>/dev/null || true
121+
df -h

0 commit comments

Comments
 (0)