Skip to content

Commit

Permalink
Merge pull request #7 from vapor-ware/etd-packaging
Browse files Browse the repository at this point in the history
update the packaging/release flow
  • Loading branch information
edaniszewski authored Nov 9, 2017
2 parents 5cd5d62 + a25bc5a commit 1409f2f
Show file tree
Hide file tree
Showing 11 changed files with 354 additions and 168 deletions.
73 changes: 8 additions & 65 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,77 +2,20 @@
# Make GRPC client/server source files for the target languages
# -------------------------------------------------------------

python: ## Build the GRPC source for Python
docker run \
-v `pwd`:/build \
grpc/python:1.4 \
python3 -m grpc_tools.protoc -I/build \
--python_out=/build/python/synse_plugin \
--grpc_python_out=/build/python/synse_plugin \
/build/synse.proto && \
sed -i -e 's/import synse_pb2 as synse__pb2/from . import synse_pb2 as synse__pb2/g' python/synse_plugin/synse_pb2_grpc.py && \
if [ -f "python/synse_plugin/synse_pb2_grpc.py-e" ]; then rm python/synse_plugin/synse_pb2_grpc.py-e; fi;
# Make targets are organized by functionality in the 'make' subdirectory
include make/build.make
include make/github.make
include make/pip.make

PKG_VER := $(shell python python/version.py)


go: ## Build the GRPC source for Go
docker run \
-v `pwd`:/build \
grpc/go:1.0 \
protoc -I /build /build/synse.proto --go_out=plugins=grpc:/build/go


all: python go ## Build source for all supported languages



# Packaging for Python

# this currently goes on the assumption that python 2 is run via the `python`
# binary, and python3 is run by the `python3` binary. this is not the best way
# of doing this, but it is a start.
HAS_PY2 := $(shell command -v python)
HAS_PY3 := $(shell command -v python3)


pip-package: ## Package the python package into a tarball
cd python ; python setup.py sdist


pip-install: ## Install the python package from tarball
ifdef HAS_PY2
cd python ; pip install dist/synse_plugin-*.tar.gz
endif
ifdef HAS_PY3
cd python ; pip3 install dist/synse_plugin-*.tar.gz
endif


pip-einstall: ## Install the python package in editable mode
ifdef HAS_PY2
pip install -I -e ./python
endif
ifdef HAS_PY3
pip3 install -I -e ./python
endif


pip-uninstall: ## Uninstall the synse_plugin package via pip
ifdef HAS_PY2
cd python ; pip uninstall -y synse_plugin
endif
ifdef HAS_PY3
cd python ; pip3 uninstall -y synse_plugin
endif


pip-clean: ## Remove the python packaging build artifacts
cd python ; rm -rf build dist synse_plugin.egg-info

version: ## Print the current version of Synse Server gRPC
@echo "$(PKG_VER)"

help: ## Print usage information
@awk 'BEGIN {FS = ":.*?## "} /^[0-9a-zA-Z_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort


.PHONY: all go help python pip-package pip-install pip-einstall pip-uninstall pip-clean
.PHONY: help version
.DEFAULT_GOAL := help
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,42 @@ make pip-uninstall
make pip-clean
```

## Releasing
To release a new version of Synse Server gRPC, you must have the correct permissions on the repo.
Assuming that you do, a few steps need to be taken. First, you need to know what version number is
to be released. Ideally, this should already be checked in to the repo. The version is currently
defined in `python/synse_plugin/__init__.py` under the `__version__` variable.

The version can be verified by running
```bash
make version
```

Then, clean out any of the previously build packages which may exist.
```bash
make pip-clean
```

Next, rebuild the packages. Make sure that the repo is up to date prior to this.
```bash
make pip-package
```

This should create the `python/dist` directory which contains a tarball with the version
number in the tarball name.

Finally, run
```bash
make release-github
```

This will build a docker image that will install `hub` and create a new release draft under
the specified version. It will include the python package tarball in the release distribution.

Once that is done, you can go to the [GitHub release page](release-page) and should see that a new release
draft was created. You can then edit this draft and publish it.


## Troubleshooting
To see a list of available make targets and a brief description, use
```bash
Expand All @@ -108,4 +144,5 @@ as much context around the bug/issue as possible.



[api-spec]: https://github.com/vapor-ware/synse-server-grpc/blob/master/synse.proto
[api-spec]: https://github.com/vapor-ware/synse-server-grpc/blob/master/synse.proto
[release-page]: https://github.com/vapor-ware/synse-server-grpc/releases
15 changes: 15 additions & 0 deletions dockerfile/hub.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM debian:wheezy-slim

RUN apt-get update && apt-get install --no-install-recommends -y \
git ca-certificates && \
rm -rf /var/lib/apt/lists/*

ADD https://github.com/github/hub/releases/download/v2.3.0-pre10/hub-linux-amd64-2.3.0-pre10.tgz /tmp
RUN cd /tmp \
&& tar xzf /tmp/*.tgz \
&& /bin/bash /tmp/hub*/install \
&& rm -rf /tmp/*

WORKDIR /data

ENTRYPOINT ["/usr/local/bin/hub"]
158 changes: 98 additions & 60 deletions go/synse.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions make/build.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

python: ## Build the GRPC source for Python
@printf "Generating Python source."
@docker run \
-v `pwd`:/build \
grpc/python:1.4 \
python3 -m grpc_tools.protoc -I/build \
--python_out=/build/python/synse_plugin \
--grpc_python_out=/build/python/synse_plugin \
/build/synse.proto && \
sed -i -e 's/import synse_pb2 as synse__pb2/from . import synse_pb2 as synse__pb2/g' python/synse_plugin/synse_pb2_grpc.py && \
if [ -f "python/synse_plugin/synse_pb2_grpc.py-e" ]; then rm python/synse_plugin/synse_pb2_grpc.py-e; fi;
@printf " [done]\n"



go: ## Build the GRPC source for Go
@printf "Generating Go source."
@docker run \
-v `pwd`:/build \
grpc/go:1.0 \
protoc -I /build /build/synse.proto --go_out=plugins=grpc:/build/go
@printf " [done]\n"


all: python go ## Build source for all supported languages


.PHONY: all go python
Loading

0 comments on commit 1409f2f

Please sign in to comment.