Skip to content

Commit 3494cbb

Browse files
committed
refinements and addressing feedback
1 parent 78481a4 commit 3494cbb

File tree

5 files changed

+54
-81
lines changed

5 files changed

+54
-81
lines changed

.github/workflows/checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ jobs:
6464
run: go install mvdan.cc/[email protected]
6565

6666
- name: Install staticcheck
67-
run: go install honnef.co/go/tools/cmd/staticcheck@latest
67+
run: go install honnef.co/go/tools/cmd/staticcheck@v0.6.1
6868

6969
- name: Install golangci-lint
70-
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
70+
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
7171

7272
# - name: Install NilAway
7373
# run: go install go.uber.org/nilaway/cmd/[email protected]

.github/workflows/release.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ on:
44
push:
55
tags:
66
- 'v*'
7-
workflow_dispatch:
8-
inputs:
9-
snapshot:
10-
description: 'Create snapshot release'
11-
required: false
12-
default: false
13-
type: boolean
147

158
permissions:
169
contents: write

.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ release:
206206
mode: append
207207

208208
# Create release draft
209-
draft: false
209+
draft: true
210210

211211
# Mark as prerelease if version contains prerelease identifiers
212212
prerelease: auto

Makefile

Lines changed: 2 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -115,77 +115,8 @@ package-local: ## Build packages locally for testing
115115

116116
.PHONY: package-test-reproducible
117117
package-test-reproducible: ## Test reproducible builds
118-
@echo "🔄 Testing reproducible builds..."
119-
@mkdir -p ./test-reproducible
120-
@echo " Building first version (with packages)..."
121-
@if goreleaser release --snapshot --clean >/dev/null 2>&1; then \
122-
echo " ✅ First build completed"; \
123-
cp -r ./dist ./test-reproducible/build1; \
124-
else \
125-
echo "❌ First build failed"; \
126-
echo "Running with verbose output:"; \
127-
goreleaser release --snapshot --clean; \
128-
rm -rf ./test-reproducible; \
129-
exit 1; \
130-
fi
131-
@sleep 2
132-
@echo " Building second version (with packages)..."
133-
@if goreleaser release --snapshot --clean >/dev/null 2>&1; then \
134-
echo " ✅ Second build completed"; \
135-
cp -r ./dist ./test-reproducible/build2; \
136-
else \
137-
echo "❌ Second build failed"; \
138-
echo "Running with verbose output:"; \
139-
goreleaser release --snapshot --clean; \
140-
rm -rf ./test-reproducible; \
141-
exit 1; \
142-
fi
143-
@echo " Comparing packages and binaries..."
144-
@BUILD1_DEBS=$$(find ./test-reproducible/build1 -name "*.deb" | wc -l); \
145-
BUILD2_DEBS=$$(find ./test-reproducible/build2 -name "*.deb" | wc -l); \
146-
BUILD1_BINS=$$(find ./test-reproducible/build1 -type f -name "go-template-*" | wc -l); \
147-
BUILD2_BINS=$$(find ./test-reproducible/build2 -type f -name "go-template-*" | wc -l); \
148-
echo " Found $$BUILD1_DEBS .deb packages and $$BUILD1_BINS binaries in first build"; \
149-
echo " Found $$BUILD2_DEBS .deb packages and $$BUILD2_BINS binaries in second build"; \
150-
if [ "$$BUILD1_DEBS" -eq 0 ] && [ "$$BUILD1_BINS" -eq 0 ]; then \
151-
echo "❌ No build artifacts found in first build"; \
152-
find ./test-reproducible/build1 -type f | head -10; \
153-
rm -rf ./test-reproducible; \
154-
exit 1; \
155-
fi
156-
@echo " Comparing binary checksums..."
157-
@find ./test-reproducible/build1 -type f -name "go-template-*" -exec sha256sum {} \; | sed 's|./test-reproducible/build1/||' | sort > ./test-reproducible/checksums1_bins.txt
158-
@find ./test-reproducible/build2 -type f -name "go-template-*" -exec sha256sum {} \; | sed 's|./test-reproducible/build2/||' | sort > ./test-reproducible/checksums2_bins.txt
159-
@echo " Comparing package checksums..."
160-
@find ./test-reproducible/build1 -name "*.deb" -exec sha256sum {} \; | sed 's|./test-reproducible/build1/||' | sort > ./test-reproducible/checksums1_debs.txt
161-
@find ./test-reproducible/build2 -name "*.deb" -exec sha256sum {} \; | sed 's|./test-reproducible/build2/||' | sort > ./test-reproducible/checksums2_debs.txt
162-
@if diff ./test-reproducible/checksums1_bins.txt ./test-reproducible/checksums2_bins.txt >/dev/null 2>&1; then \
163-
BINS_MATCH=true; \
164-
else \
165-
BINS_MATCH=false; \
166-
fi; \
167-
if diff ./test-reproducible/checksums1_debs.txt ./test-reproducible/checksums2_debs.txt >/dev/null 2>&1; then \
168-
DEBS_MATCH=true; \
169-
else \
170-
DEBS_MATCH=false; \
171-
fi; \
172-
if [ "$$BINS_MATCH" = "true" ] && [ "$$DEBS_MATCH" = "true" ]; then \
173-
echo "✅ Both binaries and packages are reproducible!"; \
174-
else \
175-
echo "❌ Builds are NOT reproducible!"; \
176-
if [ "$$BINS_MATCH" = "false" ]; then \
177-
echo "Binary differences:"; \
178-
diff ./test-reproducible/checksums1_bins.txt ./test-reproducible/checksums2_bins.txt || true; \
179-
fi; \
180-
if [ "$$DEBS_MATCH" = "false" ]; then \
181-
echo "Package differences:"; \
182-
diff ./test-reproducible/checksums1_debs.txt ./test-reproducible/checksums2_debs.txt || true; \
183-
fi; \
184-
rm -rf ./test-reproducible; \
185-
exit 1; \
186-
fi
187-
@rm -rf ./test-reproducible
188-
@echo "🎉 Reproducibility test passed"
118+
@chmod +x scripts/test-reproducible.sh
119+
@./scripts/test-reproducible.sh
189120

