-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build the binaries on our own #15
Changes from all commits
3d039d8
44ab3fd
54054d0
74496ba
f2f7e97
84c32f3
55b1844
2ddcdc9
72acba8
c356c46
4052254
f599fdf
f6e1358
196688e
836d6c3
3bdd8f0
2a85a36
afdd7ed
3b6c402
07052fd
a295ba2
2b3b5b5
05054ce
27f7e00
30076b1
faebb8d
aa8d8eb
168989e
8cb7d6f
ba5e4aa
a7c59a9
e321ea2
77af6da
64bb28d
c4b71b7
c8ccbd2
b8dd155
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ logs | |
**/node_modules | ||
releases | ||
dists/ipfs-app/build | ||
www | ||
**/gopath | ||
**/tmp-build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: node_js | ||
node_js: | ||
- '4' | ||
- '5' | ||
- stable | ||
|
||
script: | ||
- npm run lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,17 @@ | ||
all: all_dists index | ||
all: all_dists site | ||
|
||
all_dists: go-ipfs | ||
all_dists: go-ipfs ipfs-update fs-repo-migrations | ||
|
||
ipfs-app: | ||
echo "** making $@ **" | ||
%: | ||
echo "** $@ **" | ||
cd dists/$@ && make | ||
|
||
go-ipfs: | ||
echo "** making $@ **" | ||
cd dists/$@ && make | ||
|
||
index: | ||
echo "** making index.html **" | ||
node gen-index.js >releases/index.html | ||
cp -r static releases/. | ||
site: | ||
echo "** Building site **" | ||
npm run build | ||
|
||
publish: all_dists index | ||
publish: all_dists site | ||
ipfs add -s rabin -q -r releases | tail -n1 >>versions | ||
|
||
clean: | ||
rm -rf releases |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
#!/bin/bash | ||
|
||
# globals | ||
releases=../../releases | ||
|
||
# init colors | ||
txtnon='\e[0m' # color reset | ||
txtred='\e[0;31m' # Red | ||
txtgrn='\e[0;32m' # Green | ||
txtylw='\e[0;33m' # Yellow | ||
|
||
function fail() { | ||
printf $txtred%s$txtnon\\n "$@" | ||
exit 1 | ||
} | ||
|
||
function warn() { | ||
printf $txtylw%s$txtnon\\n "$@" | ||
} | ||
|
||
function notice() { | ||
printf $txtgrn%s$txtnon\\n "$@" | ||
} | ||
|
||
# dep checks | ||
reqbins="jq zip go" | ||
for b in $reqbins | ||
do | ||
if ! type $b > /dev/null; then | ||
fail "must have '$b' installed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Install with a makefile and gx (or ipget)? (we can leave this for a future PR) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah... jq i normally install with npm, zip with my package manager, and go from source. It would be nice to just be able to download them in the script if needed, but this is really just code that we're going to use internally (at least for now) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to have a note about how to install them in the readme. (No idea where and what jq is) |
||
fi | ||
done | ||
|
||
function printDistInfo() { | ||
# print json output | ||
jq -e ".platforms[\"$goos\"]" dist.json > /dev/null | ||
if [ ! $? -eq 0 ]; then | ||
cp dist.json dist.json.temp | ||
jq ".platforms[\"$goos\"] = {\"name\":\"$goos Binary\",\"archs\":{}}" dist.json.temp > dist.json | ||
fi | ||
|
||
local binname="$1" | ||
cp dist.json dist.json.temp | ||
jq ".platforms[\"$goos\"].archs[\"$goarch\"] = {\"link\":\"$goos-$goarch/$binname.zip\"}" dist.json.temp > dist.json | ||
rm dist.json.temp | ||
} | ||
|
||
function doBuild() { | ||
local goos=$1 | ||
local goarch=$2 | ||
local target=$3 | ||
local output=$4 | ||
|
||
echo "==> building for $goos $goarch" | ||
|
||
dir=$output/$1-$2 | ||
if [ -e $dir ]; then | ||
echo " $dir exists, skipping build" | ||
return | ||
fi | ||
echo " output to $dir" | ||
|
||
mkdir -p tmp-build | ||
|
||
(cd tmp-build && GOOS=$goos GOARCH=$goarch go build $target 2> build-log) | ||
if [ $? -ne 0 ]; then | ||
warn " failed." | ||
return 1 | ||
fi | ||
|
||
notice " build succeeded!" | ||
|
||
# copy dist assets if they exist | ||
if [ -e $GOPATH/src/$target/dist ]; then | ||
cp -r $GOPATH/src/$target/dist/* tmp-build/ | ||
fi | ||
|
||
# now zip it all up | ||
local binname=$(basename $target) | ||
mkdir -p $dir | ||
if zip -r $dir/$binname.zip tmp-build/* > /dev/null; then | ||
printDistInfo $binname | ||
rm -rf tmp-build | ||
else | ||
warn " failed to zip up output" | ||
success=1 | ||
fi | ||
|
||
|
||
# output results to results table | ||
echo $target, $goos, $goarch, $success >> $output/results | ||
} | ||
|
||
function printInitialDistfile() { | ||
local distname=$1 | ||
local version=$2 | ||
test -e description || fail "no description file found" | ||
|
||
printf "{\"id\":\"$distname\",\"version\":\"$version\",\"releaseLink\":\"/$distname/$version\"}" | | ||
jq ".name = \"$disname\"" | | ||
jq ".platforms = {}" | | ||
jq ".description = \"`cat description`\"" | ||
} | ||
|
||
function printBuildInfo() { | ||
# print out build information | ||
local commit=$1 | ||
go version | ||
echo "git sha of code: $commit" | ||
uname -a | ||
echo built on `date` | ||
} | ||
|
||
function buildWithMatrix() { | ||
local matfile=$1 | ||
local gobin=$2 | ||
local output=$3 | ||
local commit=$4 | ||
|
||
test -n "$output" || fail "error: output dir not specified" | ||
test -e "$matfile" || fail "build matrix $matfile does not exist" | ||
|
||
mkdir -p "$output" | ||
|
||
local distname=$(basename `pwd`) | ||
|
||
printInitialDistfile $distname $version > dist.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok makes sense 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah... its kindof a weird hack because doing |
||
printBuildInfo $commit > $output/build-info | ||
|
||
# build each os/arch combo | ||
while read line | ||
do | ||
doBuild $line $gobin $output | ||
done < $matfile | ||
|
||
mv dist.json $output/dist.json | ||
} | ||
|
||
function cleanRepo() { | ||
local repopath=$1 | ||
|
||
reporoot=$(cd "$repopath" && git rev-parse --show-toplevel) | ||
(cd "$reporoot" && git clean -df) | ||
(cd "$reporoot" && git reset --hard) | ||
} | ||
|
||
function checkoutVersion() { | ||
local repopath=$1 | ||
local ref=$2 | ||
|
||
test -n "$repopath" || fail "checkoutVersion: no repo to check out specified" | ||
|
||
echo "==> checking out version $ref in $repopath" | ||
cleanRepo "$repopath" | ||
(cd "$repopath" && git checkout $ref > /dev/null) | ||
|
||
test $? -eq 0 || fail "failed to check out $ref in $reporoot" | ||
} | ||
|
||
function currentSha() { | ||
(cd $1 && git show --pretty="%H") | ||
} | ||
|
||
function printVersions() { | ||
versarr=$(tr \n ' ' < versions) | ||
echo "building versions: $versarr" | ||
} | ||
|
||
function startGoBuilds() { | ||
distname=$1 | ||
gpath=$2 | ||
|
||
outputDir="$releases/$distname" | ||
|
||
# if the output directory already exists, warn user | ||
if [ -e $outputDir ]; then | ||
warn "dirty output directory" | ||
warn "will skip building already existing binaries" | ||
fi | ||
|
||
export GOPATH=$(pwd)/gopath | ||
if [ ! -e $GOPATH/src/$gpath ]; then | ||
echo "fetching $distname code..." | ||
go get $gpath 2> /dev/null | ||
fi | ||
|
||
repopath="$GOPATH/src/$gpath" | ||
|
||
(cd "$repopath" && git reset --hard && git clean -df) | ||
|
||
printVersions | ||
|
||
echo "" | ||
while read version | ||
do | ||
notice "Building version $version binaries" | ||
checkoutVersion $repopath $version | ||
|
||
buildWithMatrix matrices/$version $gpath $outputDir/$version $(currentSha $repopath) | ||
echo "" | ||
done < versions | ||
|
||
notice "build complete!" | ||
} | ||
|
||
startGoBuilds $1 $2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
machine: | ||
node: | ||
version: stable | ||
|
||
test: | ||
override: | ||
- npm run lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
repo=http://github.com/ipfs/fs-repo-migrations | ||
releases=../../releases/fs-repo-migrations | ||
|
||
all: dist | ||
|
||
dist: versions | ||
mkdir -p $(releases) | ||
cp versions $(releases)/versions | ||
../../build-go.sh fs-repo-migrations github.com/ipfs/fs-repo-migrations | ||
|
||
versions: filtered_versions | ||
git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions | ||
comm -23 -- tag_versions filtered_versions > versions | ||
|
||
filtered_versions: | ||
touch filtered_versions | ||
|
||
clean: | ||
rm -rf ./gopath | ||
rm -rf $(releases) | ||
rm versions tag_versions | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fs-repo-migrations is a tool to help migration ipfs storage repos to newer versions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
darwin 386 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This applies for ipfs and other binaries as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, okay. I just picked a few that seemed reasonable, i'll remove it. But all of these binaries are supported by the go compiler. Which do you think should be kept? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hold on, i think we do need If the go team has it there still, it's there for a reason. Let's keep it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (to be clear, i understand that osx has been supposed to run only on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (there is also the possibility of suppressing it from the distributions page, if we think "almost all users wont need it and it will be confusing". i twill still be available in the version file listing itself) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mmkay, i left it in. |
||
darwin amd64 | ||
freebsd 386 | ||
freebsd amd64 | ||
freebsd arm | ||
linux 386 | ||
linux amd64 | ||
linux arm | ||
windows 386 | ||
windows amd64 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v1.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gopath/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,16 @@ | ||
repo = http://github.com/ipfs/go-ipfs | ||
gpath = github.com/ipfs/go-ipfs/cmd/ipfs | ||
releases = ../../releases/go-ipfs | ||
gbcli = $(shell which gobuilder-cli) | ||
|
||
all: dist | ||
|
||
dist: versions deps | ||
dist: versions | ||
mkdir -p $(releases) | ||
cp versions $(releases)/versions | ||
./go-ipfs-dist all | ||
../../build-go.sh go-ipfs github.com/ipfs/go-ipfs/cmd/ipfs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretty sweet! 👍 😄 |
||
|
||
versions: filtered_versions | ||
git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' > tag_versions | ||
cat tag_versions | grep -f filtered_versions -vE > versions | ||
git ls-remote -t $(repo) | egrep -o "refs/tags/v(.*)" | sed 's/refs\/tags\///' | sort > tag_versions | ||
comm -23 -- tag_versions filtered_versions > versions | ||
|
||
deps: bin bin/gobuilder-cli go-ipfs-dist-x | ||
|
||
bin: | ||
@mkdir -p bin | ||
|
||
go-ipfs-dist-x: | ||
chmod +x go-ipfs-dist | ||
|
||
bin/gobuilder-cli: bin | ||
#TODO: make this not require a go compiler... | ||
go get github.com/Luzifer/gobuilder/cmd/gobuilder-cli | ||
cp $(gbcli) bin/gobuilder-cli | ||
|
||
# bin/go-env: | ||
# ipfs get -o bin/go-env QmfS4PZj7G7KgAztPN3JxXyY6KHJDZ77EaxzocWqsa3XhQ/go-env | ||
# chmox +x bin/go-env | ||
clean: | ||
rm -rf $(releases) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v0.3.11 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
go-ipfs is the main implementation of IPFS. It is the base distribution, and includes:\n- an IPFS core implementation\n- an IPFS daemon server\n- extensive command line tooling\n- an HTTP API for controlling the node\n- an HTTP Gateway for serving content to HTTP browsers\n |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shell file is intense. did you lift it or make it from scratch?
cc @chriscool for some quick review?
(no need for
sh
, I'm ok to keepbash
to save time here. all of the people releasing go-ipfs havebash
installed.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this all, lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I just commented on a few things that can be applied in many places.