Skip to content

Commit 6dd69b2

Browse files
authored
Merge pull request #661 from lightninglabs/add-github-cd-release-build
Add GitHub CD release build workflow
2 parents fec4a40 + 2657805 commit 6dd69b2

File tree

19 files changed

+1259
-40
lines changed

19 files changed

+1259
-40
lines changed

.github/workflows/main.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ env:
1919
# go needs absolute directories, using the $HOME variable doesn't work here.
2020
GOPATH: /home/runner/work/go
2121

22-
# If you change this value, please change it in the following files as well:
23-
# /Dockerfile
24-
# /dev.Dockerfile
25-
# /make/builder.Dockerfile
26-
# /taprpc/Dockerfile
27-
# /tools/Dockerfile
2822
GO_VERSION: '1.21.0'
2923

3024
jobs:

.github/workflows/release.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Release build
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
env:
13+
GO_VERSION: 1.21.0
14+
15+
jobs:
16+
main:
17+
name: Release build
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: git checkout
21+
uses: actions/checkout@v2
22+
with:
23+
fetch-depth: 0
24+
25+
- name: setup go ${{ env.GO_VERSION }}
26+
uses: actions/setup-go@v2
27+
with:
28+
go-version: '${{ env.GO_VERSION }}'
29+
30+
- name: Set env
31+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
32+
33+
- name: build release for all architectures
34+
run: SKIP_VERSION_CHECK=1 make release tag=${{ env.RELEASE_VERSION }}
35+
36+
- name: Create Release
37+
uses: lightninglabs/gh-actions/[email protected]
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
with:
41+
tag_name: ${{ env.RELEASE_VERSION }}
42+
name: tapd ${{ env.RELEASE_VERSION }}
43+
draft: true
44+
prerelease: false
45+
files: tapd-${{ env.RELEASE_VERSION }}/*
46+
body: |
47+
# Database Migrations
48+
TODO
49+
50+
# Verifying the Release
51+
52+
In order to verify the release, you'll need to have `gpg` or `gpg2` installed on your system. Once you've obtained a copy (and hopefully verified that as well), you'll first need to import the keys that have signed this release if you haven't done so already:
53+
54+
```
55+
curl https://raw.githubusercontent.com/lightninglabs/taproot-assets/main/scripts/keys/roasbeef.asc | gpg --import
56+
```
57+
58+
Once you have the required PGP keys, you can verify the release (assuming `manifest-roasbeef-${{ env.RELEASE_VERSION }}.sig` and `manifest-${{ env.RELEASE_VERSION }}.txt` are in the current directory) with:
59+
60+
```
61+
gpg --verify manifest-roasbeef-${{ env.RELEASE_VERSION }}.sig manifest-${{ env.RELEASE_VERSION }}.txt
62+
```
63+
64+
You should see the following if the verification was successful:
65+
66+
```
67+
gpg: Signature made Wed Sep 30 17:35:20 2020 PDT
68+
gpg: using RSA key 60A1FA7DA5BFF08BDCBBE7903BBD59E99B280306
69+
gpg: Good signature from "Olaoluwa Osuntokun <[email protected]>" [ultimate]
70+
```
71+
72+
That will verify the signature of the manifest file, which ensures integrity and authenticity of the archive you've downloaded locally containing the binaries. Next, depending on your operating system, you should then re-compute the `sha256` hash of the archive with `shasum -a 256 <filename>`, compare it with the corresponding one in the manifest file, and ensure they match *exactly*.
73+
74+
## Verifying the Release Timestamp
75+
76+
From this new version onwards, in addition time-stamping the _git tag_ with [OpenTimestamps](https://opentimestamps.org/), we'll also now timestamp the manifest file along with its signature. Two new files are now included along with the rest of our release artifacts: ` manifest-roasbeef-${{ env.RELEASE_VERSION }}.txt.asc.ots`.
77+
78+
Assuming you have the opentimestamps client installed locally, the timestamps can be verified with the following commands:
79+
```
80+
ots verify manifest-roasbeef-${{ env.RELEASE_VERSION }}.sig.ots -f manifest-roasbeef-${{ env.RELEASE_VERSION }}.sig
81+
```
82+
83+
Alternatively, [the OpenTimestamps website](https://opentimestamps.org/) can be used to verify timestamps if one doesn't have a `bitcoind` instance accessible locally.
84+
85+
These timestamps should give users confidence in the integrity of this release even after the key that signed the release expires.
86+
87+
## Verifying the Release Binaries
88+
89+
Our release binaries are fully reproducible. Third parties are able to verify that the release binaries were produced properly without having to trust the release manager(s). See our [reproducible builds guide](https://github.com/lightninglabs/taproot-assets/blob/main/docs/release.md) for how this can be achieved.
90+
The release binaries are compiled with `go${{ env.GO_VERSION }}`, which is required by verifiers to arrive at the same ones.
91+
92+
The `make release` command can be used to ensure one rebuilds with all the same flags used for the release. If one wishes to build for only a single platform, then `make release sys=<OS-ARCH> tag=<tag>` can be used.
93+
94+
Finally, you can also verify the _tag_ itself with the following command:
95+
96+
```
97+
$ git verify-tag ${{ env.RELEASE_VERSION }}
98+
gpg: Signature made Tue Sep 15 18:55:00 2020 PDT
99+
gpg: using RSA key 60A1FA7DA5BFF08BDCBBE7903BBD59E99B280306
100+
gpg: Good signature from "Olaoluwa Osuntokun <[email protected]>" [ultimate]
101+
```
102+
103+
## Verifying the Docker Images
104+
105+
To verify the `tapd` and `tapcli` binaries inside the docker images against the signed, reproducible release binaries, there is a verification script in the image that can be called (before starting the container for example):
106+
107+
```shell
108+
$ docker run --rm --entrypoint="" lightninglabs/taproot-assets:${{ env.RELEASE_VERSION }} /verify-install.sh ${{ env.RELEASE_VERSION }}
109+
$ OK=$?
110+
$ if [ "$OK" -ne "0" ]; then echo "Verification failed!"; exit 1; done
111+
$ docker run lightninglabs/taproot-assets [command-line options]
112+
```
113+
114+
# Building the Contained Release
115+
116+
Users are able to rebuild the target release themselves without having to fetch any of the dependencies. In order to do so, assuming
117+
that `vendor.tar.gz` and `tapd-source-${{ env.RELEASE_VERSION }}.tar.gz` are in the current directory, follow these steps:
118+
119+
```
120+
tar -xvzf vendor.tar.gz
121+
tar -xvzf tapd-source-${{ env.RELEASE_VERSION }}.tar.gz
122+
GO111MODULE=on go install -v -mod=vendor -ldflags "-X github.com/lightninglabs/taproot-assets/build.Commit=${{ env.RELEASE_VERSION }}" ./cmd/tapd
123+
GO111MODULE=on go install -v -mod=vendor -ldflags "-X github.com/lightninglabs/taproot-assets/build.Commit=${{ env.RELEASE_VERSION }}" ./cmd/tapcli
124+
```
125+
126+
The `-mod=vendor` flag tells the `go build` command that it doesn't need to fetch the dependencies, and instead, they're all enclosed in the local vendor directory.
127+
128+
Additionally, it's now possible to use the enclosed `release.sh` script to bundle a release for a _specific_ system like so:
129+
130+
```
131+
make release sys="linux-arm64 darwin-amd64"
132+
```
133+
134+
⚡️⚡️⚡️ OK, now to the rest of the release notes! ⚡️⚡️⚡️
135+
136+
# Release Notes
137+
138+
TODO
139+
140+
# Contributors (Alphabetical Order)
141+
142+
TODO

Dockerfile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
# If you change this value, please change it in the following files as well:
2-
# /.github/workflows/main.yaml
3-
# /dev.Dockerfile
4-
# /make/builder.Dockerfile
5-
# /taprpc/Dockerfile
6-
# /tools/Dockerfile
7-
# /itest/loadtest/Dockerfile
81
FROM golang:1.21.0-alpine as builder
92

103
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ DOCKER_TOOLS = docker run \
5757
-v $(shell bash -c "go env GOMODCACHE || (mkdir -p /tmp/go-modcache; echo /tmp/go-modcache)"):/tmp/build/.modcache \
5858
-v $$(pwd):/build taproot-assets-tools
5959

60+
GO_VERSION = 1.21.0
61+
6062
GREEN := "\\033[0;32m"
6163
NC := "\\033[0m"
6264
define print
@@ -251,10 +253,20 @@ fmt: $(GOIMPORTS_BIN)
251253
@$(call print, "Formatting source.")
252254
gofmt -l -w -s $(GOFILES_NOVENDOR)
253255

254-
lint: docker-tools
256+
check-go-version-yaml:
257+
@$(call print, "Checking for target Go version (v$(GO_VERSION)) in YAML files (*.yaml, *.yml)")
258+
./tools/check-go-version-yaml.sh $(GO_VERSION)
259+
260+
check-go-version-dockerfile:
261+
@$(call print, "Checking for target Go version (v$(GO_VERSION)) in Dockerfile files (*Dockerfile)")
262+
./tools/check-go-version-dockerfile.sh $(GO_VERSION)
263+
264+
lint-source: docker-tools
255265
@$(call print, "Linting source.")
256266
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
257267

268+
lint: lint-source check-go-version-dockerfile check-go-version-yaml
269+
258270
list:
259271
@$(call print, "Listing commands.")
260272
@$(MAKE) -qp | \

dev.Dockerfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
# If you change this value, please change it in the following files as well:
2-
# /.github/workflows/main.yaml
3-
# /Dockerfile
4-
# /make/builder.Dockerfile
5-
# /taprpc/Dockerfile
6-
# /tools/Dockerfile
7-
FROM golang:1.21.0 as builder
1+
FROM golang:1.21.0 as builder
82

93
WORKDIR /app
104

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+
```

itest/loadtest/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21.0 as builder
1+
FROM golang:1.21.0 as builder
22

33
WORKDIR /app
44

make/builder.Dockerfile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# If you change this value, please change it in the following files as well:
2-
# /.github/workflows/main.yaml
3-
# /Dockerfile
4-
# /dev.Dockerfile
5-
# /taprpc/Dockerfile
6-
# /tools/Dockerfile
71
FROM golang:1.21.0-bookworm
82

93
MAINTAINER Olaoluwa Osuntokun <[email protected]>

scripts/keys/ffranr.asc

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
-----BEGIN PGP PUBLIC KEY BLOCK-----
2+
3+
mQGNBGM+7DcBDACxPY5WZEB8PwmUkWugPTgDOiBtdOeh7V6B+emLAJjLMaj+XBIM
4+
YN4AmJOmhrTH3s2avmQRAmE2lYNDhAeYn6SGcHZonYXGMgnrbUpibYkUhsCz5n/T
5+
M2dG18rJEqVu7VjF7o9Ug8X5dmLgFTSfl4lne3bvR+ciuebWEZislpNRQs8FXBXk
6+
MQRDgJ44gjYyWcbdHOTimXM2vzDJo0OF2PHK1hJU23fHNH5Pnz7sjyCimEUbsO1f
7+
iVoSEp8tCGnFf20WWL39+Qsww96mr+Sm2UC746PKEVRDMIvkgG9VfzwbUP2oHvA0
8+
60gwm4QE2YIkfH7YZ4/pekRxkXoo6UobXMWS3S1iOQmJwR8sX3/51E96Fw98SIZx
9+
K7pOEQQ5ewkbLkr+rMhuP7noS5irXhqtcjfRLyLUrfP4Yj/OUlehiklULS2uQ3/h
10+
wpaBJJLw0Um8ARkR0hhk2gv8hhKbNm15sLwvtnDmRvCtzaxSxA8VkMcwS1OvxEGj
11+
IPwvLEb9MyBLvL0AEQEAAbQsUm9ieW4gRmZyYW5jb24gPHJvYnluQGxpZ2h0bmlu
12+
Zy5lbmdpbmVlcmluZz6JAdQEEwEKAD4WIQT+XhWacMQ21q9NKIex+ISFV6op0gUC
13+
Yz7sNwIbAwUJA8JnAAULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRCx+ISFV6op
14+
0jA4C/4tWj0/ByAHnguSgSSBuU4JTrfHngJP9Zle6cIGJkbt627on0PmRi59vPSu
15+
Zpgp+qwKk8hTZuOH4pvZMyBdGVrUsBjGO7DKU5ZaetR/aZxB4nTpc2nJ5nZXTiKV
16+
pn3MQ3wfnkq78DMQ7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