github.com/btcsuite/btcd@v0.24.0/release/README.md (about) 1 # `btcd`'s Reproducible Build System 2 3 This package contains the build script that the `btcd` project uses in order to 4 build binaries for each new release. As of `go1.13`, with some new build flags, 5 binaries are now reproducible, allowing developers to build the binary on 6 distinct machines, and end up with a byte-for-byte identical binary. 7 Every release should note which Go version was used to build the release, so 8 that version should be used for verifying the release. 9 10 ## Building a New Release 11 12 ### Tagging and pushing a new tag (for maintainers) 13 14 Before running release scripts, a few things need to happen in order to finally 15 create a release and make sure there are no mistakes in the release process. 16 17 First, make sure that before the tagged commit there are modifications to the 18 [CHANGES](../CHANGES) file committed. 19 The CHANGES file should be a changelog that roughly mirrors the release notes. 20 Generally, the PRs that have been merged since the last release have been 21 listed in the CHANGES file and categorized. 22 For example, these changes have had the following format in the past: 23 ``` 24 Changes in X.YY.Z (Month Day Year): 25 - Protocol and Network-related changes: 26 - PR Title One (#PRNUM) 27 - PR Title Two (#PRNUMTWO) 28 ... 29 - RPC changes: 30 - Crypto changes: 31 ... 32 33 - Contributors (alphabetical order): 34 - Contributor A 35 - Contributor B 36 - Contributor C 37 ... 38 ``` 39 40 If the previous tag is, for example, `vA.B.C`, then you can get the list of 41 contributors (from `vA.B.C` until the current `HEAD`) using the following command: 42 ```bash 43 git log vA.B.C..HEAD --pretty="%an" | sort | uniq 44 ``` 45 After committing changes to the CHANGES file, the tagged release commit 46 should be created. 47 48 The tagged commit should be a commit that bumps version numbers in `version.go` 49 and `cmd/btcctl/version.go`. 50 For example (taken from [f3ec130](https://github.com/btcsuite/btcd/commit/f3ec13030e4e828869954472cbc51ac36bee5c1d)): 51 ```diff 52 diff --git a/cmd/btcctl/version.go b/cmd/btcctl/version.go 53 index 2195175c71..f65cacef7e 100644 54 --- a/cmd/btcctl/version.go 55 +++ b/cmd/btcctl/version.go 56 @@ -18,7 +18,7 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr 57 const ( 58 appMajor uint = 0 59 appMinor uint = 20 60 - appPatch uint = 0 61 + appPatch uint = 1 62 63 // appPreRelease MUST only contain characters from semanticAlphabet 64 // per the semantic versioning spec. 65 diff --git a/version.go b/version.go 66 index 92fd60fdd4..fba55b5a37 100644 67 --- a/version.go 68 +++ b/version.go 69 @@ -18,7 +18,7 @@ const semanticAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr 70 const ( 71 appMajor uint = 0 72 appMinor uint = 20 73 - appPatch uint = 0 74 + appPatch uint = 1 75 76 // appPreRelease MUST only contain characters from semanticAlphabet 77 // per the semantic versioning spec. 78 ``` 79 80 Next, this commit should be signed by the maintainer using `git commit -S`. 81 The commit should be tagged and signed with `git tag <TAG> -s`, and should be 82 pushed using `git push origin TAG`. 83 84 ### Building a release on macOS/Linux/Windows (WSL) 85 86 No prior set up is needed on Linux or macOS is required in order to build the 87 release binaries. However, on Windows, the only way to build the release 88 binaries at the moment is by using the Windows Subsystem Linux. One can build 89 the release binaries following these steps: 90 91 1. `git clone https://github.com/btcsuite/btcd.git` 92 2. `cd btcd` 93 3. `./release/release.sh <TAG> # <TAG> is the name of the next release/tag` 94 95 This will then create a directory of the form `btcd-<TAG>` containing archives 96 of the release binaries for each supported operating system and architecture, 97 and a manifest file containing the hash of each archive. 98 99 ### Pushing a release (for maintainers) 100 101 Now that the directory `btcd-<TAG>` is created, the manifest file needs to be 102 signed by a maintainer and the release files need to be published to GitHub. 103 104 Sign the `manifest-<TAG>.txt` file like so: 105 ```sh 106 gpg --sign --detach-sig manifest-<TAG>.txt 107 ``` 108 This will create a file named `manifest-<TAG>.txt.sig`, which will must 109 be included in the release files later. 110 111 #### Note before publishing 112 Before publishing, go through the reproducible build process that is outlined 113 in this document with the files created from `release/release.sh`. This includes 114 verifying commit and tag signatures using `git verify-commit` and git `verify-tag` 115 respectively. 116 117 Now that we've double-checked everything and have all of the necessary files, 118 it's time to publish release files on GitHub. 119 Follow [this documentation](https://docs.github.com/en/github/administering-a-repository/managing-releases-in-a-repository) 120 to create a release using the GitHub UI, and make sure to write release notes 121 which roughly follow the format of [previous release notes](https://github.com/btcsuite/btcd/releases/tag/v0.20.1-beta). 122 This is different from the [CHANGES](../CHANGES) file, which should be before the 123 tagged commit in the git history. 124 Much of the information in the release notes will be the same as the CHANGES 125 file. 126 It's important to include the Go version used to produce the release files in 127 the release notes, so users know the correct version of Go to use to reproduce 128 and verify the build. 129 When following the GitHub documentation, include every file in the `btcd-<TAG>` 130 directory. 131 132 At this point, a signed commit and tag on that commit should be pushed to the main 133 branch. The directory created from running `release/release.sh` should be included 134 as release files in the GitHub release UI, and the `manifest-<TAG>.txt` file 135 signature, called `manifest-<TAG>.txt.sig`, should also be included. 136 A release notes document should be created and written in the GitHub release UI. 137 Once all of this is done, feel free to click `Publish Release`! 138 139 ## Verifying a Release 140 141 With `go1.13`, it's now possible for third parties to verify release binaries. 142 Before this version of `go`, one had to trust the release manager(s) to build the 143 proper binary. With this new system, third parties can now _independently_ run 144 the release process, and verify that all the hashes of the release binaries 145 match exactly that of the release binaries produced by said third parties. 146 147 To verify a release, one must obtain the following tools (many of these come 148 installed by default in most Unix systems): `gpg`/`gpg2`, `shashum`, and 149 `tar`/`unzip`. 150 151 Once done, verifiers can proceed with the following steps: 152 153 1. Acquire the archive containing the release binaries for one's specific 154 operating system and architecture, and the manifest file along with its 155 signature. 156 2. Verify the signature of the manifest file with `gpg --verify 157 manifest-<TAG>.txt.sig`. This will require obtaining the PGP keys which 158 signed the manifest file, which are included in the release notes. 159 3. Recompute the `SHA256` hash of the archive with `shasum -a 256 <filename>`, 160 locate the corresponding one in the manifest file, and ensure they match 161 __exactly__. 162 163 At this point, verifiers can use the release binaries acquired if they trust 164 the integrity of the release manager(s). Otherwise, one can proceed with the 165 guide to verify the release binaries were built properly by obtaining `shasum` 166 and `go` (matching the same version used in the release): 167 168 4. Extract the release binaries contained within the archive, compute their 169 hashes as done above, and note them down. 170 5. Ensure `go` is installed, matching the same version as noted in the release 171 notes. 172 6. Obtain a copy of `btcd`'s source code with `git clone 173 https://github.com/btcsuite/btcd` and checkout the source code of the 174 release with `git checkout <TAG>`. 175 7. Proceed to verify the tag with `git verify-tag <TAG>` and compile the 176 binaries from source for the intended operating system and architecture with 177 `BTCDBUILDSYS=OS-ARCH ./release/release.sh <TAG>`. 178 8. Extract the archive found in the `btcd-<TAG>` directory created by the 179 release script and recompute the `SHA256` hash of the release binaries (btcd 180 and btcctl) with `shasum -a 256 <filename>`. These should match __exactly__ 181 as the ones noted above.