Skip to content

Commit

Permalink
Updated makefile to build CHECKSUMS per joewalnes#101
Browse files Browse the repository at this point in the history
  • Loading branch information
asergeyev committed Feb 16, 2015
1 parent 6c6756f commit bfcb2ed
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 45 deletions.
66 changes: 43 additions & 23 deletions release/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ FLAGS_windows_amd64 = $(FLAGS_all) GOOS=windows GOARCH=amd64 CGO_ENABLED=0
EXTENSION_windows_386=.exe
EXTENSION_windows_amd64=.exe

msg=@/bin/echo -e "\x1b[33;01m>>> $1\x1b[0m"

all: build deb rpm
all: build
.PHONY: all

go-path/src/github.com/joewalnes/websocketd:
go-path/src/github.com/joewalnes/websocketd: ../*.go ../libwebsocketd/*.go
rm -f $@
mkdir -p go-path/src/github.com/joewalnes
ln -s ../../../../../ go-path/src/github.com/joewalnes/websocketd
cd go-path/src/github.com/joewalnes && ln -s ../../../../../ websocketd


# Download Go source code
$(GO_DOWNLOAD):
Expand All @@ -63,7 +63,6 @@ $(GO_DOWNLOAD):
go-download: $(GO_DOWNLOAD)
.PHONY: go-download


# Unpack Go source code
$(GO_UNPACKED): $(GO_DOWNLOAD)
$(call msg,"Unpacking Go $(GO_VERSION)")
Expand All @@ -78,40 +77,56 @@ go-unpack: $(GO_UNPACKED)

# Cross-compile Go package for target platform
$(GO_DIR)/go/pkg/%/.built: $(GO_UNPACKED)
rm -rf gopath/pkg/$*
$(call msg,"Building Go for $*")
cd $(GO_DIR)/go/src && $(FLAGS_$*) ./make.bash --no-clean >/dev/null 2>&1
touch $@
cd $(GO_DIR)/go/src && $(FLAGS_$*) ./make.bash --no-clean >lastbuild.log 2>&1
touch $(GO_DIR)/go/pkg/$*/.built

go-compile: $(foreach PLATFORM,$(PLATFORMS),$(GO_DIR)/go/pkg/$(PLATFORM)/.built)
.PHONY: go-compile


