Last active
May 22, 2018 21:30
-
-
Save nl5887/36969dc461e4dc69c2e88203d9d1088a to your computer and use it in GitHub Desktop.
Codesigning wrapper for Go
This file contains hidden or 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/bash | |
| if [ "$#" -eq 0 ]; then | |
| $GOROOT/bin/go $@ | |
| exit | |
| fi | |
| LDFLAGS="" | |
| if [ -e scripts/gen-ldflags.go ]; then | |
| LDFLAGS="$(go run -exec ~/.gopath/bin/sign-wrapper.sh scripts/gen-ldflags.go) $LDFLAGS" | |
| fi | |
| if [ $1 == "run" ]; then | |
| shift | |
| echo $@ | |
| $GOROOT/bin/go run -ldflags "$LDFLAGS" --exec ~/.gopath/bin/sign-wrapper.sh $@ | |
| elif [ $1 == "test" ]; then | |
| $GOROOT/bin/go test -ldflags "$LDFLAGS" --exec ~/.gopath/bin/sign-wrapper.sh ${@:2} | |
| elif [ $1 == "build" ]; then | |
| echo "Compiling binary ${@:2}" | |
| if [ $? -eq 0 ]; then | |
| FILENAME=$(echo $OUTPUT|tr ' ' '\n'|tail -n1|head -n1) | |
| echo "Signing $FILENAME..." | |
| codesign -f -s "Mac Developer: John Doe (AB12DEF34G)" $FILENAME | |
| else | |
| go build -ldflags "$LDFLAGS" ${@:2} | |
| fi | |
| else | |
| go $@ | |
| fi |
This file contains hidden or 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/bash | |
| codesign -f -s "Mac Developer: John Doe (AB12DEF34G)" $FILENAME | |
| $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment