Skip to content

Commit bba4dbb

Browse files
authored
CI fixes (#82)
Signed-off-by: Joseph <jvaikath@redhat.com>
1 parent 326b3f8 commit bba4dbb

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

.github/workflows/cross-arch-build-test.yml

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
build-all:
1313
name: Build All Architectures
1414
runs-on: ubuntu-latest
15+
outputs:
16+
suffix: ${{ steps.version.outputs.suffix }}
1517

1618
steps:
1719
- name: Checkout code
@@ -29,11 +31,24 @@ jobs:
2931
go clean -cache -modcache -i -r || true
3032
echo "Go environment cleaned"
3133
34+
- name: Determine version
35+
id: version
36+
run: |
37+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
38+
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
39+
echo "suffix=${{ github.ref_name }}_" >> $GITHUB_OUTPUT
40+
echo "Building with version: ${{ github.ref_name }}"
41+
else
42+
echo "version=" >> $GITHUB_OUTPUT
43+
echo "suffix=" >> $GITHUB_OUTPUT
44+
echo "Building without version (non-tag build)"
45+
fi
46+
3247
- name: Build all architectures using make
3348
run: |
3449
set -e
3550
echo "Building all architectures..."
36-
if ! make release-build; then
51+
if ! make release-build VERSION="${{ steps.version.outputs.version }}"; then
3752
echo "❌ Build failed"
3853
exit 1
3954
fi
@@ -56,24 +71,24 @@ jobs:
5671
with:
5772
name: linux-binaries
5873
path: |
59-
kubectl-oadp_${{ github.ref_name }}_linux_amd64
60-
kubectl-oadp_${{ github.ref_name }}_linux_arm64
74+
kubectl-oadp_${{ steps.version.outputs.suffix }}linux_amd64
75+
kubectl-oadp_${{ steps.version.outputs.suffix }}linux_arm64
6176
6277
- name: Upload macOS binaries
6378
uses: actions/upload-artifact@v4
6479
with:
6580
name: macos-binaries
6681
path: |
67-
kubectl-oadp_${{ github.ref_name }}_darwin_amd64
68-
kubectl-oadp_${{ github.ref_name }}_darwin_arm64
82+
kubectl-oadp_${{ steps.version.outputs.suffix }}darwin_amd64
83+
kubectl-oadp_${{ steps.version.outputs.suffix }}darwin_arm64
6984
7085
- name: Upload Windows binaries
7186
uses: actions/upload-artifact@v4
7287
with:
7388
name: windows-binaries
7489
path: |
75-
kubectl-oadp_${{ github.ref_name }}_windows_amd64.exe
76-
kubectl-oadp_${{ github.ref_name }}_windows_arm64.exe
90+
kubectl-oadp_${{ steps.version.outputs.suffix }}windows_amd64.exe
91+
kubectl-oadp_${{ steps.version.outputs.suffix }}windows_arm64.exe
7792
7893
- name: Run host tests
7994
run: |
@@ -95,10 +110,10 @@ jobs:
95110
include:
96111
- os: ubuntu-latest
97112
arch: amd64
98-
binary: kubectl-oadp_${{ github.ref_name }}_linux_amd64
113+
binary: kubectl-oadp_${{ needs.build-all.outputs.suffix }}linux_amd64
99114
- os: ubuntu-24.04-arm
100115
arch: arm64
101-
binary: kubectl-oadp_${{ github.ref_name }}_linux_arm64
116+
binary: kubectl-oadp_${{ needs.build-all.outputs.suffix }}linux_arm64
102117

103118
runs-on: ${{ matrix.os }}
104119

@@ -202,10 +217,10 @@ jobs:
202217
include:
203218
- os: macos-13 # Intel
204219
arch: amd64
205-
binary: kubectl-oadp_${{ github.ref_name }}_darwin_amd64
220+
binary: kubectl-oadp_${{ needs.build-all.outputs.suffix }}darwin_amd64
206221
- os: macos-latest # Apple Silicon
207222
arch: arm64
208-
binary: kubectl-oadp_${{ github.ref_name }}_darwin_arm64
223+
binary: kubectl-oadp_${{ needs.build-all.outputs.suffix }}darwin_arm64
209224

210225
runs-on: ${{ matrix.os }}
211226

@@ -309,10 +324,10 @@ jobs:
309324
include:
310325
- os: windows-latest # amd64
311326
arch: amd64
312-
binary: kubectl-oadp_${{ github.ref_name }}_windows_amd64.exe
327+
binary: kubectl-oadp_${{ needs.build-all.outputs.suffix }}windows_amd64.exe
313328
- os: windows-11-arm # arm64
314329
arch: arm64
315-
binary: kubectl-oadp_${{ github.ref_name }}_windows_arm64.exe
330+
binary: kubectl-oadp_${{ needs.build-all.outputs.suffix }}windows_arm64.exe
316331

317332
runs-on: ${{ matrix.os }}
318333

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,13 @@ release-build: ## Build binaries for all platforms
386386
fi; \
387387
echo "Building for $$GOOS/$$GOARCH..."; \
388388
GOOS=$$GOOS GOARCH=$$GOARCH go build -o $$binary_name .; \
389-
echo "✅ Built $$binary_name for $$GOOS/$$GOARCH"; \
390-
mv $$binary_name $(BINARY_NAME)_${VERSION}_$$GOOS_$$GOARCH$${binary_name#$(BINARY_NAME)}; \
389+
if [ -n "$(VERSION)" ]; then \
390+
final_name="$(BINARY_NAME)_$(VERSION)_$${GOOS}_$${GOARCH}$${binary_name#$(BINARY_NAME)}"; \
391+
else \
392+
final_name="$(BINARY_NAME)_$${GOOS}_$${GOARCH}$${binary_name#$(BINARY_NAME)}"; \
393+
fi; \
394+
mv $$binary_name $$final_name; \
395+
echo "✅ Built $$final_name for $$GOOS/$$GOARCH"; \
391396
done
392397
@echo "✅ All release binaries built successfully!"
393398

@@ -408,7 +413,7 @@ release-archives: release-build ## Create tar.gz archives for all platforms (inc
408413
fi; \
409414
archive_name="$(BINARY_NAME)_${VERSION}_$$GOOS_$$GOARCH.tar.gz"; \
410415
echo "Creating $$archive_name..."; \
411-
tar czf $$archive_name LICENSE $(BINARY_NAME)_${VERSION}_$$GOOS_$$GOARCH$${binary_name#$(BINARY_NAME)}; \
416+
tar czf $$archive_name LICENSE $(BINARY_NAME)_${VERSION}_$${GOOS}_$${GOARCH}$${binary_name#$(BINARY_NAME)}; \
412417
sha256sum $$archive_name > $$archive_name.sha256; \
413418
echo "✅ Created $$archive_name with LICENSE"; \
414419
done

0 commit comments

Comments
 (0)