Skip to content

Commit 2e8da2c

Browse files
authored
Release flow (#26)
* Add release workflow for automated GitHub releases - Triggers on version tags (v*) - Builds all 6 architectures using existing make release-build - Creates proper tar.gz archives with LICENSE - Generates SHA256 checksums - Creates GitHub release with all artifacts * Fix Go cache issues in release workflow - Disable Go cache to avoid tar restoration conflicts - Add explicit cache cleaning for fresh builds - Download and verify dependencies explicitly - Ensures clean build environment for releases * Add automated krew manifest generation with Python - Generate final kubectl-oadp.yaml with real SHA256 checksums - Use Python for readable and maintainable string processing - Include final manifest as release artifact - Update release notes with installation instructions - Ready for krew index submission automation * Convert oadp.yaml to proper template for automation - Use v0.0.0 as template version placeholder - All URLs now use consistent template version - Add missing windows-arm64 platform (matches workflow builds) - Ready for Python automation to populate real versions and SHA256s * Implement better templating with envsubst ✨ Major improvements: - Convert oadp.yaml to environment variable template - Replace complex Python regex with clean envsubst - Much more readable and maintainable approach - Robust error handling and validation - Template uses ${VERSION}, ${LINUX_AMD64_SHA}, etc. 🔧 Technical benefits: - No more fragile regex string replacement - Standard environment variable substitution - Easier to debug and modify - Less code, more reliable * Simplify krew manifest naming to oadp.yaml 🎯 Perfect for krew index submission: - Generate oadp.yaml directly (not oadp-final.yaml) - Release artifact is ready to drop into krew index - No renaming needed - matches krew convention exactly - Clean workflow: template → envsubst → oadp.yaml * Fix archive creation for krew platform matching 🐛 Fixes checksum validation errors: - Only create archives for the 6 krew platforms (not ppc64le/s390x) - Fix Windows naming: .exe binary → .tar.gz archive (no .exe in archive name) - Skip non-binary files (kubectl-oadp-design.md) - Explicit platform list ensures exact match with oadp.yaml - Better error handling if binaries missing ✅ Now checksums.txt will have exactly the files the workflow expects * Fix GitHub Actions cache restoration warnings 🐛 Resolves tar exit code 2 failures across all workflows: - Disable Go cache in cross-arch build job (cache: false) - Disable Go cache in all test jobs (Linux/macOS/Windows) - Add cache cleaning step for build job - Prevents tar conflicts during cache restoration ✅ No more 'Failed to restore' warnings in CI logs 🚀 More reliable builds across all architectures * Add ppc64le and s390x architecture support 🚀 Expand platform coverage for enterprise environments: - Add linux-ppc64le platform to krew manifest - Add linux-s390x platform to krew manifest - Update release workflow to build and package new architectures - Add environment variable extraction for new platform checksums - Update release notes to reflect 8 total platforms ✅ Now supports: - Linux: amd64, arm64, ppc64le, s390x - macOS: amd64, arm64 - Windows: amd64, arm64 🎯 Enables OADP CLI installation on IBM Power and mainframe systems
1 parent b39f4af commit 2e8da2c

File tree

3 files changed

+257
-16
lines changed

3 files changed

+257
-16
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ jobs:
2121
uses: actions/setup-go@v5
2222
with:
2323
go-version-file: 'go.mod'
24-
cache: true
24+
cache: false
25+
26+
- name: Clean Go environment
27+
run: |
28+
echo "Cleaning Go environment for reliable build..."
29+
go clean -cache -modcache -i -r || true
30+
echo "Go environment cleaned"
2531
2632
- name: Build all architectures using make
2733
run: |
@@ -104,7 +110,7 @@ jobs:
104110
uses: actions/setup-go@v5
105111
with:
106112
go-version-file: 'go.mod'
107-
cache: true
113+
cache: false
108114

109115
- name: Download Linux binaries
110116
uses: actions/download-artifact@v4
@@ -211,7 +217,7 @@ jobs:
211217
uses: actions/setup-go@v5
212218
with:
213219
go-version-file: 'go.mod'
214-
cache: true
220+
cache: false
215221

216222
- name: Download macOS binaries
217223
uses: actions/download-artifact@v4
@@ -318,7 +324,7 @@ jobs:
318324
uses: actions/setup-go@v5
319325
with:
320326
go-version-file: 'go.mod'
321-
cache: true
327+
cache: false
322328

323329
- name: Download Windows binaries
324330
uses: actions/download-artifact@v4

.github/workflows/release.yml

Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
release:
10+
name: Create Release
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v5
19+
with:
20+
go-version-file: 'go.mod'
21+
cache: false
22+
23+
- name: Clean Go environment
24+
run: |
25+
echo "Cleaning Go environment for fresh build..."
26+
go clean -cache -modcache -i -r || true
27+
echo "Go environment cleaned"
28+
29+
- name: Download dependencies
30+
run: |
31+
echo "Downloading fresh dependencies..."
32+
go mod download
33+
go mod verify
34+
echo "Dependencies ready"
35+
36+
- name: Build all architectures
37+
run: |
38+
set -e
39+
echo "Building all architectures for release..."
40+
if ! make release-build; then
41+
echo "❌ Build failed"
42+
exit 1
43+
fi
44+
echo "✅ All builds completed"
45+
46+
- name: Create release archives
47+
run: |
48+
set -e
49+
echo "Creating release archives..."
50+
51+
# Define the platforms we want for krew (must match oadp.yaml)
52+
declare -a platforms=(
53+
"linux-amd64"
54+
"linux-arm64"
55+
"linux-ppc64le"
56+
"linux-s390x"
57+
"darwin-amd64"
58+
"darwin-arm64"
59+
"windows-amd64"
60+
"windows-arm64"
61+
)
62+
63+
# Create archives only for krew platforms
64+
for platform in "${platforms[@]}"; do
65+
if [[ "$platform" == *"windows"* ]]; then
66+
# Windows binaries have .exe extension
67+
binary="kubectl-oadp-${platform}.exe"
68+
if [[ -f "$binary" ]]; then
69+
echo "Creating archive for $platform..."
70+
cp "$binary" kubectl-oadp.exe
71+
tar -czf "kubectl-oadp-${platform}.tar.gz" kubectl-oadp.exe LICENSE
72+
rm kubectl-oadp.exe
73+
echo "✅ Created kubectl-oadp-${platform}.tar.gz"
74+
else
75+
echo "❌ Binary not found: $binary"
76+
exit 1
77+
fi
78+
else
79+
# Unix binaries (no extension)
80+
binary="kubectl-oadp-${platform}"
81+
if [[ -f "$binary" ]]; then
82+
echo "Creating archive for $platform..."
83+
cp "$binary" kubectl-oadp
84+
tar -czf "kubectl-oadp-${platform}.tar.gz" kubectl-oadp LICENSE
85+
rm kubectl-oadp
86+
echo "✅ Created kubectl-oadp-${platform}.tar.gz"
87+
else
88+
echo "❌ Binary not found: $binary"
89+
exit 1
90+
fi
91+
fi
92+
done
93+
94+
echo ""
95+
echo "Release archives created:"
96+
ls -la *.tar.gz
97+
98+
- name: Generate SHA256 checksums
99+
run: |
100+
set -e
101+
echo "Generating SHA256 checksums..."
102+
sha256sum *.tar.gz > checksums.txt
103+
echo ""
104+
echo "Checksums:"
105+
cat checksums.txt
106+
107+
- name: Generate final krew manifest
108+
run: |
109+
set -e
110+
echo "Generating final krew manifest with version ${{ github.ref_name }}..."
111+
112+
# Set environment variables for template substitution
113+
export VERSION="${{ github.ref_name }}"
114+
export LINUX_AMD64_SHA=$(grep "kubectl-oadp-linux-amd64.tar.gz" checksums.txt | cut -d' ' -f1)
115+
export LINUX_ARM64_SHA=$(grep "kubectl-oadp-linux-arm64.tar.gz" checksums.txt | cut -d' ' -f1)
116+
export LINUX_PPC64LE_SHA=$(grep "kubectl-oadp-linux-ppc64le.tar.gz" checksums.txt | cut -d' ' -f1)
117+
export LINUX_S390X_SHA=$(grep "kubectl-oadp-linux-s390x.tar.gz" checksums.txt | cut -d' ' -f1)
118+
export DARWIN_AMD64_SHA=$(grep "kubectl-oadp-darwin-amd64.tar.gz" checksums.txt | cut -d' ' -f1)
119+
export DARWIN_ARM64_SHA=$(grep "kubectl-oadp-darwin-arm64.tar.gz" checksums.txt | cut -d' ' -f1)
120+
export WINDOWS_AMD64_SHA=$(grep "kubectl-oadp-windows-amd64.tar.gz" checksums.txt | cut -d' ' -f1)
121+
export WINDOWS_ARM64_SHA=$(grep "kubectl-oadp-windows-arm64.tar.gz" checksums.txt | cut -d' ' -f1)
122+
123+
# Validate all checksums were found
124+
if [[ -z "$LINUX_AMD64_SHA" || -z "$LINUX_ARM64_SHA" || -z "$LINUX_PPC64LE_SHA" || -z "$LINUX_S390X_SHA" || -z "$DARWIN_AMD64_SHA" || -z "$DARWIN_ARM64_SHA" || -z "$WINDOWS_AMD64_SHA" || -z "$WINDOWS_ARM64_SHA" ]]; then
125+
echo "❌ Some checksums are missing!"
126+
echo "Available checksums:"
127+
cat checksums.txt
128+
exit 1
129+
fi
130+
131+
# Use envsubst to substitute environment variables in template
132+
# Save original template and generate final manifest
133+
cp oadp.yaml oadp-template.yaml
134+
envsubst < oadp-template.yaml > oadp.yaml
135+
136+
echo "✅ Final krew manifest generated successfully!"
137+
echo ""
138+
echo "Summary:"
139+
echo "Version: $VERSION"
140+
echo "Linux amd64: ${LINUX_AMD64_SHA:0:16}..."
141+
echo "Linux arm64: ${LINUX_ARM64_SHA:0:16}..."
142+
echo "Linux ppc64le: ${LINUX_PPC64LE_SHA:0:16}..."
143+
echo "Linux s390x: ${LINUX_S390X_SHA:0:16}..."
144+
echo "Darwin amd64: ${DARWIN_AMD64_SHA:0:16}..."
145+
echo "Darwin arm64: ${DARWIN_ARM64_SHA:0:16}..."
146+
echo "Windows amd64: ${WINDOWS_AMD64_SHA:0:16}..."
147+
echo "Windows arm64: ${WINDOWS_ARM64_SHA:0:16}..."
148+
149+
echo ""
150+
echo "Final manifest preview:"
151+
grep -E "(version:|sha256:)" oadp.yaml
152+
153+
- name: Create GitHub Release
154+
uses: softprops/action-gh-release@v1
155+
with:
156+
files: |
157+
*.tar.gz
158+
checksums.txt
159+
oadp.yaml
160+
body: |
161+
## OADP CLI ${{ github.ref_name }}
162+
163+
Cross-platform kubectl plugin for managing OpenShift API for Data Protection (OADP) backup and restore operations.
164+
165+
### Installation
166+
167+
#### Via krew (recommended)
168+
```bash
169+
kubectl krew install oadp
170+
```
171+
172+
#### Via krew manifest (for testing or custom indexes)
173+
```bash
174+
curl -LO https://github.com/migtools/oadp-cli/releases/download/${{ github.ref_name }}/oadp.yaml
175+
kubectl krew install --manifest=oadp.yaml
176+
```
177+
178+
#### Manual installation
179+
1. Download the appropriate binary for your platform
180+
2. Extract the archive
181+
3. Add the binary to your PATH
182+
4. Verify installation: `kubectl oadp --help`
183+
184+
### Supported Platforms
185+
- Linux (amd64, arm64, ppc64le, s390x)
186+
- macOS (amd64, arm64)
187+
- Windows (amd64, arm64)
188+
189+
### Files Included
190+
- **Binary archives**: Platform-specific kubectl-oadp binaries with LICENSE
191+
- **checksums.txt**: SHA256 checksums for all binaries
192+
- **oadp.yaml**: Final krew plugin manifest with populated SHA256 values (ready for krew index)
193+
194+
### For Krew Index Maintainers
195+
The `oadp.yaml` file contains the complete krew plugin manifest with all SHA256 checksums populated and can be used directly for krew index submissions.
196+
draft: false
197+
prerelease: false
198+
env:
199+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

oadp.yaml

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Plugin
33
metadata:
44
name: oadp
55
spec:
6-
version: v1.0.0
6+
version: ${VERSION}
77
homepage: https://github.com/migtools/oadp-cli
88
shortDescription: Manage OpenShift API for Data Protection (OADP) backup and restore operations
99
description: |
@@ -32,8 +32,8 @@ spec:
3232
matchLabels:
3333
os: linux
3434
arch: amd64
35-
uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-linux-amd64.tar.gz
36-
sha256: ""
35+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-linux-amd64.tar.gz
36+
sha256: "${LINUX_AMD64_SHA}"
3737
files:
3838
- from: kubectl-oadp
3939
to: .
@@ -44,8 +44,32 @@ spec:
4444
matchLabels:
4545
os: linux
4646
arch: arm64
47-
uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-linux-arm64.tar.gz
48-
sha256: ""
47+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-linux-arm64.tar.gz
48+
sha256: "${LINUX_ARM64_SHA}"
49+
files:
50+
- from: kubectl-oadp
51+
to: .
52+
- from: LICENSE
53+
to: .
54+
bin: kubectl-oadp
55+
- selector:
56+
matchLabels:
57+
os: linux
58+
arch: ppc64le
59+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-linux-ppc64le.tar.gz
60+
sha256: "${LINUX_PPC64LE_SHA}"
61+
files:
62+
- from: kubectl-oadp
63+
to: .
64+
- from: LICENSE
65+
to: .
66+
bin: kubectl-oadp
67+
- selector:
68+
matchLabels:
69+
os: linux
70+
arch: s390x
71+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-linux-s390x.tar.gz
72+
sha256: "${LINUX_S390X_SHA}"
4973
files:
5074
- from: kubectl-oadp
5175
to: .
@@ -56,8 +80,8 @@ spec:
5680
matchLabels:
5781
os: darwin
5882
arch: amd64
59-
uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-darwin-amd64.tar.gz
60-
sha256: ""
83+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-darwin-amd64.tar.gz
84+
sha256: "${DARWIN_AMD64_SHA}"
6185
files:
6286
- from: kubectl-oadp
6387
to: .
@@ -68,8 +92,8 @@ spec:
6892
matchLabels:
6993
os: darwin
7094
arch: arm64
71-
uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-darwin-arm64.tar.gz
72-
sha256: ""
95+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-darwin-arm64.tar.gz
96+
sha256: "${DARWIN_ARM64_SHA}"
7397
files:
7498
- from: kubectl-oadp
7599
to: .
@@ -80,11 +104,23 @@ spec:
80104
matchLabels:
81105
os: windows
82106
arch: amd64
83-
uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-windows-amd64.tar.gz
84-
sha256: ""
107+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-windows-amd64.tar.gz
108+
sha256: "${WINDOWS_AMD64_SHA}"
109+
files:
110+
- from: kubectl-oadp.exe
111+
to: .
112+
- from: LICENSE
113+
to: .
114+
bin: kubectl-oadp.exe
115+
- selector:
116+
matchLabels:
117+
os: windows
118+
arch: arm64
119+
uri: https://github.com/migtools/oadp-cli/releases/download/${VERSION}/kubectl-oadp-windows-arm64.tar.gz
120+
sha256: "${WINDOWS_ARM64_SHA}"
85121
files:
86122
- from: kubectl-oadp.exe
87123
to: .
88124
- from: LICENSE
89125
to: .
90-
bin: kubectl-oadp.exe
126+
bin: kubectl-oadp.exe

0 commit comments

Comments
 (0)