-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
TAG := $(shell git describe --tags) | ||
LAST_TAG := $(shell git describe --tags --abbrev=0) | ||
NEW_TAG := $(shell echo $(LAST_TAG) | perl -lpe 's/v//; $$_ += 0.01; $$_ = sprintf("v%.2f", $$_)') | ||
|
||
snapshot-manager: | ||
@go version | ||
go install -v ./... | ||
|
||
test: snapshot-manager | ||
go test ./... | ||
|
||
doc: snapshot-manager.1 README.html README.txt | ||
|
||
snapshot-manager.1: README.md Makefile | ||
pandoc -M "title=SNAPSHOT-MANAGER(1)" -M "date="`date -Id` -M "author=Memset Ltd" -s --from markdown --to man README.md -o snapshot-manager.1 | ||
|
||
README.html: README.md Makefile | ||
pandoc -s --from markdown_github --to html README.md -o README.html | ||
|
||
README.txt: README.md Makefile | ||
pandoc -s --from markdown_github --to plain README.md -o README.txt | ||
|
||
install: snapshot-manager | ||
install -d ${DESTDIR}/usr/bin | ||
install -t ${DESTDIR}/usr/bin ${GOPATH}/bin/snapshot-manager | ||
|
||
clean: | ||
go clean ./... | ||
find . -name \*~ | xargs -r rm -f | ||
rm -rf build | ||
rm -f snapshot-manager snapshot-manager.1 README.html README.txt | ||
|
||
.PHONY: upload | ||
|
||
upload: | ||
./upload $(TAG) | ||
|
||
cross: doc | ||
./cross-compile $(TAG) | ||
|
||
tag: | ||
@echo "Old tag is $(LAST_TAG)" | ||
@echo "New tag is $(NEW_TAG)" | ||
echo -e "package main\n const Version = \"$(NEW_TAG)\"\n" | gofmt > version.go | ||
git tag $(NEW_TAG) | ||
@echo "Add this to changelog in README.md" | ||
@echo " * $(NEW_TAG) -" `date -I` | ||
@git log $(LAST_TAG)..$(NEW_TAG) --oneline | ||
@echo "Then commit the changes" | ||
@echo git commit -m "Version $(NEW_TAG)" -a -v | ||
@echo "And finally run make retag before make cross etc" | ||
|
||
retag: | ||
git tag -f $(LAST_TAG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Required software for making a release | ||
* [github-release](https://github.com/aktau/github-release) for uploading packages | ||
* [gox](https://github.com/mitchellh/gox) for cross compiling | ||
* Run `gox -build-toolchain` | ||
* This assumes you have your own source checkout | ||
* pandoc for making the html and man pages | ||
|
||
Making a release | ||
* go get -u -f -v ./... | ||
* make test | ||
* make tag | ||
* edit README.md | ||
* git commit version.go README.md | ||
* make retag | ||
* # Set the GOPATH for a gox enabled compiler | ||
* make cross | ||
* make upload | ||
* git push --tags origin master | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# This uses gox from https://github.com/mitchellh/gox | ||
# Make sure you've run gox -build-toolchain | ||
|
||
if [ "$1" == "" ]; then | ||
echo "Syntax: $0 Version" | ||
exit 1 | ||
fi | ||
VERSION="$1" | ||
|
||
rm -rf build | ||
|
||
gox -output "build/{{.Dir}}-${VERSION}-{{.OS}}-{{.Arch}}/{{.Dir}}" | ||
|
||
mv build/snapshot-manager-${VERSION}-darwin-amd64 build/snapshot-manager-${VERSION}-osx-amd64 | ||
mv build/snapshot-manager-${VERSION}-darwin-386 build/snapshot-manager-${VERSION}-osx-386 | ||
|
||
cd build | ||
|
||
for d in `ls`; do | ||
cp -a ../README.txt $d/ | ||
cp -a ../README.html $d/ | ||
cp -a ../snapshot-manager.1 $d/ | ||
zip -r9 $d.zip $d | ||
rm -rf $d | ||
done | ||
|
||
cd .. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/bin/bash | ||
# | ||
# Upload a release | ||
|
||
set -e | ||
|
||
REPO="snapshot-manager" | ||
|
||
if [ "$1" == "" ]; then | ||
echo "Syntax: $0 Version" | ||
exit 1 | ||
fi | ||
VERSION="$1" | ||
if [ "$GITHUB_USER" == "" ]; then | ||
echo 1>&2 "Need GITHUB_USER environment variable" | ||
exit 1 | ||
fi | ||
if [ "$GITHUB_TOKEN" == "" ]; then | ||
echo 1>&2 "Need GITHUB_TOKEN environment variable" | ||
exit 1 | ||
fi | ||
|
||
echo "Making release ${VERSION}" | ||
github-release release \ | ||
--repo ${REPO} \ | ||
--tag ${VERSION} \ | ||
--name "Snapshot Manager" \ | ||
--description "Tool to upload and download Memset snapshots" | ||
|
||
for build in `ls build`; do | ||
echo "Uploading ${build}" | ||
base="${build%.*}" | ||
parts=(${base//-/ }) | ||
os=${parts[3]} | ||
arch=${parts[4]} | ||
|
||
github-release upload \ | ||
--repo ${REPO} \ | ||
--tag ${VERSION} \ | ||
--name "${build}" \ | ||
--file build/${build} | ||
done | ||
|
||
github-release info \ | ||
--repo ${REPO} \ | ||
--tag ${VERSION} | ||
|
||
echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package main | ||
|
||
const Version = "v1.00" |