2015-08-18 20:09:15 +02:00
|
|
|
# Building Terraform
|
2015-05-26 23:12:44 +02:00
|
|
|
|
2015-08-18 20:09:15 +02:00
|
|
|
This document contains details about the process for building binaries for
|
|
|
|
Terraform.
|
2015-05-26 23:12:44 +02:00
|
|
|
|
|
|
|
## Versioning
|
|
|
|
|
|
|
|
As a pre-1.0 project, we use the MINOR and PATCH versions as follows:
|
|
|
|
|
|
|
|
* a `MINOR` version increment indicates a release that may contain backwards
|
|
|
|
incompatible changes
|
|
|
|
* a `PATCH` version increment indicates a release that may contain bugfixes as
|
|
|
|
well as additive (backwards compatible) features and enhancements
|
|
|
|
|
|
|
|
## Process
|
|
|
|
|
2015-08-18 20:09:15 +02:00
|
|
|
If only need to build binaries for the platform you're running (Windows, Linux,
|
|
|
|
Mac OS X etc..), you can follow the instructions in the README for [Developing
|
|
|
|
Terraform][1].
|
|
|
|
|
|
|
|
The guide below outlines the steps HashiCorp takes to build the official release
|
|
|
|
binaries for Terraform. This process will generate a set of binaries for each supported
|
|
|
|
platform, using the [gox](https://github.com/mitchellh/gox) tool.
|
|
|
|
|
|
|
|
A Vagrant virtual machine is used to provide a consistent envirornment with
|
|
|
|
the pre-requisite tools in place. The specifics of this VM are defined in the
|
|
|
|
[Vagrantfile](Vagrantfile).
|
|
|
|
|
2015-05-26 23:12:44 +02:00
|
|
|
|
|
|
|
```sh
|
2015-08-18 20:09:15 +02:00
|
|
|
# clone the repository if needed
|
|
|
|
git clone https://github.com/hashicorp/terraform.git
|
|
|
|
cd terraform
|
|
|
|
|
2015-06-30 21:10:49 +02:00
|
|
|
# Spin up a fresh build VM
|
|
|
|
vagrant destroy -f
|
|
|
|
vagrant up
|
|
|
|
vagrant ssh
|
2015-08-18 20:09:15 +02:00
|
|
|
|
|
|
|
# The Vagrantfile installs Go and configures the $GOPATH at /opt/gopath
|
|
|
|
# The current "terraform" directory is then sync'd into the gopath
|
2015-06-30 21:10:49 +02:00
|
|
|
cd /opt/gopath/src/github.com/hashicorp/terraform/
|
|
|
|
|
|
|
|
# Fetch dependencies
|
|
|
|
make updatedeps
|
|
|
|
|
|
|
|
# Verify unit tests pass
|
2015-05-26 23:12:44 +02:00
|
|
|
make test
|
|
|
|
|
2015-08-18 20:09:15 +02:00
|
|
|
# Build the release
|
|
|
|
# This generates binaries for each platform and places them in the pkg folder
|
|
|
|
make release
|
|
|
|
```
|
|
|
|
|
|
|
|
After running these commands, you should have
|
|
|
|
|
2015-05-26 23:12:44 +02:00
|
|
|
# Prep release commit
|
|
|
|
export VERSION="vX.Y.Z"
|
2015-06-30 21:10:49 +02:00
|
|
|
# Edit CHANGELOG.md, adding current date to unreleased version header
|
2015-05-26 23:12:44 +02:00
|
|
|
# Edit version.go, setting VersionPrelease to empty string
|
|
|
|
|
|
|
|
# Snapshot dependency information
|
2015-07-15 23:34:12 +02:00
|
|
|
go get github.com/tools/godep
|
2015-06-16 23:25:27 +02:00
|
|
|
godep save ./...
|
2015-06-30 21:10:49 +02:00
|
|
|
cp Godeps/Godeps.json deps/$(echo $VERSION | sed 's/\./-/g').json
|
2015-05-26 23:12:44 +02:00
|
|
|
|
2015-06-30 21:10:49 +02:00
|
|
|
# Make and tag release commit (skipping Godeps dir)
|
|
|
|
git add CHANGELOG.md terraform/version.go deps/
|
2015-05-26 23:12:44 +02:00
|
|
|
git commit -a -m "${VERSION}"
|
|
|
|
git tag -m "${VERSION}" "${VERSION}"
|
|
|
|
|
2015-06-30 21:10:49 +02:00
|
|
|
# Build the release
|
2015-05-26 23:12:44 +02:00
|
|
|
make release
|
|
|
|
|
2015-07-20 23:19:41 +02:00
|
|
|
# Add Godeps for the archive
|
|
|
|
git add Godeps
|
|
|
|
|
2015-06-30 21:10:49 +02:00
|
|
|
# Make an archive with vendored dependencies
|
2015-07-20 23:19:41 +02:00
|
|
|
stashName=$(git stash create)
|
2015-06-30 21:10:49 +02:00
|
|
|
git archive -o terraform-$VERSION-src.tar.gz $stashName
|
2015-07-20 23:19:41 +02:00
|
|
|
git reset --hard ${VERSION}
|
2015-06-30 21:10:49 +02:00
|
|
|
|
2015-05-26 23:12:44 +02:00
|
|
|
# Zip and push release to bintray
|
|
|
|
export BINTRAY_API_KEY="..."
|
|
|
|
./scripts/dist "X.Y.Z" # no `v` prefix here
|
|
|
|
|
|
|
|
# -- "Point of no return" --
|
|
|
|
# -- Process can be aborted safely at any point before this --
|
|
|
|
|
|
|
|
# Push the release commit and tag
|
|
|
|
git push origin master
|
|
|
|
git push origin vX.Y.Z
|
|
|
|
|
|
|
|
# Click "publish" on the release from the Bintray Web UI
|
2015-06-30 21:10:49 +02:00
|
|
|
# Upload terraform-$VERSION-src.tar.gz as a file to the GitHub release.
|
2015-05-26 23:12:44 +02:00
|
|
|
|
|
|
|
# -- Release is complete! --
|
|
|
|
|
2015-06-30 21:10:49 +02:00
|
|
|
# Start release branch (to be used for reproducible builds and docs updates)
|
|
|
|
git checkout -b release/$VERSION
|
|
|
|
git push origin release/$VERSION
|
|
|
|
|
|
|
|
# Clean up master
|
|
|
|
git checkout master
|
|
|
|
# Set VersionPrerelease to "dev"
|
|
|
|
# Add new CHANGELOG section for next release
|
|
|
|
git add -A
|
|
|
|
git commit -m "release: clean up after ${VERSION}"
|
2015-05-26 23:12:44 +02:00
|
|
|
```
|
2015-08-18 20:09:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
[1]: https://github.com/hashicorp/terraform#developing-terraform
|