Skip to content

Commit

Permalink
add grep scripts and bump vsn to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
UmanShahzad committed Mar 31, 2021
1 parent 6ec900c commit 9bf3c4e
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 9 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ After choosing a platform `PLAT` from above, run:

```bash
# for Windows, use ".zip" instead of ".tar.gz"
$ curl -L https://github.com/ipinfo/cli/releases/download/1.0.0b3/ipinfo_1.0.0b3_${PLAT}.tar.gz
$ curl -L https://github.com/ipinfo/cli/releases/download/1.0.0/ipinfo_1.0.0_${PLAT}.tar.gz
# OR
$ wget https://github.com/ipinfo/cli/releases/download/1.0.0b3/ipinfo_1.0.0b3_${PLAT}.tar.gz
$ wget https://github.com/ipinfo/cli/releases/download/1.0.0/ipinfo_1.0.0_${PLAT}.tar.gz

$ tar -xvf ipinfo_1.0.0b3_${PLAT}.tar.gz
$ mv ipinfo_1.0.0b3_${PLAT} /usr/local/bin/ipinfo
$ tar -xvf ipinfo_1.0.0_${PLAT}.tar.gz
$ mv ipinfo_1.0.0_${PLAT} /usr/local/bin/ipinfo
```

### Using Homebrew
Expand All @@ -64,8 +64,8 @@ $ mv ipinfo_1.0.0b3_${PLAT} /usr/local/bin/ipinfo
The `ipinfo` binary will be installed in `/usr/local/bin/ipinfo`:

```bash
$ curl -L https://github.com/ipinfo/cli/releases/download/1.0.0b3/ipinfo_1.0.0b3.deb
$ sudo dpkg -i ipinfo_1.0.0b3.deb
$ curl -L https://github.com/ipinfo/cli/releases/download/1.0.0/ipinfo_1.0.0.deb
$ sudo dpkg -i ipinfo_1.0.0.deb
```

### Using Linux package managers
Expand Down
41 changes: 41 additions & 0 deletions grepip/build-all-platforms.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Build binary for all platforms for version $1.

set -e

DIR=`dirname $0`
ROOT=$DIR/..

VSN=$1

if [ -z "$VSN" ]; then
echo "require version as first parameter" 2>&1
exit 1
fi

for t in \
darwin_amd64 \
dragonfly_amd64 \
freebsd_amd64 \
linux_amd64 \
netbsd_amd64 \
openbsd_amd64 \
plan9_amd64 \
solaris_amd64 \
windows_amd64 ;
do
os="${t%_*}"
arch="${t#*_}"
output="grepip_${VSN}_${os}_${arch}"

if [ "$os" == "windows" ] ; then
output+=".exe"
fi

GOOS=$os GOARCH=$arch go build \
-o $ROOT/build/${output} \
$ROOT/grepip &
done

wait
10 changes: 10 additions & 0 deletions grepip/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Build local binary.

DIR=`dirname $0`
ROOT=$DIR/..

go build \
-o $ROOT/build/grepip \
$ROOT/grepip
1 change: 1 addition & 0 deletions grepip/dist/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
usr/
11 changes: 11 additions & 0 deletions grepip/dist/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Source: grepip
Section: utils
Version: 1.0.0
Priority: optional
Maintainer: IPinfo <[email protected]>
Vcs-Git: https://github.com/ipinfo/cli
Vcs-browser: https://github.com/ipinfo/cli
Homepage: https://ipinfo.io
Package: grepip
Architecture: amd64
Description: A grep-like tool for filtering IPv4 and IPv6 addresses.
44 changes: 44 additions & 0 deletions grepip/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Build and upload (to GitHub) for all platforms for version $1.

set -e

DIR=`dirname $0`
ROOT=$DIR/..

VSN=$1

if [ -z "$VSN" ]; then
echo "require version as first parameter" 2>&1
exit 1
fi

# build
rm -f $ROOT/build/grepip_${VSN}*
$ROOT/grepip/build-all-platforms.sh "$VSN"

# archive
cd $ROOT/build
for t in grepip_${VSN}_* ; do
if [[ $t == grepip_*_windows_* ]]; then
zip -q ${t/.exe/.zip} $t
else
tar -czf ${t}.tar.gz $t
fi
done
cd ..

# dist: debian
rm -rf $ROOT/grepip/dist/usr
mkdir -p $ROOT/grepip/dist/usr/local/bin
cp $ROOT/build/grepip_${VSN}_linux_amd64 $ROOT/grepip/dist/usr/local/bin/grepip
dpkg-deb --build ${ROOT}/grepip/dist build/grepip_${VSN}.deb

# release
gh release create $VSN \
-R ipinfo/cli \
-t "grepip-${VSN}" \
$ROOT/build/grepip_*.tar.gz \
$ROOT/build/grepip_*.zip \
$ROOT/build/grepip_*.deb
2 changes: 1 addition & 1 deletion ipinfo/dist/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Source: ipinfo
Section: utils
Version: 1.0-1
Version: 1.0.0
Priority: optional
Maintainer: IPinfo <[email protected]>
Vcs-Git: https://github.com/ipinfo/cli
Expand Down
2 changes: 1 addition & 1 deletion ipinfo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

var progBase = filepath.Base(os.Args[0])
var version = "1.0.0b3"
var version = "1.0.0"

var ii *ipinfo.Client

Expand Down
3 changes: 2 additions & 1 deletion ipinfo/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ cd ..
# dist: debian
rm -rf $ROOT/ipinfo/dist/usr
mkdir -p $ROOT/ipinfo/dist/usr/local/bin
cp $ROOT/build/ipinfo_1.0.0b3_linux_amd64 $ROOT/ipinfo/dist/usr/local/bin/ipinfo
cp $ROOT/build/ipinfo_${VSN}_linux_amd64 $ROOT/ipinfo/dist/usr/local/bin/ipinfo
dpkg-deb --build ${ROOT}/ipinfo/dist build/ipinfo_${VSN}.deb

# release
gh release create $VSN \
-R ipinfo/cli \
-t "ipinfo-${VSN}" \
$ROOT/build/ipinfo_*.tar.gz \
$ROOT/build/ipinfo_*.zip \
$ROOT/build/ipinfo_*.deb

0 comments on commit 9bf3c4e

Please sign in to comment.