190121
.PHONY: package-install-local
191122
package-install-local: package-local ## Install locally built package

scripts/test-reproducible.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🔄 Testing reproducible builds..."
5+
6+
# Create test directory
7+
mkdir -p ./test-reproducible
8+
9+
# Build first version
10+
echo " Building first version..."
11+
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) goreleaser release --snapshot --clean >/dev/null 2>&1 || {
12+
echo "❌ First build failed"
13+
goreleaser release --snapshot --clean
14+
rm -rf ./test-reproducible
15+
exit 1
16+
}
17+
cp -r ./dist ./test-reproducible/build1
18+
19+
# Wait to ensure different build times
20+
sleep 2
21+
22+
# Build second version
23+
echo " Building second version..."
24+
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct) goreleaser release --snapshot --clean >/dev/null 2>&1 || {
25+
echo "❌ Second build failed"
26+
goreleaser release --snapshot --clean
27+
rm -rf ./test-reproducible
28+
exit 1
29+
}
30+
cp -r ./dist ./test-reproducible/build2
31+
32+
# Compare builds
33+
echo " Comparing builds..."
34+
find ./test-reproducible/build1 -name "*.deb" -exec sha256sum {} \; | sed 's|./test-reproducible/build1/||' | sort > ./test-reproducible/checksums1.txt
35+
find ./test-reproducible/build2 -name "*.deb" -exec sha256sum {} \; | sed 's|./test-reproducible/build2/||' | sort > ./test-reproducible/checksums2.txt
36+
37+
if diff ./test-reproducible/checksums1.txt ./test-reproducible/checksums2.txt >/dev/null 2>&1; then
38+
echo "✅ Builds are reproducible!"
39+
else
40+
echo "❌ Builds are NOT reproducible!"
41+
echo "Differences:"
42+
diff ./test-reproducible/checksums1.txt ./test-reproducible/checksums2.txt || true
43+
rm -rf ./test-reproducible
44+
exit 1
45+
fi
46+
47+
# Cleanup
48+
rm -rf ./test-reproducible
49+
echo "🎉 Reproducibility test passed"

0 commit comments

Comments
 (0)