-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (75 loc) · 2.89 KB
/
publish.yml
File metadata and controls
88 lines (75 loc) · 2.89 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
# This workflow will publish our package on pypi
name: Publish
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
push_to_pypi:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
- name: Publish to pypi
run: |
uv build --python 3.13
uv publish
push_to_docker_hub:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Check out the repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Log in to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: ./.github/actions/docker-build
with:
push-image: "true"
platforms: linux/amd64,linux/arm64
dockerfile: ./Dockerfile
context: .
image-name: elementsinteractive/lightman-ai
cache-from: type=registry,ref=ghcr.io/elementsinteractive/lightman-ai:buildcache
cache-to: type=registry,ref=ghcr.io/elementsinteractive/lightman-ai:buildcache,mode=max,compression=zstd,force-compression=true,oci-mediatypes=true
- name: Delete old cache entries
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get all versions of the container package
versions=$(gh api "orgs/elementsinteractive/packages/container/lightman-ai/versions" --paginate)
# Extract version IDs that do NOT have the 'buildcache' tag
ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | index("buildcache") | not) | .id')
# Delete them
for id in $ids_to_delete; do
echo "Deleting old cache version ID: $id"
gh api -X DELETE "orgs/elementsinteractive/packages/container/lightman-ai/versions/$id"
done
release_notes:
runs-on: ubuntu-latest
needs: [push_to_pypi, push_to_docker_hub]
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda #v3.0.0
with:
generate_release_notes: true
token: "${{ secrets.GITHUB_TOKEN }}"