Skip to content

Commit

Permalink
Add release generation process
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev committed Mar 7, 2019
1 parent c6a7472 commit aee4d60
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ clientcompat/pycompat/ENV
build

npm-debug.log

/release
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ Twirp uses Github releases. To make a new release:
3. Add a new commit to master with a message like "Version vX.X.X release".
4. Tag the commit you just made: `git tag <version number>` and `git push
origin --tags`
5. Go to Github https://github.com/twitchtv/twirp/releases and
5. Run `make release_gen` to generate release assets in the `release`
directory. This requires Docker to be installed.
6. Go to Github https://github.com/twitchtv/twirp/releases and
"Draft a new release".
6. Make sure to document changes, specially when upgrade instructions are
7. Make sure to document changes, specially when upgrade instructions are
needed.
8. Upload all files in the `release` directory as part of the release.


## Code of Conduct
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
RETOOL=$(CURDIR)/_tools/bin/retool
PATH := ${PWD}/bin:${PWD}/ENV/bin:${PATH}
DOCKER_RELEASE_IMAGE := golang:1.12.0-stretch
.DEFAULT_GOAL := all

all: setup test_all

.PHONY: test test_all test_core test_clients test_go_client test_python_client generate
.PHONY: test test_all test_core test_clients test_go_client test_python_client generate release_gen

# Phony commands:
generate:
Expand All @@ -30,6 +31,14 @@ setup:
GOPATH=$(CURDIR)/_tools go install github.com/twitchtv/retool/...
$(RETOOL) build

release_gen:
git clean -xdf
docker run \
--volume "$(CURDIR):/go/src/github.com/twitchtv/twirp" \
--workdir "/go/src/github.com/twitchtv/twirp" \
$(DOCKER_RELEASE_IMAGE) \
internal/release_gen.sh

# Actual files for testing clients:
./build:
mkdir build
Expand Down
50 changes: 50 additions & 0 deletions internal/release_gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash

set -euo pipefail

DIR="$(cd "$(dirname "${0}")/.." && pwd)"
cd "${DIR}"

goos() {
case "${1}" in
Darwin) echo darwin ;;
Linux) echo linux ;;
*) return 1 ;;
esac
}

goarch() {
case "${1}" in
x86_64) echo amd64 ;;
*) return 1 ;;
esac
}

sha256() {
if ! type sha256sum >/dev/null 2>/dev/null; then
if ! type shasum >/dev/null 2>/dev/null; then
fail "sha256sum and shasum are not installed"
return 1
else
shasum -a 256 "$@"
fi
else
sha256sum "$@"
fi
}

RELEASE_DIR="release"

rm -rf "${RELEASE_DIR}"
for os in Darwin Linux; do
for arch in x86_64; do
for binary_name in protoc-gen-twirp protoc-gen-twirp_python; do
BINARY="${RELEASE_DIR}/${binary_name}-${os}-${arch}"
CGO_ENABLED=0 GOOS=$(goos "${os}") GOARCH=$(goarch "${arch}") \
go build -a -installsuffix cgo -o "${BINARY}" \
$(find "${binary_name}" -name '*.go')
sha256 "${BINARY}" > "${BINARY}.sha256sum"
sha256 -c "${BINARY}.sha256sum"
done
done
done

0 comments on commit aee4d60

Please sign in to comment.