From 2083acdd247338336bf1a1b644b53be2960131aa Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 10 Oct 2019 16:17:57 -0700 Subject: [PATCH] release: add new release script and documentation In this commit, we add the new release script that will be used to build all release binaries going forward. We also remove the existing Conformal key as it's no longer in use, updating the README to reflect the new release build/verification process. --- README.md | 25 ++----- release/GIT-GPG-KEY-conformal.txt | 74 -------------------- release/README.md | 71 +++++++++++++++++++ release/release.sh | 109 ++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+), 93 deletions(-) delete mode 100644 release/GIT-GPG-KEY-conformal.txt create mode 100644 release/README.md create mode 100755 release/release.sh diff --git a/README.md b/README.md index 2b126a65..a270fd2e 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ which are both under active development. ## Requirements -[Go](http://golang.org) 1.11 or newer. +[Go](http://golang.org) 1.12 or newer. ## Installation @@ -118,25 +118,12 @@ is used for this project. The documentation is a work-in-progress. It is located in the [docs](https://github.com/btcsuite/btcd/tree/master/docs) folder. -## GPG Verification Key +## Release Verification -All official release tags are signed by Conformal so users can ensure the code -has not been tampered with and is coming from the btcsuite developers. To -verify the signature perform the following: - -- Download the Conformal public key: - https://raw.githubusercontent.com/btcsuite/btcd/master/release/GIT-GPG-KEY-conformal.txt - -- Import the public key into your GPG keyring: - ```bash - gpg --import GIT-GPG-KEY-conformal.txt - ``` - -- Verify the release tag with the following command where `TAG_NAME` is a - placeholder for the specific tag: - ```bash - git tag -v TAG_NAME - ``` +Please see our [documentation on the current build/verification +process](https://github.com/btcsuite/btcd/tree/master/release) for all our +releases for information on how to verify the integrity of published releases +using our reproducible build system. ## License diff --git a/release/GIT-GPG-KEY-conformal.txt b/release/GIT-GPG-KEY-conformal.txt deleted file mode 100644 index a6d1a256..00000000 --- a/release/GIT-GPG-KEY-conformal.txt +++ /dev/null @@ -1,74 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v1 - -mQINBFGJW70BEAC6cms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fpXy4qH21ovho+I2y4FH -k3XVKrFgnT/g3Q1sU7GR+V/gO14nR7gbpo3LSodN0FVUTsp7kc9FZJvoUzIufwp5 -Te0Hxo1+FIse88qDcwdj5VxIDF5rIWHqdbRmoLaT0FFfckCo99R6a0n0Q9w= -=iic8 ------END PGP PUBLIC KEY BLOCK----- diff --git a/release/README.md b/release/README.md new file mode 100644 index 00000000..10d1c80c --- /dev/null +++ b/release/README.md @@ -0,0 +1,71 @@ +# `btcd`'s Reproducible Build System + +This package contains the build script that the `btcd` project uses in order to +build binaries for each new release. As of `go1.13`, with some new build flags, +binaries are now reproducible, allowing developers to build the binary on +distinct machines, and end up with a byte-for-byte identical binary. However, +this wasn't _fully_ solved in `go1.13`, as the build system still includes the +directory the binary is built into the binary itself. As a result, our scripts +utilize a work around needed until `go1.13.2`. + +## Building a New Release + +### macOS/Linux/Windows (WSL) + +No prior set up is needed on Linux or macOS is required in order to build the +release binaries. However, on Windows, the only way to build the release +binaries at the moment is by using the Windows Subsystem Linux. One can build +the release binaries following these steps: + +1. `git clone https://github.com/btcsuite/btcd.git +2. `cd btcd` +3. `./build/release/release.sh # is the name of the next + release/tag` + +This will then create a directory of the form `btcd-` containing archives +of the release binaries for each supported operating system and architecture, +and a manifest file containing the hash of each archive. + +## Verifying a Release + +With `go1.13`, it's now possible for third parties to verify release binaries. +Before this version of `go`, one had to trust the release manager(s) to build the +proper binary. With this new system, third parties can now _independently_ run +the release process, and verify that all the hashes of the release binaries +match exactly that of the release binaries produced by said third parties. + +To verify a release, one must obtain the following tools (many of these come +installed by default in most Unix systems): `gpg`/`gpg2`, `shashum`, and +`tar`/`unzip`. + +Once done, verifiers can proceed with the following steps: + +1. Acquire the archive containing the release binaries for one's specific + operating system and architecture, and the manifest file along with its + signature. +2. Verify the signature of the manifest file with `gpg --verify + manifest-.txt.sig`. This will require obtaining the PGP keys which + signed the manifest file, which are included in the release notes. +3. Recompute the `SHA256` hash of the archive with `shasum -a 256 `, + locate the corresponding one in the manifest file, and ensure they match + __exactly__. + +At this point, verifiers can use the release binaries acquired if they trust +the integrity of the release manager(s). Otherwise, one can proceed with the +guide to verify the release binaries were built properly by obtaining `shasum` +and `go` (matching the same version used in the release): + +4. Extract the release binaries contained within the archive, compute their + hashes as done above, and note them down. +5. Ensure `go` is installed, matching the same version as noted in the release + notes. +6. Obtain a copy of `btcd`'s source code with `git clone + https://github.com/btcsuite/btcd` and checkout the source code of the + release with `git checkout `. +7. Proceed to verify the tag with `git verify-tag ` and compile the + binaries from source for the intended operating system and architecture with + `BTCDBUILDSYS=OS-ARCH ./build/release/release.sh `. +8. Extract the archive found in the `btcd-` directory created by the + release script and recompute the `SHA256` hash of the release binaries (btcd + and btcctl) with `shasum -a 256 `. These should match __exactly__ + as the ones noted above. diff --git a/release/release.sh b/release/release.sh new file mode 100755 index 00000000..53c73b8d --- /dev/null +++ b/release/release.sh @@ -0,0 +1,109 @@ +#!/bin/bash + +# Simple bash script to build basic btcd tools for all the platforms we support +# with the golang cross-compiler. +# +# Copyright (c) 2016 Company 0, LLC. +# Use of this source code is governed by the ISC +# license. + +set -e + +# If no tag specified, use date + version otherwise use tag. +if [[ $1x = x ]]; then + DATE=`date +%Y%m%d` + VERSION="01" + TAG=$DATE-$VERSION +else + TAG=$1 +fi + +go mod vendor +tar -cvzf vendor.tar.gz vendor + +PACKAGE=btcd +MAINDIR=$PACKAGE-$TAG +mkdir -p $MAINDIR + +cp vendor.tar.gz $MAINDIR/ +rm vendor.tar.gz +rm -r vendor + +PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar" +git archive -o $PACKAGESRC HEAD +gzip -f $PACKAGESRC > "$PACKAGESRC.gz" + +cd $MAINDIR + +# If BTCDBUILDSYS is set the default list is ignored. Useful to release +# for a subset of systems/architectures. +SYS=${BTCDBUILDSYS:-" + darwin-386 + darwin-amd64 + dragonfly-amd64 + freebsd-386 + freebsd-amd64 + freebsd-arm + illumos-amd64 + linux-386 + linux-amd64 + linux-armv6 + linux-armv7 + linux-arm64 + linux-ppc64 + linux-ppc64le + linux-mips + linux-mipsle + linux-mips64 + linux-mips64le + linux-s390x + netbsd-386 + netbsd-amd64 + netbsd-arm + netbsd-arm64 + openbsd-386 + openbsd-amd64 + openbsd-arm + openbsd-arm64 + solaris-amd64 + windows-386 + windows-amd64 + windows-arm +"} + +# Use the first element of $GOPATH in the case where GOPATH is a list +# (something that is totally allowed). +PKG="github.com/btcsuite/btcd" +COMMIT=$(git describe --abbrev=40 --dirty) + +for i in $SYS; do + OS=$(echo $i | cut -f1 -d-) + ARCH=$(echo $i | cut -f2 -d-) + ARM= + + if [[ $ARCH = "armv6" ]]; then + ARCH=arm + ARM=6 + elif [[ $ARCH = "armv7" ]]; then + ARCH=arm + ARM=7 + fi + + mkdir $PACKAGE-$i-$TAG + cd $PACKAGE-$i-$TAG + + echo "Building:" $OS $ARCH $ARM + env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/btcsuite/btcd + env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/btcsuite/btcd/cmd/btcctl + cd .. + + if [[ $OS = "windows" ]]; then + zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG + else + tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG + fi + + rm -r $PACKAGE-$i-$TAG +done + +shasum -a 256 * > manifest-$TAG.txt