1313 branches :
1414 - main # Trigger on pull requests to main branch
1515
16+ env :
17+ CARGO_TERM_COLOR : always
18+ CARGO_INCREMENTAL : 0
19+
1620jobs :
1721 # This job runs for all pushes and pull requests
1822 build-and-test :
@@ -40,15 +44,23 @@ jobs:
4044 - name : 📦 Rust cache
4145 uses : Swatinem/rust-cache@v2
4246 with :
43- # Let action generate cache keys automatically
44- workspaces : " . -> target "
47+ shared-key : " build-${{ matrix.target }} "
48+ save-if : ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
4549
4650 - name : 🔨 Build
4751 run : |
4852 echo "::group::Building Git-Iris (${{ matrix.build }})"
4953 ${{ matrix.cmd }} build --verbose --locked --target ${{ matrix.target }}
5054 echo "::endgroup::"
5155
56+ - name : 📤 Upload build artifacts
57+ uses : actions/upload-artifact@v4
58+ with :
59+ name : build-${{ matrix.build }}
60+ path : ./target/${{ matrix.target }}/debug
61+ if-no-files-found : error
62+ retention-days : 1
63+
5264 - name : 🧪 Run tests
5365 run : |
5466 echo "::group::Running tests (${{ matrix.build }})"
@@ -68,14 +80,20 @@ jobs:
6880 with :
6981 fetch-depth : 0
7082
83+ - name : 📥 Download build artifacts
84+ uses : actions/download-artifact@v4
85+ with :
86+ name : build-linux-amd64
87+ path : ./target/x86_64-unknown-linux-gnu/debug
88+
7189 - name : 🔍 Set up Docker Buildx
7290 uses : docker/setup-buildx-action@v3
7391
7492 - name : 🔨 Build Docker image
7593 working-directory : ./docker
7694 run : |
7795 echo "::group::Building Docker image"
78- ./build.sh $IMAGE_NAME
96+ CARGO_TARGET_DIR=../target ./build.sh $IMAGE_NAME
7997 echo "::endgroup::"
8098
8199 - name : 🧪 Test Docker image
@@ -116,6 +134,13 @@ jobs:
116134 with :
117135 fetch-depth : 0
118136
137+ - name : 📥 Download debug artifacts if available
138+ uses : actions/download-artifact@v4
139+ continue-on-error : true
140+ with :
141+ name : build-${{ matrix.build }}
142+ path : ./target/${{ matrix.target }}/debug
143+
119144 - name : 🦀 Install Rust
120145 uses : dtolnay/rust-toolchain@stable
121146 with :
@@ -124,17 +149,23 @@ jobs:
124149 - name : 📦 Rust cache
125150 uses : Swatinem/rust-cache@v2
126151 with :
127- # Let action generate cache keys automatically
128- workspaces : " . -> target/${{ matrix.target }}/release"
129- # Additional cache suffix for release builds
130- cache-on-failure : true
152+ shared-key : " release-${{ matrix.target }}"
153+ save-if : true
131154
132155 - name : 🔨 Build release binary
133156 run : |
134157 echo "::group::Building release binary (${{ matrix.build }})"
135158 cargo build --verbose --locked --release --target ${{ matrix.target }}
136159 echo "::endgroup::"
137160
161+ - name : 📤 Upload release artifacts
162+ uses : actions/upload-artifact@v4
163+ with :
164+ name : release-${{ matrix.build }}
165+ path : ./target/${{ matrix.target }}/release
166+ if-no-files-found : error
167+ retention-days : 1
168+
138169 - name : 📤 Upload artifact
139170 uses : actions/upload-artifact@v4
140171 with :
@@ -156,6 +187,12 @@ jobs:
156187 with :
157188 fetch-depth : 0
158189
190+ - name : 📥 Download build artifacts
191+ uses : actions/download-artifact@v4
192+ with :
193+ name : build-linux-amd64
194+ path : ./target/x86_64-unknown-linux-gnu/debug
195+
159196 - name : 🏷️ Get version
160197 id : get_version
161198 run : echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
@@ -168,9 +205,8 @@ jobs:
168205 - name : 📦 Rust cache
169206 uses : Swatinem/rust-cache@v2
170207 with :
171- # Let action generate cache keys automatically
172- workspaces : " ."
173- cache-on-failure : true
208+ shared-key : " packages-x86_64-unknown-linux-gnu"
209+ save-if : true
174210
175211 # Build DEB package
176212 - name : 📦 Install cargo-deb
@@ -235,6 +271,12 @@ jobs:
235271 with :
236272 fetch-depth : 0
237273
274+ - name : 📥 Download release artifacts
275+ uses : actions/download-artifact@v4
276+ with :
277+ name : release-linux-amd64
278+ path : ./target/x86_64-unknown-linux-gnu/release
279+
238280 - name : 🏷️ Get version
239281 id : get_version
240282 run : |
@@ -262,6 +304,8 @@ jobs:
262304 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get_version.outputs.VERSION }}
263305 cache-from : type=gha
264306 cache-to : type=gha,mode=max
307+ build-args : |
308+ CARGO_TARGET_DIR=./target
265309
266310 - name : 🎉 Docker image published
267311 run : |
@@ -281,11 +325,19 @@ jobs:
281325 with :
282326 fetch-depth : 0
283327
328+ - name : 📥 Download release artifacts
329+ uses : actions/download-artifact@v4
330+ with :
331+ name : release-linux-amd64
332+ path : ./target/x86_64-unknown-linux-gnu/release
333+
284334 - name : 🦀 Install Rust
285335 uses : dtolnay/rust-toolchain@stable
286336
287337 - name : 📦 Rust cache
288338 uses : Swatinem/rust-cache@v2
339+ with :
340+ shared-key : " publish"
289341
290342 - name : 🔑 Setup crates.io token
291343 run : cargo login ${{ secrets.CRATES_IO_TOKEN }}
@@ -331,15 +383,15 @@ jobs:
331383 run : |
332384 echo "::group::Generating release notes"
333385 if [ -n "$OPENAI_API_KEY" ]; then
334- # Build git-iris locally to generate release notes
335- cargo build --release
386+ # Use downloaded release binary to generate release notes
387+ chmod +x ./artifacts/git-iris-linux-amd64/git-iris
336388
337389 # Get previous tag
338390 PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
339391
340392 if [ -n "$PREVIOUS_TAG" ]; then
341393 # Generate release notes using git-iris
342- ./target/release /git-iris release-notes --from "$PREVIOUS_TAG" --to "$GITHUB_REF_NAME" --print > RELEASE_NOTES.md
394+ ./artifacts/git-iris-linux-amd64 /git-iris release-notes --from "$PREVIOUS_TAG" --to "$GITHUB_REF_NAME" --print > RELEASE_NOTES.md
343395 echo "✨ Generated release notes with git-iris"
344396 else
345397 echo "No previous tag found, using default release notes"
0 commit comments