Skip to content

Commit 6f6cebf

Browse files
make+scripts: add lndsigner to release script
Update the release script to include the `lndsigner` binary in the release. Each environment will have its own zipped folder containing `lndsigner` and an `lncli` binary built with fewer build tags, limiting the available RPCs.
1 parent 395956b commit 6f6cebf

File tree

2 files changed

+51
-28
lines changed

2 files changed

+51
-28
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ release-install:
163163
# Make sure the generated mobile RPC stubs don't influence our vendor package
164164
# by removing them first in the clean-mobile target.
165165
release: clean-mobile
166-
@$(call print, "Releasing lnd and lncli binaries.")
166+
@$(call print, "Releasing lnd/lndsigner and lncli binaries.")
167167
$(VERSION_CHECK)
168-
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)"
168+
./scripts/release.sh build-release "$(VERSION_TAG)" "$(BUILD_SYSTEM)" "$(RELEASE_TAGS)" "$(LND_SIGNER_TAGS)" "$(RELEASE_LDFLAGS)" "$(GO_VERSION)"
169169

170170
#? docker-release: Same as release but within a docker container to support reproducible builds on BSD/MacOS platforms
171171
docker-release:

scripts/release.sh

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ set -e
1111

1212
LND_VERSION_REGEX="lnd version (.+) commit"
1313
PKG="github.com/lightningnetwork/lnd"
14-
PACKAGE=lnd
14+
LND_PACKAGE=lnd
15+
SIGNER_PACKAGE=lndsigner
1516

1617
# Needed for setting file timestamps to get reproducible archives.
1718
BUILD_DATE="2020-01-01 00:00:00"
@@ -127,15 +128,50 @@ function check_tag_correct() {
127128
fi
128129
}
129130

131+
# build_package builds release binaries for the passed package and lncli, for
132+
# the passed environment.
133+
# arguments: <package-name> <iteration-index> <tag> <os> <arch> <arm>
134+
# <build-tags> <ldflags>
135+
function build_package() {
136+
local package_name=$1
137+
local index=$2
138+
local tag=$3
139+
local os=$4
140+
local arch=$5
141+
local arm=$6
142+
local build_tags=$7
143+
local ldflags=$8
144+
145+
dir="${package_name}-${index}-${tag}"
146+
mkdir "${dir}"
147+
pushd "${dir}"
148+
149+
green " - Building ${package_name}: ${os} ${arch} ${arm} with build tags '${build_tags}'"
150+
env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${build_tags}" ${PKG}/cmd/${package_name}
151+
env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${build_tags}" ${PKG}/cmd/lncli
152+
popd
153+
154+
# Add the hashes for the individual binaries as well for easy verification
155+
# of a single installed binary.
156+
shasum -a 256 "${dir}/"* >> "manifest-$tag.txt"
157+
158+
if [[ $os == "windows" ]]; then
159+
reproducible_zip "${dir}"
160+
else
161+
reproducible_tar_gzip "${dir}"
162+
fi
163+
}
164+
130165
# build_release builds the actual release binaries.
131-
# arguments: <version-tag> <build-system(s)> <build-tags> <ldflags>
132-
# <go-version>
166+
# arguments: <version-tag> <build-system(s)> <lnd-build-tags>
167+
# <lndsigner-build-tags> <ldflags> <go-version>
133168
function build_release() {
134169
local tag=$1
135170
local sys=$2
136-
local buildtags=$3
137-
local ldflags=$4
138-
local goversion=$5
171+
local lndbuildtags=$3
172+
local signerbuildtags=$4
173+
local ldflags=$5
174+
local goversion=$6
139175

140176
# Check if the active Go version matches the specified Go version.
141177
active_go_version=$(go version | awk '{print $3}' | sed 's/go//')
@@ -151,13 +187,13 @@ required Go version ($goversion)."
151187
go mod vendor
152188
reproducible_tar_gzip vendor
153189

154-
maindir=$PACKAGE-$tag
190+
maindir=$LND_PACKAGE-$tag
155191
mkdir -p $maindir
156192
mv vendor.tar.gz "${maindir}/"
157193

158194
# Don't use tag in source directory, otherwise our file names get too long and
159195
# tar starts to package them non-deterministically.
160-
package_source="${PACKAGE}-source"
196+
package_source="${LND_PACKAGE}-source"
161197

162198
# The git archive command doesn't support setting timestamps and file
163199
# permissions. That's why we unpack the tar again, then use our reproducible
@@ -184,28 +220,15 @@ required Go version ($goversion)."
184220
arm=7
185221
fi
186222

187-
dir="${PACKAGE}-${i}-${tag}"
188-
mkdir "${dir}"
189-
pushd "${dir}"
223+
# Build lnd package
224+
build_package "${LND_PACKAGE}" "${i}" "${tag}" "${os}" "${arch}" "${arm}" "${lndbuildtags}" "${ldflags}"
190225

191-
green " - Building: ${os} ${arch} ${arm} with build tags '${buildtags}'"
192-
env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lnd
193-
env GOEXPERIMENT=loopvar CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lncli
194-
popd
195-
196-
# Add the hashes for the individual binaries as well for easy verification
197-
# of a single installed binary.
198-
shasum -a 256 "${dir}/"* >> "manifest-$tag.txt"
199-
200-
if [[ $os == "windows" ]]; then
201-
reproducible_zip "${dir}"
202-
else
203-
reproducible_tar_gzip "${dir}"
204-
fi
226+
# Build lndsigner package
227+
build_package "${SIGNER_PACKAGE}" "${i}" "${tag}" "${os}" "${arch}" "${arm}" "${signerbuildtags}" "${ldflags}"
205228
done
206229

207230
# Add the hash of the packages too, then sort by the second column (name).
208-
shasum -a 256 lnd-* vendor* >> "manifest-$tag.txt"
231+
shasum -a 256 "${LND_PACKAGE}"-* "${SIGNER_PACKAGE}"-* vendor* >> "manifest-$tag.txt"
209232
LC_ALL=C sort -k2 -o "manifest-$tag.txt" "manifest-$tag.txt"
210233
cat "manifest-$tag.txt"
211234
}

0 commit comments

Comments
 (0)