Skip to content

Commit 44c83d7

Browse files
committed
docs: add reproducible release build guide
1 parent ec5395b commit 44c83d7

File tree

1 file changed

+125
-0
lines changed

1 file changed

+125
-0
lines changed

docs/release.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# `taproot-assets`'s Reproducible Build System
2+
3+
This package contains the build script that the `taproot-assets` project uses in
4+
order to build binaries for each new release. As of `go1.13`, with some new
5+
build flags, binaries are now reproducible, allowing developers to build the
6+
binary on distinct machines, and end up with a byte-for-byte identical binary.
7+
However, this wasn't _fully_ solved in `go1.13`, as the build system still
8+
includes the directory the binary is built into the binary itself. As a result,
9+
our scripts utilize a work around needed until `go1.13.2`.
10+
11+
## Building a New Release
12+
13+
### MacOS
14+
15+
The first requirement is to have [`docker`](https://www.docker.com/)
16+
installed locally and running. The second requirement is to have `make`
17+
installed. Everything else (including `golang`) is included in the release
18+
helper image.
19+
20+
To build a release, run the following commands:
21+
22+
```shell
23+
$ git clone https://github.com/lightninglabs/taproot-assets.git
24+
$ cd taproot-assets
25+
$ git checkout <TAG> # <TAG> is the name of the next release/tag
26+
$ make docker-release tag=<TAG>
27+
```
28+
29+
Where `<TAG>` is the name of the next release of `taproot-assets`.
30+
31+
### Linux/Windows (WSL)
32+
33+
No prior set up is needed on Linux or macOS is required in order to build the
34+
release binaries. However, on Windows, the only way to build the release
35+
binaries at the moment is by using the Windows Subsystem Linux. One can build
36+
the release binaries following these steps:
37+
38+
```shell
39+
$ git clone https://github.com/lightninglabs/taproot-assets.git
40+
$ cd taproot-assets
41+
$ git checkout <TAG> # <TAG> is the name of the next release/tag
42+
$ make release tag=<TAG>
43+
```
44+
45+
This will then create a directory of the form `taproot-assets-<TAG>` containing
46+
archives of the release binaries for each supported operating system and
47+
architecture, and a manifest file containing the hash of each archive.
48+
49+
## Verifying a Release
50+
51+
With `go1.13`, it's now possible for third parties to verify release binaries.
52+
Before this version of `go`, one had to trust the release manager(s) to build the
53+
proper binary. With this new system, third parties can now _independently_ run
54+
the release process, and verify that all the hashes of the release binaries
55+
match exactly that of the release binaries produced by said third parties.
56+
57+
To verify a release, one must obtain the following tools (many of these come
58+
installed by default in most Unix systems): `gpg`/`gpg2`, `shashum`, and
59+
`tar`/`unzip`.
60+
61+
Once done, verifiers can proceed with the following steps:
62+
63+
1. Acquire the archive containing the release binaries for one's specific
64+
operating system and architecture, and the manifest file along with its
65+
signature.
66+
2. Verify the signature of the manifest file with `gpg --verify
67+
manifest-<TAG>.txt.sig`. This will require obtaining the PGP keys which
68+
signed the manifest file, which are included in the release notes.
69+
3. Recompute the `SHA256` hash of the archive with `shasum -a 256 <filename>`,
70+
locate the corresponding one in the manifest file, and ensure they match
71+
__exactly__.
72+
73+
At this point, verifiers can use the release binaries acquired if they trust
74+
the integrity of the release manager(s). Otherwise, one can proceed with the
75+
guide to verify the release binaries were built properly by obtaining `shasum`
76+
and `go` (matching the same version used in the release):
77+
78+
4. Extract the release binaries contained within the archive, compute their
79+
hashes as done above, and note them down.
80+
5. Ensure `go` is installed, matching the same version as noted in the release
81+
notes.
82+
6. Obtain a copy of `taproot-assets`'s source code with `git clone
83+
https://github.com/lightninglabs/taproot-assets` and checkout the source code of the
84+
release with `git checkout <TAG>`.
85+
7. Proceed to verify the tag with `git verify-tag <TAG>` and compile the
86+
binaries from source for the intended operating system and architecture with
87+
`make release sys=OS-ARCH tag=<TAG>`.
88+
8. Extract the archive found in the `taproot-assets-<TAG>` directory created by
89+
the release script and recompute the `SHA256` hash of the release binaries
90+
(`tapd` and `tapcli`) with `shasum -a 256 <filename>`. These should match
91+
__exactly__ as the ones noted above.
92+
93+
## Verifying Docker Images
94+
95+
To verify the `tapd` and `tapcli` binaries inside the
96+
[official provided docker images](https://hub.docker.com/r/lightninglabs/taproot-assets)
97+
against the signed, reproducible release binaries, there is a verification
98+
script in the image that can be called (before starting the container for
99+
example):
100+
101+
```shell
102+
$ docker run --rm --entrypoint="" lightninglabs/taproot-assets:v0.3.0 /verify-install.sh v0.3.0
103+
$ OK=$?
104+
$ if [ "$OK" -ne "0" ]; then echo "Verification failed!"; exit 1; done
105+
$ docker run lightninglabs/taproot-assets [command-line options]
106+
```
107+
108+
# Signing an Existing Manifest File
109+
110+
If you're a developer of `taproot-assets` and are interested in attaching your
111+
signature to the final release archive, the manifest MUST be signed in a manner
112+
that allows your signature to be verified by our verify script
113+
`scripts/verify-install.sh`.
114+
115+
Assuming you've done a local build for _all_ release targets, then you should
116+
have a file called `manifest-TAG.txt` where `TAG` is the actual release tag
117+
description being signed. The release script expects a particular file name for
118+
each included signature, so we'll need to modify the name of our output
119+
signature during signing.
120+
121+
Assuming `USERNAME` is your current nick as a developer, then the following
122+
command will generate a proper signature:
123+
```shell
124+
$ gpg --detach-sig --output manifest-USERNAME-TAG.sig manifest-TAG.txt
125+
```

0 commit comments

Comments
 (0)