1+++
2title = "Mage in CI"
3date = 2018-09-06T21:41:23-04:00
4type = "post"
5author = "Nate Finch"
6authorLink = "twitter.com/natethefinch"
7+++
8
9So, there's a bootstrap problem with Mage.  What if you want to use Mage for
10your build, but you need to get it during your CI build?  Mage is best built...
11with Mage.  The problem is that if you don't use the custom `mage install` then
12Mage isn't compiled with ldflags that set all the usseful info in `mage
13-version`.  So what do you do?
14
15Luckily, Mage has a [zero install](/zeroInstall) option.  You don't need Mage to
16build Mage, there's a bootstrap file that will let you use `go run` to install
17Mage with all the great version info.  The bootstrap.go file in the root of the
18repo hooks into mage's libraries and acts like Mage itself, so you can pass it
19mage targets in the current directory.
20
21This will download the mage source and install it (if you're using a gopath):
22
23```plain
24go get -d github.com/magefile/mage
25go run $GOPATH/src/github.com/magefile/mage/bootstrap.go install
26```
27
28If you're using go modules, you can do it with good old git clone:
29
30```plain
31git clone git@github.com:magefile/mage
32cd mage
33go run bootstrap.go install
34```
35
36Note that in the second case, the binary will be copied to where go env GOPATH
37points (for now, PRs welcome).