# Cross-compile final applications
out/$(RELEASE_VERSION)/%/websocketd: $(GO_DIR)/go/pkg/%/.built $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd
out/$(RELEASE_VERSION)/%/websocketd out/$(RELEASE_VERSION)/%/websocketd.exe: $(GO_DIR)/go/pkg/%/.built $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd
$(call msg,"Compiling release for $*")
rm -f $@
mkdir -p $(dir $@)
$(FLAGS_$*) $(GO_DIR)/go/bin/go get ./go-path/src/github.com/joewalnes/websocketd
go get golang.org/x/net/websocket
go test github.com/joewalnes/websocketd/libwebsocketd
$(FLAGS_$*) $(GO_DIR)/go/bin/go build -ldflags "-X main.version $(RELEASE_VERSION)" -o out/$(RELEASE_VERSION)/$*/websocketd$(EXTENSION_$*) $(wildcard ../*.go)
touch $@

out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-%.zip: out/$(RELEASE_VERSION)/%/websocketd $(wildcard ../*.go) go-path/src/github.com/joewalnes/websocketd
rm -f $@
zip -j $@ out/$(RELEASE_VERSION)/$*/* ../{INSTALL,README.md,LICENSE}
zip -j $@ out/$(RELEASE_VERSION)/$*/* ../{README.md,LICENSE}


build: $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/websocketd) $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-$(PLATFORM).zip)
BINARIES = $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/$(PLATFORM)/websocketd$(EXTENSION_$(PLATFORM)))
ZIPS = $(foreach PLATFORM,$(PLATFORMS),out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)-$(PLATFORM).zip)
DEBS = out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb
RPMS = out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).i386.rpm out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).x86_64.rpm

binaries: $(BINARIES)
.PHONY: websocketd

build: out/$(RELEASE_VERSION)/CHECKSUMS
.PHONY: build

out/$(RELEASE_VERSION)/CHECKSUMS: $(BINARIES) $(ZIPS) $(DEBS) $(RPMS)
sha256sum $^ | sed -e 's/out\/$(RELEASE_VERSION)\///' >$@



BASEFPM=--description "WebSockets server that converts STDIO scripts to powerful HTML5 applications." --url http://websocketd.com/ --license MIT --vendor "websocketd team <joe@walnes.com>" --maintainer "abc@alexsergeyev.com"

DEBFPM=""
RPMFPM=--rpm-os linux

deb: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb
deb: $(DEBS)
.PHONY: deb

rpm: out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).x86_64.rpm
rpm: $(RPMS)
.PHONY: rpm


out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_386.deb: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd
Expand All @@ -130,15 +145,15 @@ out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION)_amd64.deb: $(GO_DIR)/go/pk
fpm -f -s dir -t deb -a amd64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/deb64/ -p out/$(RELEASE_VERSION)/websocketd-VERSION_ARCH.deb $(BASEFPM) $(DEB_FPM) usr/
rm -rf out/$(RELEASE_VERSION)/deb64/

out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).x86_64.rpm: $(GO_DIR)/go/pkg/linux_amd64/.built out/$(RELEASE_VERSION)/linux_amd64/websocketd
out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).x86_64.rpm: $(GO_DIR)/go/pkg/linux_amd64/.built out/$(RELEASE_VERSION)/linux_amd64/websocketd
mkdir -p out/$(RELEASE_VERSION)/rpm64/{usr/bin,etc/default,usr/libexec,usr/share/man/man1,usr/share/doc/websocketd-$(RELEASE_VERSION),usr/lib/systemd/system}
cp out/$(RELEASE_VERSION)/linux_amd64/websocketd out/$(RELEASE_VERSION)/rpm64/usr/bin/
cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/rpm64/usr/share/doc/websocketd-$(RELEASE_VERSION)
cat websocketd.man | gzip > out/$(RELEASE_VERSION)/rpm64/usr/share/man/man1/websocket.1.gz
fpm -f -s dir -t rpm -a x86_64 -n websocketd -v $(RELEASE_VERSION) -C out/$(RELEASE_VERSION)/rpm64/ -p out/$(RELEASE_VERSION)/websocketd.VERSION.ARCH.rpm $(BASEFPM) $(RPMFPM) usr/
rm -rf out/$(RELEASE_VERSION)/rpm64/

out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd
out/$(RELEASE_VERSION)/websocketd.$(RELEASE_VERSION).i386.rpm: $(GO_DIR)/go/pkg/linux_386/.built out/$(RELEASE_VERSION)/linux_386/websocketd
mkdir -p out/$(RELEASE_VERSION)/rpm32/{usr/bin,etc/default,usr/libexec,usr/share/man/man1,usr/share/doc/websocketd-$(RELEASE_VERSION),usr/lib/systemd/system}
cp out/$(RELEASE_VERSION)/linux_386/websocketd out/$(RELEASE_VERSION)/rpm32/usr/bin/
cp ../{LICENSE,AUTHORS,README.md} out/$(RELEASE_VERSION)/rpm32/usr/share/doc/websocketd-$(RELEASE_VERSION)
Expand All @@ -147,14 +162,19 @@ out/$(RELEASE_VERSION)/websocketd-$(RELEASE_VERSION).i386.rpm: $(GO_DIR)/go/pkg/
rm -rf out/$(RELEASE_VERSION)/rpm32/




# Clean up
clean:
rm -rf out go-path
.PHONY: clean
clobber: clean
.PHONY: clobber

clean: clean-go clean-out
.PHONY: clean

clobber: clean
clean-go:
rm -rf go-local
.PHONY: clobber
rm -rf go-path
.PHONY: clean-go

clean-out:
rm -rf out
.PHONY: clean-out

57 changes: 35 additions & 22 deletions release/README
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
Release scripts for websocketd
==============================

Perform a fully automated repeatable release of websocketd. Including:
Perform a fully automated repeatable release of websocketd.

* Downloading the correct version of Go
* Cross-compiling Go for all required platforms
* Inferring the next websocketd release version
* Cross-compiling websocketd for all required platforms
* Uploading releases to http://download.websocketd.com/
* Git tagging the version
This is three-stage process in normal release cycle that's performed by
repository maintainers.

The release process has been built and test on Ubuntu.
* Tag
* Build
* Release

Pre-reqs:
Those that do not have permissions to push tags could still use this build
chain to build their own customized versions or packages.

sudo apt-get install libc6-dev-i386 s3cmd git mercurial
s3cmd --configure # Setup Amazon S3 credentials
## Step 1: Tag

The actual Go release will be downloaded and cross-compiled. All compilation
occurs in an isolated environment to ensure there are no conflicts with any
system install Go. The first build will be really slow (cross compiling Go core),
but subsequent builds are incremental.
Annotated tags require for release:

To build the packages for all platforms:
git tag -a vx.x.x

make build
To see currently tagged version run tag with -l option.

To perform a release to http://download.websocketd.com/
(version number will be automatically determined based on last git tag):
## Step 2: Build

release/Makefile contains all required to download pre-verified for build release of Go and cross-compile
websocketd for all platforms that we release for.

cd release
make

To clean up:
Is generally recommended but other build options are available:

* go-compile: build cross-platform golang pakages
* binaries: only create websocketd binaries, do not generate zip distributions
* deb, rpm: only create particular kind of packages
* clean-go: remove build files for go
* clean-out: remove built binaries, zip and linux packages
* clean: remove everything (go and release files)

Building requires to have gcc and other build tools installed. Building rpm/deb files would fail without fpm ("gem install fpm" itself requires ruby devel tools).

## Step 3: Release

In order to make release official following steps required:

# push tags (assuming joewalnes repo is origin):
go push --tags origin master:master

make clean
Upload files to github release (to be automated). Use these instructions for now: https://github.com/blog/1547-release-your-software


-Joe Walnes

0 comments on commit bfcb2ed

Please sign in to comment.