Last active
July 17, 2018 04:18
-
-
Save kemokemo/6daecb0d05a8ebdb3006bcf9d09e2b9e to your computer and use it in GitHub Desktop.
a script to build golang app for multi-platform.
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
@echo off | |
setlocal enabledelayedexpansion | |
rem set the result of the "git rev-parse --short HEAD" to the variable 'rev' | |
for /f "usebackq tokens=*" %%a in (`git rev-parse --short HEAD`) do @set rev=%%a | |
set GOOS=windows | |
set GOARCH=amd64 | |
go build -ldflags "-X main.Revision=%rev%" | |
endlocal |
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
#!/bin/sh | |
if [ $# != 1 ]; then | |
echo "Usage: $0 [binary name]" | |
exit 0 | |
fi | |
GOOS=linux GOARCH=amd64 go build -o ./bin/$1_linux_x64/$1 | |
GOOS=linux GOARCH=386 go build -o ./bin/$1_linux_x86/$1 | |
GOOS=windows GOARCH=386 go build -o ./bin/$1_windows_x86/$1.exe | |
GOOS=windows GOARCH=amd64 go build -o ./bin/$1_windows_x64/$1.exe | |
GOOS=darwin GOARCH=386 go build -o ./bin/$1_macOS_x86/$1 | |
GOOS=darwin GOARCH=amd64 go build -o ./bin/$1_macOS_x64/$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment