Skip to content

Commit cc1e877

Browse files
committed
ci: require to test python package and docker build before publishing
1 parent 00090ff commit cc1e877

File tree

4 files changed

+57
-34
lines changed

4 files changed

+57
-34
lines changed

.github/actions/docker-build/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ inputs:
4444
required: false
4545
default: "false"
4646

47+
outputs:
48+
image-tag:
49+
description: "Tag of the built image"
50+
value: ${{ steps.meta.outputs.tags }}
51+
4752
runs:
4853
using: "composite"
4954
steps:
@@ -71,7 +76,7 @@ runs:
7176
type=semver,enable=true,pattern={{major}},prefix=v
7277
type=ref,event=pr,prefix=pr-,enable=true
7378
type=ref,event=branch,branch=main,pattern={{raw}}
74-
type=ref,event=branch,branch=main,pattern={{major}},prefix=v
79+
type=ref,event=branch,branch=main,pattern={{major}}
7580
7681
- name: Build Docker image
7782
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0

.github/workflows/build-test-docker.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
name: Build and Test Docker Image
22

33
on:
4-
pull_request:
5-
branches: ["main"]
6-
push:
7-
branches: ["main"]
4+
# pull_request:
5+
# branches: ["main"]
6+
workflow_call:
7+
inputs:
8+
config:
9+
type: string
810

911
jobs:
1012
should-test-docker-build:

.github/workflows/build-test-python.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
name: Build and Test Python Package
44

55
on:
6-
pull_request:
7-
branches: ["main"]
8-
push:
9-
branches: ["main"]
6+
# pull_request:
7+
# branches: ["main"]
8+
workflow_call:
9+
inputs:
10+
config:
11+
type: string
1012

1113
env:
1214
PYTHON_VERSION: "3.10"

.github/workflows/publish.yml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,47 @@ on:
44
push:
55
tags:
66
- "v*.*.*"
7+
pull_request:
8+
branches: ["main"]
9+
env:
10+
UV_VERSION: "0.8.22"
11+
PYTHON_VERSION: "3.10"
712

813
jobs:
14+
build_and_test_package:
15+
uses: ./.github/workflows/build-test-python.yml
16+
17+
build_and_test_docker:
18+
uses: ./.github/workflows/build-test-docker.yml
19+
920
publish_to_pypi:
1021
name: Publish to PyPI
1122
runs-on: ubuntu-latest
12-
23+
needs: [build_and_test_package, build_and_test_docker]
1324
permissions:
1425
id-token: write
15-
contents: read
16-
1726
steps:
1827
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1928

20-
- name: Build package
21-
uses: ./.github/actions/python-package-build
22-
id: build
29+
- name: Download package artifacts
30+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
31+
with:
32+
name: python-package-${{ github.sha }}
33+
path: dist
34+
35+
- name: Install uv
36+
uses: astral-sh/setup-uv@eac588ad8def6316056a12d4907a9d4d84ff7a3b # v7.3.0
2337
with:
24-
uv-version: "0.8.22"
25-
python-version: "3.10"
38+
version: ${{ env.UV_VERSION }}
2639

27-
- name: Publish package
28-
run: |
29-
uv publish
40+
# - name: Publish package
41+
# run: |
42+
# uv publish
3043

3144
publish_to_dockerhub:
3245
name: Push Docker images to registries
3346
runs-on: ubuntu-latest
47+
needs: [build_and_test_docker, build_and_test_package]
3448
permissions:
3549
contents: read
3650
packages: write
@@ -54,7 +68,7 @@ jobs:
5468
- name: Push Docker images
5569
uses: ./.github/actions/docker-build
5670
with:
57-
push: "true"
71+
# push: "true"
5872
platforms: linux/amd64,linux/arm64
5973
dockerfile: ./Dockerfile
6074
context: .
@@ -63,21 +77,21 @@ jobs:
6377
type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-amd64
6478
type=registry,ref=ghcr.io/elementsinteractive/twyn:buildcache-arm64
6579
66-
- name: Delete old cache entries
67-
env:
68-
GH_TOKEN: ${{ github.token }}
69-
run: |
70-
# Get all versions of the container package
71-
versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)
80+
# - name: Delete old cache entries
81+
# env:
82+
# GH_TOKEN: ${{ github.token }}
83+
# run: |
84+
# # Get all versions of the container package
85+
# versions=$(gh api "orgs/elementsinteractive/packages/container/twyn/versions" --paginate)
7286

73-
# Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
74-
ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^buildcache-")) | any | not) | .id')
87+
# # Extract version IDs that do NOT have any buildcache-* tags (buildcache-amd64, buildcache-arm64, etc.)
88+
# ids_to_delete=$(echo "$versions" | jq -r '.[] | select(.metadata.container.tags | map(test("^buildcache-")) | any | not) | .id')
7589

76-
# Delete them
77-
for id in $ids_to_delete; do
78-
echo "Deleting old cache version ID: $id"
79-
gh api -X DELETE "orgs/elementsinteractive/packages/container/twyn/versions/$id"
80-
done
90+
# # Delete them
91+
# for id in $ids_to_delete; do
92+
# echo "Deleting old cache version ID: $id"
93+
# gh api -X DELETE "orgs/elementsinteractive/packages/container/twyn/versions/$id"
94+
# done
8195

8296
release_notes:
8397
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)