Skip to content

Commit cc6f191

Browse files
committed
Prepare for first release
1 parent 1dfafe6 commit cc6f191

File tree

3 files changed

+121
-9
lines changed

3 files changed

+121
-9
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## Unreleased [v0.1.0] - (2020-11-XX)
8+
## Unreleased
99

1010
### Fixes
1111

@@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### New
1717

18+
## [v0.1.0] - (2020-11-20)
19+
20+
### New
21+
22+
- For the time being, this repository is kept private. Will be open-sourced later.
23+
- First release, with scripted release support.
1824
- Basic functionalities, generate UP migration only.
1925
- flag `-version` reports the git commit.
2026

README.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Terravalet
22

3-
A tool to help with certain [Terraform](https://www.terraform.io/) operations.
3+
A tool to help with some [Terraform](https://www.terraform.io/) operations.
44

55
For the time being it generates state migration scripts that work also for Terraform workspaces. The idea of migrations comes from the excellent [tfmigrate](https://github.com/minamijoyo/tfmigrate).
66

7-
# Status
7+
## Status
88

99
This is BETA code, although we already use it in production. The instructions provide also ways to manually recover, but be careful and ensure you UNDERSTAND what you are doing if you use it for something important!
1010

1111
You have been warned.
1212

1313
The API can change in breaking ways until we reach v1.0.0
1414

15-
# Usage
15+
## Usage
1616

1717
Collect informations for Terravalet:
1818

@@ -21,7 +21,7 @@ $ cd $ROOT_MODULE_DIR
2121
$ terraform plan -no-color 2>&1 | tee ~/work/plan-01.txt
2222
```
2323

24-
## Current
24+
### Current
2525

2626
Generate a script with local state.
2727
Running this script will NOT change the remote source state.
@@ -30,7 +30,7 @@ Running this script will NOT change the remote source state.
3030
$ terravalet ~/work/plan-01.txt ../migrations/001_$TITLE.up.sh
3131
```
3232

33-
## Upcoming
33+
### Upcoming
3434

3535
Take as input the Terraform plan `~/work/plan-01.txt` and generate two migration scripts with prefix `../migrations/001_TITLE`:
3636
- `../migrations/001_TITLE.up.sh`
@@ -42,9 +42,14 @@ $ terravalet -scripts=../migrations/001_TITLE -plan=~/work/plan-01.txt
4242

4343
NOTE: It us up to the user to ensure that the migration number is correct with respect to what is already present in the migration directory.
4444

45-
# Install
45+
## Install
4646

47-
## Install from source
47+
### Install from binary package
48+
49+
1. Download the archive for your platform from the [releases page](https://github.com/Pix4D/terravalet/releases).
50+
2. Unarchive and copy the `terravalet` executable somewhere in your `$PATH`. I like to use `$HOME/bin/`.
51+
52+
### Install from source
4853

4954
1. Install [Go](https://golang.org/).
5055
2. Install [task](https://taskfile.dev/).
@@ -54,6 +59,33 @@ NOTE: It us up to the user to ensure that the migration number is correct with r
5459
```
5560
4. Copy the executable `bin/terravalet` to a directory in your `$PATH`. I like to use `$HOME/bin/`.
5661

57-
# License
62+
## Making a release
63+
64+
### Setup
65+
66+
1. Install [github-release](https://github.com/github-release/github-release).
67+
2. Install [gopass](https://github.com/gopasspw/gopass) or equivalent.
68+
2. Configure a GitHub token.
69+
2.1 Go to [Personal Access tokens](https://github.com/settings/tokens)
70+
2.2 Click on "Generate new token"
71+
2.3 Select only the `repo` scope
72+
3. Store the token securely with a tool like `gopass`. The name `GITHUB_TOKEN` is expected by `github-release`
73+
```
74+
$ gopass insert gh/terravalet/GITHUB_TOKEN
75+
```
76+
77+
### Each time
78+
79+
1. Update [CHANGELOG](CHANGELOG.md)
80+
2. Update this README and/or additional documentation.
81+
3. Commit and push.
82+
4. Begin the release process with
83+
```
84+
$ env RELEASE_TAG=v0.1.0 gopass env gh/terravalet task release
85+
```
86+
5. Finish the release process by following the instructions printed by `task` above.
87+
6. To recover from a half-baked release, see the hints in the [Taskfile](Taskfile.yml).
88+
89+
## License
5890

5991
This code is released under the MIT license, see file [LICENSE](LICENSE).

Taskfile.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,77 @@ tasks:
3434
sh: which gotestsum 2> /dev/null; true
3535
TESTRUNNER: "{{if .GOTESTSUM}}{{.GOTESTSUM}}{{else}}go test{{end}}"
3636

37+
#
38+
# usage: env RELEASE_TAG=v0.1.0 gopass task release
39+
#
40+
release:
41+
desc: Build a release and upload to GitHub as draft. You need to transition
42+
from draft to published in the web UI.
43+
preconditions:
44+
- sh: test -n "$RELEASE_TAG"
45+
msg: "error: missing environment variable RELEASE_TAG"
46+
- sh: test -z $(git status --porcelain)
47+
msg: "error: git dirty"
48+
- sh: test -z $(git status --branch --porcelain | grep ahead)
49+
msg: "error: git local branch ahead"
50+
cmds:
51+
# - task: unit-test
52+
# We create the (local) git tag now, after having ran the unit tests and
53+
# before building the executables, so that we can embed this information
54+
# in the binaries.
55+
# To recover: delete local tag: git tag --delete tagname
56+
- git tag -a {{.RELEASE_TAG}} -m ''
57+
- task: release-linux
58+
- task: release-darwin
59+
# - task: system-test
60+
- task: test
61+
# We create the release as a draft (that is: not visible to the public).
62+
# The act of "publishing" the release is left to a human from the web UI.
63+
- >
64+
github-release release
65+
--tag {{.RELEASE_TAG}}
66+
--draft
67+
--description
68+
"See the [CHANGELOG](https://github.com/$GITHUB_USER/$GITHUB_REPO/blob/{{.RELEASE_TAG}}/CHANGELOG.md)"
69+
# Upload the artifacts.
70+
- >
71+
github-release upload
72+
--tag {{.RELEASE_TAG}}
73+
--name terravalet-linux-amd64.zip
74+
--file bin/linux/terravalet-linux-amd64.zip
75+
- >
76+
github-release upload
77+
--tag {{.RELEASE_TAG}}
78+
--name terravalet-darwin-amd64.zip
79+
--file bin/darwin/terravalet-darwin-amd64.zip
80+
# We don't push the git tag. Instead, in the web UI, the act of
81+
# transitioning the release from draft to published will create the
82+
# corresponding tag in the remote repository. This is safer, because it
83+
# reduces the situations when one might be tempted to delete a public tag
84+
# due to a mistake in the release.
85+
- cmd: |
86+
echo "Draft release $RELEASE_TAG created successfully."
87+
echo "Remember to publish it in the GitHub web UI https://github.com/$GITHUB_USER/$GITHUB_REPO/releases"
88+
silent: true
89+
env:
90+
GITHUB_USER: pix4d
91+
GITHUB_REPO: terravalet
92+
# GITHUB_TOKEN expected to be set securely via `gopass` or equivalent
93+
release-linux:
94+
dir: bin/linux
95+
cmds: &release-cmds
96+
- go build -v -ldflags="{{.LDFLAGS}}" ../..
97+
- zip terravalet-$GOOS-$GOARCH.zip terravalet
98+
env:
99+
CGO_ENABLED: 0
100+
GOOS: linux
101+
GOARCH: amd64
102+
vars: *build-vars
103+
release-darwin:
104+
dir: bin/darwin
105+
cmds: *release-cmds
106+
env:
107+
CGO_ENABLED: 0
108+
GOOS: darwin
109+
GOARCH: amd64
110+
vars: *build-vars

0 commit comments

Comments
 (0)