Skip to content

Commit dfb3444

Browse files
authored
Merge pull request #7 from apiiro/yariv/fix_arch
Add support for different architectures
2 parents 0abdea0 + e624d84 commit dfb3444

File tree

3 files changed

+41
-7
lines changed

3 files changed

+41
-7
lines changed

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ build-osx:
1313
ifneq ($(shell uname -s),Darwin)
1414
$(error this makefile assumes you're building from mac env)
1515
endif
16-
GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -o bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-osx .
16+
GOARCH=amd64 GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -o bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-osx-x86_64 .
17+
GOARCH=arm64 GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -o bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-osx-arm64 .
1718

1819
build-linux:
19-
docker run --rm -v $(shell pwd):/app -w /app golang:1.22-alpine /bin/sh -c "GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -o bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux ."
20+
docker run --rm -v $(shell pwd):/app -w /app golang:1.22-alpine /bin/sh -c "GOARCH=amd64 GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -o bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux-x86_64 ."
21+
docker run --rm -v $(shell pwd):/app -w /app golang:1.22-alpine /bin/sh -c "GOARCH=arm64 GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -o bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux-aarch64 ."
2022

2123
clean:
2224
rm -rf ./bin
@@ -32,10 +34,12 @@ test:
3234

3335
verify-binaries:
3436
$(info running binaries verification on osx, alpine, debiand, centos)
35-
./bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-osx --version
36-
docker run --rm -v $(shell pwd)/bin:/app -w /app alpine /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux --version
37-
docker run --rm -v $(shell pwd)/bin:/app -w /app debian:buster /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux --version
38-
docker run --rm -v $(shell pwd)/bin:/app -w /app centos:8 /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux --version
37+
./bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-osx-x86_64 --version
38+
./bin/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-osx-arm64 --version
39+
docker run --rm -v $(shell pwd)/bin:/app -w /app alpine /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux-aarch64 --version
40+
docker run --rm -v $(shell pwd)/bin:/app -w /app alpine /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux-x86_64 --version
41+
docker run --rm -v $(shell pwd)/bin:/app -w /app debian:buster /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux-aarch64 --version
42+
docker run --rm -v $(shell pwd)/bin:/app -w /app debian:buster /app/$(BINARY_NAME)-$(shell $(GOCMD) run . --version | cut -d" " -f 3)-linux-x86_64 --version
3943

4044
compress-bin:
4145
find bin -type f -print -exec zip -j '{}'.zip '{}' \;

install2.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
# USAGE: ./install.sh [version]
4+
# will install the latest tool executable to your /usr/local/bin
5+
6+
set -e
7+
8+
echo "Installing..."
9+
10+
TMPDIR=${TMPDIR:-"/tmp"}
11+
pushd "$TMPDIR" > /dev/null
12+
mkdir -p complexity
13+
pushd complexity > /dev/null;
14+
distro=$(if [[ "$(uname -s)" == "Darwin" ]]; then echo "osx"; else echo "linux"; fi)
15+
arch=$(uname -m)
16+
if [ -n "$1" ]
17+
then
18+
echo "Will download and install v$1"
19+
curl -sSL --fail -o complexity.zip "https://github.com/apiiro/code-complexity/releases/download/v$1/complexity-$1-$distro-$arch.zip"
20+
else
21+
curl -s --fail https://api.github.com/repos/apiiro/code-complexity/releases/latest | grep "browser_download_url.*$distro-$arch.zip" | cut -d : -f 2,3 | tr -d \" | xargs curl -sSL --fail -o complexity.zip
22+
fi
23+
unzip complexity.zip
24+
chmod +x complexity-*
25+
cp -f complexity-* /usr/local/bin/complexity
26+
popd > /dev/null
27+
rm -rf complexity
28+
popd > /dev/null
29+
30+
echo "Done: $(complexity -v)"

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/urfave/cli/v2"
1212
)
1313

14-
const VERSION = "1.0.6"
14+
const VERSION = "1.0.7"
1515

1616
func main() {
1717
cli.AppHelpTemplate =

0 commit comments

Comments
 (0)