5
5
workflow_call :
6
6
inputs :
7
7
tag_suffix :
8
- description : ' Custom tag suffix for the Docker image'
8
+ description : " Custom tag suffix for the Docker image"
9
9
required : false
10
10
type : string
11
- default : ' '
11
+ default : " "
12
12
is_nightly :
13
- description : ' Whether this is a nightly build'
13
+ description : " Whether this is a nightly build"
14
14
required : false
15
15
type : boolean
16
16
default : false
17
17
skip_multiarch :
18
- description : ' Skip multi-architecture build for faster CI'
18
+ description : " Skip multi-architecture build for faster CI"
19
19
required : false
20
20
type : boolean
21
21
default : false
22
22
push :
23
- branches : [ "main" ]
23
+ branches : ["main"]
24
24
25
25
jobs :
26
26
# Parallel job for building both images
@@ -35,115 +35,110 @@ jobs:
35
35
fail-fast : false # Continue building other images if one fails
36
36
37
37
steps :
38
- - name : Check out the repo
39
- uses : actions/checkout@v4
38
+ - name : Check out the repo
39
+ uses : actions/checkout@v4
40
40
41
- - name : Set up Docker Buildx
42
- uses : docker/setup-buildx-action@v3
43
- with :
44
- driver-opts : |
45
- network=host
46
- image=moby/buildkit:v0.12.5
41
+ - name : Set up Docker Buildx
42
+ uses : docker/setup-buildx-action@v3
47
43
48
- - name : Set up QEMU (only for multi-arch builds)
49
- if : inputs.skip_multiarch != true
50
- uses : docker/setup-qemu-action@v3
51
- with :
52
- platforms : arm64
44
+ - name : Set up QEMU (only for multi-arch builds)
45
+ if : inputs.skip_multiarch != true
46
+ uses : docker/setup-qemu-action@v3
47
+ with :
48
+ platforms : arm64
53
49
54
- - name : Log in to GitHub Container Registry
55
- uses : docker/login-action@v3
56
- with :
57
- registry : ghcr.io
58
- username : ${{ github.actor }}
59
- password : ${{ secrets.GITHUB_TOKEN }}
50
+ - name : Log in to GitHub Container Registry
51
+ uses : docker/login-action@v3
52
+ with :
53
+ registry : ghcr.io
54
+ username : ${{ github.actor }}
55
+ password : ${{ secrets.GITHUB_TOKEN }}
60
56
61
- - name : Generate date tag for nightly builds
62
- id : date
63
- if : inputs.is_nightly == true
64
- run : echo "date_tag=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
57
+ - name : Generate date tag for nightly builds
58
+ id : date
59
+ if : inputs.is_nightly == true
60
+ run : echo "date_tag=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
65
61
66
- - name : Set lowercase repository owner
67
- run : echo "REPOSITORY_OWNER_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
62
+ - name : Set lowercase repository owner
63
+ run : echo "REPOSITORY_OWNER_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
68
64
69
- # Rust build cache for extproc
70
- - name : Cache Rust dependencies (extproc only)
71
- if : matrix.image == 'extproc'
72
- uses : actions/cache@v4
73
- with :
74
- path : |
75
- ~/.cargo/bin/
76
- ~/.cargo/registry/index/
77
- ~/.cargo/registry/cache/
78
- ~/.cargo/git/db/
79
- candle-binding/target/
80
- key : ${{ runner.os }}-cargo-extproc-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
81
- restore-keys : |
82
- ${{ runner.os }}-cargo-extproc-
65
+ # Rust build cache for extproc - only use GitHub Actions cache for non-PR builds
66
+ - name : Cache Rust dependencies (extproc only)
67
+ if : matrix.image == 'extproc' && github.event_name != 'pull_request '
68
+ uses : actions/cache@v4
69
+ with :
70
+ path : |
71
+ ~/.cargo/bin/
72
+ ~/.cargo/registry/index/
73
+ ~/.cargo/registry/cache/
74
+ ~/.cargo/git/db/
75
+ candle-binding/target/
76
+ key : ${{ runner.os }}-cargo-extproc-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
77
+ restore-keys : |
78
+ ${{ runner.os }}-cargo-extproc-
83
79
84
- # Set build context and dockerfile based on matrix
85
- - name : Set build parameters
86
- id : build-params
87
- run : |
88
- if [ "${{ matrix.image }}" = "extproc" ]; then
89
- echo "context=." >> $GITHUB_OUTPUT
90
- echo "dockerfile=./Dockerfile.extproc" >> $GITHUB_OUTPUT
91
- echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
92
- elif [ "${{ matrix.image }}" = "llm-katan" ]; then
93
- echo "context=./e2e-tests/llm-katan" >> $GITHUB_OUTPUT
94
- echo "dockerfile=./e2e-tests/llm-katan/Dockerfile" >> $GITHUB_OUTPUT
95
- echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
96
- fi
80
+ # Set build context and dockerfile based on matrix
81
+ - name : Set build parameters
82
+ id : build-params
83
+ run : |
84
+ if [ "${{ matrix.image }}" = "extproc" ]; then
85
+ echo "context=." >> $GITHUB_OUTPUT
86
+ echo "dockerfile=./Dockerfile.extproc" >> $GITHUB_OUTPUT
87
+ echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
88
+ elif [ "${{ matrix.image }}" = "llm-katan" ]; then
89
+ echo "context=./e2e-tests/llm-katan" >> $GITHUB_OUTPUT
90
+ echo "dockerfile=./e2e-tests/llm-katan/Dockerfile" >> $GITHUB_OUTPUT
91
+ echo "platforms=${{ inputs.skip_multiarch == true && 'linux/amd64' || 'linux/amd64,linux/arm64' }}" >> $GITHUB_OUTPUT
92
+ fi
97
93
98
- # Extract version for llm-katan
99
- - name : Extract version from pyproject.toml
100
- id : version
101
- if : matrix.image == 'llm-katan'
102
- run : |
103
- VERSION=$(grep '^version = ' e2e-tests/llm-katan/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
104
- echo "version=$VERSION" >> $GITHUB_OUTPUT
94
+ # Extract version for llm-katan
95
+ - name : Extract version from pyproject.toml
96
+ id : version
97
+ if : matrix.image == 'llm-katan'
98
+ run : |
99
+ VERSION=$(grep '^version = ' e2e-tests/llm-katan/pyproject.toml | sed 's/version = "\(.*\)"/\1/')
100
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
105
101
106
- # Generate tags for extproc
107
- - name : Generate extproc tags
108
- id : extproc-tags
109
- if : matrix.image == 'extproc'
110
- run : |
111
- REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
112
- if [ "${{ inputs.is_nightly }}" = "true" ]; then
113
- echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
114
- else
115
- if [ "${{ github.event_name }}" != "pull_request" ]; then
116
- echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/extproc:latest" >> $GITHUB_OUTPUT
102
+ # Generate tags for extproc
103
+ - name : Generate extproc tags
104
+ id : extproc-tags
105
+ if : matrix.image == 'extproc'
106
+ run : |
107
+ REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
108
+ if [ "${{ inputs.is_nightly }}" = "true" ]; then
109
+ echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
117
110
else
118
- echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }}" >> $GITHUB_OUTPUT
111
+ if [ "${{ github.event_name }}" != "pull_request" ]; then
112
+ echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/extproc:latest" >> $GITHUB_OUTPUT
113
+ else
114
+ echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/extproc:${{ github.sha }}" >> $GITHUB_OUTPUT
115
+ fi
119
116
fi
120
- fi
121
117
122
- # Generate tags for llm-katan
123
- - name : Generate llm-katan tags
124
- id : llm-katan-tags
125
- if : matrix.image == 'llm-katan'
126
- run : |
127
- REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
128
- if [ "${{ inputs.is_nightly }}" = "true" ]; then
129
- echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
130
- else
131
- if [ "${{ github.event_name }}" != "pull_request" ]; then
132
- echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:latest,ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
118
+ # Generate tags for llm-katan
119
+ - name : Generate llm-katan tags
120
+ id : llm-katan-tags
121
+ if : matrix.image == 'llm-katan'
122
+ run : |
123
+ REPO_LOWER=$(echo $GITHUB_REPOSITORY_OWNER | tr '[:upper:]' '[:lower:]')
124
+ if [ "${{ inputs.is_nightly }}" = "true" ]; then
125
+ echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:nightly-${{ steps.date.outputs.date_tag }}" >> $GITHUB_OUTPUT
133
126
else
134
- echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }}" >> $GITHUB_OUTPUT
127
+ if [ "${{ github.event_name }}" != "pull_request" ]; then
128
+ echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }},ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:latest,ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT
129
+ else
130
+ echo "tags=ghcr.io/${REPO_LOWER}/semantic-router/llm-katan:${{ github.sha }}" >> $GITHUB_OUTPUT
131
+ fi
135
132
fi
136
- fi
137
133
138
- - name : Build and push ${{ matrix.image }} Docker image
139
- uses : docker/build-push-action@v5
140
- with :
141
- context : ${{ steps.build-params.outputs.context }}
142
- file : ${{ steps.build-params.outputs.dockerfile }}
143
- platforms : ${{ steps.build-params.outputs.platforms }}
144
- push : ${{ github.event_name != 'pull_request' }}
145
- cache-from : type=gha,scope=${{ matrix.image }}
146
- cache-to : type=gha,mode=max,scope=${{ matrix.image }}
147
- tags : ${{ matrix.image == 'extproc' && steps.extproc-tags.outputs.tags || steps.llm-katan-tags.outputs.tags }}
148
- build-args : |
149
- BUILDKIT_INLINE_CACHE=1
134
+ - name : Build and push ${{ matrix.image }} Docker image
135
+ uses : docker/build-push-action@v5
136
+ with :
137
+ context : ${{ steps.build-params.outputs.context }}
138
+ file : ${{ steps.build-params.outputs.dockerfile }}
139
+ platforms : ${{ steps.build-params.outputs.platforms }}
140
+ push : ${{ github.event_name != 'pull_request' }}
141
+ load : ${{ github.event_name == 'pull_request' }}
142
+ tags : ${{ matrix.image == 'extproc' && steps.extproc-tags.outputs.tags || steps.llm-katan-tags.outputs.tags }}
143
+ build-args : |
144
+ BUILDKIT_INLINE_CACHE=1
0 commit comments