Skip to content

Commit f959b6c

Browse files
Add release artifact signing to build script.
1 parent 908beea commit f959b6c

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

Rakefile

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,40 @@ namespace 'release' do
4646
SUPPORTED.each do |os, arch|
4747
output_dir = "#{OUTDIR}/#{os}_#{arch}"
4848
build_for_platform(os, arch, out: "#{output_dir}/#{PROGNAME}")
49-
sh "tar czf #{OUTDIR}/#{os}_#{arch}.tar.gz -C #{OUTDIR} #{os}_#{arch}"
49+
50+
version = get_version
51+
sh "tar czf #{OUTDIR}/gitwho_#{version}_#{os}_#{arch}.tar.gz "\
52+
"-C #{OUTDIR} #{os}_#{arch}"
5053
end
5154
end
55+
56+
desc 'Sign checksum of built artifacts'
57+
task :sign do
58+
FileUtils.cd(OUTDIR) do
59+
version = get_version
60+
sumsfile = "SHA2-256SUMS_#{version}.txt"
61+
sh "shasum -a 256 **/git-who > #{sumsfile}"
62+
sh "ssh-keygen -Y sign -n file -f ~/.ssh/gitwho_ed25519 #{sumsfile}"
63+
end
64+
end
65+
66+
task all: [:build, :sign]
5267
end
5368

5469
CLOBBER.include(OUTDIR)
5570
CLOBBER.include(PROGNAME)
5671

72+
def get_version()
73+
`git describe --tags --always --dirty`.strip
74+
end
75+
76+
def get_commit()
77+
`git rev-parse --short HEAD`.strip
78+
end
79+
5780
def build_for_platform(goos, goarch, out: PROGNAME)
58-
rev = `git rev-parse --short HEAD`.strip
59-
version = `git describe --tags --always --dirty`.strip
81+
version = get_version
82+
rev = get_commit
6083
sh "GOOS=#{goos} GOARCH=#{goarch} go build -a -o #{out} "\
6184
"-ldflags '-s -w -X main.Commit=#{rev} -X main.Version=#{version}'"
6285
end

0 commit comments

Comments
 (0)