|
1 | 1 | # how release works |
2 | 2 |
|
3 | | -Prerequisite: |
4 | | - |
5 | | -* docker installed |
6 | | -* How drone works |
7 | | -* How [goreleaser](https://goreleaser.com/intro/) works and you have to |
8 | | - [install](https://goreleaser.com/install/) it to try a release locally. |
9 | | -* multi arch TODO, don't know yet |
10 | | - |
11 | | -## Continuous Delivery |
12 | | - |
13 | | -We use GitHub Action as continuous integration and continuous delivery pipeline. |
14 | | -Integration means: running tests, checking code quality. |
15 | | -Delivery means: make a release when a new tag get pushed. |
16 | | - |
17 | | -GoReleaser is used only when a new tag gets pushed. We also push a new image |
18 | | -every time master changes. I will document this workflow in its own chapter: |
19 | | -"push from master" at the end of this document but at the moment it does not use |
20 | | -GoReleaser. |
21 | | - |
22 | | -## goreleaser |
23 | | - |
24 | | -GoReleaser is a popular tool to release Go applications and library. |
25 | | - |
26 | | -We use GoReleaser for the following features: |
27 | | - |
28 | | -* Multi arch build. It uses Go cross compilation feature to build for Darwin and |
29 | | - Linux (arm and amd) |
30 | | -* Docker to build docker images for Linux container arm and amd. |
31 | | -* Changelog to generate a changelog that will be pushed in the GitHub release |
32 | | - page with the list of PR part of the release itself. |
33 | | -* Artifact (binaries) will be pushed as part of GitHub release page as well as |
34 | | - the other YAML file required by cluster-api like: metadata.yaml, |
35 | | - infrastructure-provider.yaml and so on. |
36 | | - |
37 | | -First things you should check if the file `./goreleaser.yaml` in the project |
38 | | -root because it gives you an idea about what it does. |
39 | | - |
40 | | -## Directories and general workflow |
41 | | - |
42 | | -The release life cycle touches two directories: |
43 | | - |
44 | | -1. `./dist` it is a temporary directory used by GoReleaser to bundle all the |
45 | | - required files and, binaries, changelog and so on. It is in gitignore. |
46 | | -2. `./out` is ignored by git and it gets generated via `make release`. It is a |
47 | | - bundle that contains generated Kubernetes manifest required by the |
48 | | - cluster-api such as: metadata.yaml, infrastructure-provider.yaml, |
49 | | - cluster-template.yaml and so on. |
50 | | - |
51 | | -GoReleaser works in this way: |
52 | | - |
53 | | -1. it builds binaries in `./dist` |
54 | | -2. moves all the file that has to be added in the release archive and release |
55 | | - page such as: LICENSE, README, the kubernetes manifests in `./dist` |
56 | | -3. Build docker images |
57 | | -4. Push all the archives and the images to GitHub and to Docker Hub. |
58 | | - |
59 | | -## Local workflow |
60 | | - |
61 | | -GoReleaser can be used locally, to visualize how a release will look like for |
62 | | -example: |
63 | | - |
64 | | -``` |
65 | | -$ goreleaser release --rm-dir --skip-publish |
66 | | -``` |
67 | | - |
68 | | -You can run this command if your git HEAD has a tag. You can make a temporary |
69 | | -one: |
70 | | - |
71 | | -``` |
72 | | -git tag v0.10.0 |
73 | | -``` |
74 | | - |
75 | | -Or you can decided to run GoRelease in `--snapshot` mode to avoid a fake tag |
76 | | -(but changelog won't work): |
77 | | - |
78 | | -``` |
79 | | -$ goreleaser release --rm-dir --snapshot --skip-publish |
80 | | -``` |
81 | | - |
82 | | -*Removing --skip-publish goreleaser will attempt a push to GitHub and to your |
83 | | -docker image repository (docker.io). In this way you can cut a release from your |
84 | | -laptop if needed. But it is not a good idea and we use drone for that. Normally |
85 | | -at Packet only drone.io is capable of pushing to Docker Hub and GitHub.* |
86 | | - |
87 | | -We have an utility target that helps you do try a release: |
88 | | - |
89 | | -``` |
90 | | -make release |
91 | | -``` |
92 | | - |
93 | | -If you know what you are doing and you have the right access to GitHub and |
94 | | -Docker Hub you can use: |
95 | | - |
96 | | -``` |
97 | | -make release/publish |
98 | | -``` |
99 | | -**THIS IS NOT USUALLY REQUIRED AND YOU SHOULD NOT DO IT!** |
100 | | - |
101 | | -## Drone workflow |
102 | | - |
103 | | -Drone is capable of triggering a command only when a new tag is pushed. |
104 | | -The command it runs is: `goreleaser release`. |
105 | | - |
106 | | -In order to push artifacts and a release page, drone needs to have access to |
107 | | -docker image repository and GitHub via access token. |
108 | | - |
109 | | -## push from master |
110 | | - |
111 | | -We push images to Docker Hub tagged as the git commit sha and latest every time |
112 | | -master changes (usually when a PR gets merged). |
113 | | - |
114 | | -This process at the moment does not use GoReleaser (it will may use it in the |
115 | | -future) and you can check how it works look at the `./.github/workflows/ci.yaml` |
116 | | -file. In practice when master changes an action will build and push the new |
117 | | -images to Docker Hub. |
118 | | - |
119 | | -## example of goreleaser output |
120 | | - |
121 | | -This is an example of a valid goreleaser output that I ran locally via `make release` |
122 | | - |
123 | | -``` |
124 | | -goreleaser release --rm-dist --snapshot --skip-publish |
125 | | -
|
126 | | - • releasing... |
127 | | - • loading config file file=.goreleaser.yml |
128 | | - • running before hooks |
129 | | - • loading environment variables |
130 | | - • getting and validating git state |
131 | | - • releasing v0.1.0, commit 1f8e0e31d10a3f4f909fbcd9249fb12b14bf0010 |
132 | | - • pipe skipped error=disabled during snapshot mode |
133 | | - • parsing tag |
134 | | - • setting defaults |
135 | | - • snapshotting |
136 | | - • github/gitlab/gitea releases |
137 | | - • project name |
138 | | - • building binaries |
139 | | - • creating source archive |
140 | | - • archives |
141 | | - • linux packages |
142 | | - • snapcraft packages |
143 | | - • calculating checksums |
144 | | - • signing artifacts |
145 | | - • docker images |
146 | | - • artifactory |
147 | | - • blobs |
148 | | - • homebrew tap formula |
149 | | - • scoop manifests |
150 | | - • snapshotting |
151 | | - • checking ./dist |
152 | | - • --rm-dist is set, cleaning it up |
153 | | - • writing effective config file |
154 | | - • writing config=dist/config.yaml |
155 | | - • generating changelog |
156 | | - • pipe skipped error=not available for snapshots |
157 | | - • building binaries |
158 | | - • building binary=/Users/gianarb/git/cluster-api-provider-packet/dist/capp_l |
159 | | -inux_arm64/manager |
160 | | - • building binary=/Users/gianarb/git/cluster-api-provider-packet/dist/capp_d |
161 | | -arwin_amd64/manager |
162 | | - • building binary=/Users/gianarb/git/cluster-api-provider-packet/dist/capp_l |
163 | | -inux_amd64/manager |
164 | | - • archives |
165 | | - • creating archive=dist/cluster-api-provider-packet_v0.1.0-next_Linux_x86_64 |
166 | | -.tar.gz |
167 | | - • creating archive=dist/cluster-api-provider-packet_v0.1.0-next_Linux_arm64. |
168 | | -tar.gz |
169 | | - • creating archive=dist/cluster-api-provider-packet_v0.1.0-next_Darwin_x86_6 |
170 | | -4.tar.gz |
171 | | - • creating source archive |
172 | | - • pipe skipped error=source pipe is disabled |
173 | | - • linux packages |
174 | | - • snapcraft packages |
175 | | - • calculating checksums |
176 | | - • checksumming file=cluster-api-provider-packet_v0.1.0-next_Darwin_x86_64.tar.gz |
177 | | - • checksumming file=cluster-api-provider-packet_v0.1.0-next_Linux_arm64.tar.gz |
178 | | - • checksumming file=cluster-api-provider-packet_v0.1.0-next_Linux_x86_64.tar.gz |
179 | | - • signing artifacts |
180 | | - • docker images |
181 | | - • building docker image image=packethost/cluster-api-provider-packet:latest-amd64 |
182 | | - • building docker image image=packethost/cluster-api-provider-packet:latest-arm64 |
183 | | - • pipe skipped error=docker.skip_push is set |
184 | | - • publishing |
185 | | - • blobs |
186 | | - • pipe skipped error=blobs section is not configured |
187 | | - • http upload |
188 | | - • pipe skipped error=uploads section is not configured |
189 | | - • docker images |
190 | | - • pipe skipped error=publishing is disabled |
191 | | - • snapcraft packages |
192 | | - • pipe skipped error=publishing is disabled |
193 | | - • github/gitlab/gitea releases |
194 | | - • pipe skipped error=publishing is disabled |
195 | | - • homebrew tap formula |
196 | | - • token type type= |
197 | | - • scoop manifests |
198 | | - • pipe skipped error=publishing is disabled |
199 | | - • release succeeded after 8.29s |
200 | | -``` |
| 3 | +Currently when master changes CI builds Docker images and pushes them to Docker |
| 4 | +Hub. |
0 commit comments