-
Notifications
You must be signed in to change notification settings - Fork 5
107 lines (91 loc) · 3.37 KB
/
Copy pathpublish.yml
File metadata and controls
107 lines (91 loc) · 3.37 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
name: Publish
on:
push:
tags:
- "v*.*.*"
env:
PYTHON_VERSION: "3.10"
jobs:
build_and_test_package:
uses: ./.github/workflows/build-test-python.yml
build_and_test_docker:
uses: ./.github/workflows/build-test-docker.yml
with:
image-tag: latest
publish_to_pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [build_and_test_package, build_and_test_docker]
permissions:
id-token: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download package artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: python-package-${{ github.sha }}
path: dist
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "0.8.22"
- name: Publish package
run: |
uv publish
publish_to_dockerhub:
name: Push Docker images to registries
runs-on: ubuntu-latest
needs: [build_and_test_docker, build_and_test_package]
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@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker images
uses: ./.github/actions/docker-build
with:
push: "true"
platforms: linux/amd64,linux/arm64
dockerfile: ./Dockerfile
context: .
image-name: elementsinteractive/twyn
cache-from: |
type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
- 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/twyn/versions" --paginate)
# Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^buildcache-")) | any | 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/twyn/versions/$id"
done
release_notes:
runs-on: ubuntu-latest
needs: [publish_to_pypi, publish_to_dockerhub]
permissions:
contents: write
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 }}"