Skip to content
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

Refactor/cross compile #14

Merged
merged 3 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.3
6 changes: 5 additions & 1 deletion cmd/ducker/ducker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"github.com/urfave/cli/v2"
)

var (
version string
)

// Cross compile options
// env GOOS=darwin GOARCH=arm64 go build ./cmd/ducker

Expand Down Expand Up @@ -303,7 +307,7 @@ func main() {

app := &cli.App{
Name: "ducker",
Version: "0.1.3",
Version: version,
Compiled: time.Now(),
Authors: []*cli.Author{
&cli.Author{
Expand Down
4 changes: 2 additions & 2 deletions cross_compile.sh
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/bin/bash

VERSION="0.1.3"
OSS=("darwin" "linux")
ARCHS=("amd64" "arm64" "arm")
VERSION=$(cat VERSION)

for os in ${OSS[@]}; do
for arch in ${ARCHS[@]}; do
echo -n "Compile $os-$arch ... "
if env GOOS=$os GOARCH=$arch go build ./cmd/ducker; then
if env GOOS=$os GOARCH=$arch go build -ldflags "-X main.version=$VERSION" ./cmd/ducker; then
tar -czf ducker-$VERSION-$os-$arch.tar.gz ./ducker
echo "ducker-$VERSION-$os-$arch.tar.gz has been created."
fi
Expand Down