Set up version number injection
This commit is contained in:
parent
a17b3a41ae
commit
e9b51d7ca1
6 changed files with 62 additions and 42 deletions
61
build.sh
61
build.sh
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
TIME_START=$(date +%s)
|
||||||
|
|
||||||
if [ $# -lt 1 ]; then
|
if [ $# -lt 1 ]; then
|
||||||
echo "Usage: $0 <darwin|linux|windows> [<server|desktop>]"
|
echo "Usage: $0 <darwin|linux|windows> [<server|desktop>]"
|
||||||
exit 3
|
exit 3
|
||||||
|
@ -23,28 +25,45 @@ elif [ "$BUILD_TYPE" != "desktop" ] && [ "$BUILD_TYPE" != "server" ]; then
|
||||||
exit 5
|
exit 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Load version information
|
||||||
|
. ./version.properties
|
||||||
|
echo "Building Proxywoman $BUILD_TYPE v$VERSION_NAME (build $VERSION_CODE) for $PLATFORM"
|
||||||
|
echo "Developed by @NBTX (Apollo Software)"
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
|
||||||
# Ensure output directory exists.
|
# Ensure output directory exists.
|
||||||
[ -d "out/" ] || mkdir "out/"
|
[ -d "out/" ] || mkdir "out/"
|
||||||
[ -d "out/$PLATFORM-$BUILD_TYPE" ] && rm -r "out/$PLATFORM-$BUILD_TYPE"
|
[ -d "out/$PLATFORM-$BUILD_TYPE" ] && rm -r "out/$PLATFORM-$BUILD_TYPE"
|
||||||
mkdir "out/$PLATFORM-$BUILD_TYPE"
|
mkdir "out/$PLATFORM-$BUILD_TYPE"
|
||||||
OUTPUT_DIR="out/$PLATFORM-$BUILD_TYPE"
|
OUTPUT_DIR="out/$PLATFORM-$BUILD_TYPE"
|
||||||
|
|
||||||
|
|
||||||
# Handle special build: server
|
# Handle special build: server
|
||||||
if [ "$BUILD_TYPE" = "server" ]; then
|
if [ "$BUILD_TYPE" = "server" ]; then
|
||||||
|
echo "Executing go build..."
|
||||||
|
|
||||||
if [ "$PLATFORM" = "windows" ]; then
|
if [ "$PLATFORM" = "windows" ]; then
|
||||||
GOOS="$PLATFORM" go build -o "$OUTPUT_DIR/proxywoman-server.exe" server/server.go
|
GOOS="$PLATFORM" go build -ldflags "-X main.VersionName=$VERSION_NAME -X main.VersionCode=$VERSION_CODE" -o "$OUTPUT_DIR/proxywoman-server.exe" server/server.go
|
||||||
|
mv "$OUTPUT_DIR/proxywoman-server.exe" "$OUTPUT_DIR/Proxywoman-Server-Windows-v${VERSION_NAME}.exe"
|
||||||
else
|
else
|
||||||
GOOS="$PLATFORM" go build -o "$OUTPUT_DIR/proxywoman-server" server/server.go
|
GOOS="$PLATFORM" go build -ldflags "-X main.VersionName=$VERSION_NAME -X main.VersionCode=$VERSION_CODE" -o "$OUTPUT_DIR/proxywoman-server" server/server.go
|
||||||
|
mv "$OUTPUT_DIR/proxywoman-server" "$OUTPUT_DIR/proxywoman-server-${PLATFORM}-v${VERSION_NAME}"
|
||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Remove all legacy icons.
|
# Remove all legacy icons.
|
||||||
[ -f icons/icon_unix.go ] && rm icons/icon_unix.go
|
[ -f icons/icon_unix.go ] && rm icons/icon_unix.go
|
||||||
[ -f icons/icon_win.go ] && rm icons/icon_win.go
|
[ -f icons/icon_win.go ] && rm icons/icon_win.go
|
||||||
|
|
||||||
|
|
||||||
# Build the icon for the appropriate platform.
|
# Build the icon for the appropriate platform.
|
||||||
if [ "$PLATFORM" = "darwin" ] || [ "$PLATFORM" == "linux" ]; then
|
echo "Generating platform icon..."
|
||||||
|
if [ "$PLATFORM" = "darwin" ] || [ "$PLATFORM" = "linux" ]; then
|
||||||
cat "icons/icon.png" | go run github.com/cratonica/2goarray Data icon >> icons/icon_unix.go
|
cat "icons/icon.png" | go run github.com/cratonica/2goarray Data icon >> icons/icon_unix.go
|
||||||
elif [ "$PLATFORM" = "windows" ]; then
|
elif [ "$PLATFORM" = "windows" ]; then
|
||||||
cat "icons/icon.ico" | go run github.com/cratonica/2goarray Data icon >> icons/icon_win.go
|
cat "icons/icon.ico" | go run github.com/cratonica/2goarray Data icon >> icons/icon_win.go
|
||||||
|
@ -53,28 +72,52 @@ else
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Copy binary assets.
|
||||||
|
echo "Copying binary assets..."
|
||||||
cp -r "resources/$PLATFORM/." "$OUTPUT_DIR/"
|
cp -r "resources/$PLATFORM/." "$OUTPUT_DIR/"
|
||||||
|
|
||||||
|
|
||||||
|
# Inject placeholders into assets.
|
||||||
|
echo "Injecting placeholders into binary assets..."
|
||||||
|
find "$OUTPUT_DIR" -type f -print0 | xargs -0 perl -pi -e "s/\\\$VERSION_NAME/$VERSION_NAME/g"
|
||||||
|
find "$OUTPUT_DIR" -type f -print0 | xargs -0 perl -pi -e "s/\\\$VERSION_CODE/$VERSION_CODE/g"
|
||||||
|
|
||||||
|
|
||||||
|
# Execute platform build.
|
||||||
|
echo "Executing go build..."
|
||||||
|
|
||||||
if [ "$PLATFORM" = "darwin" ]; then
|
if [ "$PLATFORM" = "darwin" ]; then
|
||||||
mkdir -p "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS"
|
mkdir -p "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS"
|
||||||
mkdir -p "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS/icons"
|
mkdir -p "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS/icons"
|
||||||
cp icons/icon.png "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS/icons/"
|
cp icons/icon.png "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS/icons/"
|
||||||
GOOS="darwin" GO111MODULE=on go build -o "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS/postwoman-proxy"
|
GOOS="darwin" GO111MODULE=on go build -ldflags "-X main.VersionName=$VERSION_NAME -X main.VersionCode=$VERSION_CODE" -o "$OUTPUT_DIR/Proxywoman.app/Contents/MacOS/postwoman-proxy"
|
||||||
|
|
||||||
|
mv "$OUTPUT_DIR/Proxywoman.app" "$OUTPUT_DIR/Proxywoman-Darwin-v${VERSION_NAME}.app"
|
||||||
elif [ "$PLATFORM" = "windows" ]; then
|
elif [ "$PLATFORM" = "windows" ]; then
|
||||||
[ -f "rsrc.syso" ] && rm rsrc.syso
|
[ -f "rsrc.syso" ] && rm rsrc.syso
|
||||||
go get github.com/akavel/rsrc
|
go get github.com/akavel/rsrc
|
||||||
|
|
||||||
rsrc -manifest="$OUTPUT_DIR/postwoman-proxy.manifest" -ico="icons/icon.ico" -o rsrc.syso
|
rsrc -manifest="$OUTPUT_DIR/postwoman-proxy.manifest" -ico="icons/icon.ico" -o rsrc.syso
|
||||||
GOOS="windows" GO111MODULE=on go build -ldflags -H=windowsgui -o "$OUTPUT_DIR/proxywoman.exe"
|
GOOS="windows" GO111MODULE=on go build -ldflags "-X main.VersionName=$VERSION_NAME -X main.VersionCode=$VERSION_CODE -H=windowsgui" -o "$OUTPUT_DIR/proxywoman.exe"
|
||||||
|
|
||||||
mkdir $OUTPUT_DIR/icons
|
mkdir "$OUTPUT_DIR/icons"
|
||||||
cp icons/icon.png "$OUTPUT_DIR/icons/icon.png"
|
cp icons/icon.png "$OUTPUT_DIR/icons/icon.png"
|
||||||
|
|
||||||
mkdir $OUTPUT_DIR/data
|
mkdir "$OUTPUT_DIR/data"
|
||||||
|
|
||||||
rm $OUTPUT_DIR/postwoman-proxy.manifest
|
rm "$OUTPUT_DIR/postwoman-proxy.manifest"
|
||||||
rm rsrc.syso
|
rm rsrc.syso
|
||||||
|
|
||||||
|
mv "$OUTPUT_DIR/proxywoman.exe" "$OUTPUT_DIR/Proxywoman-Windows-v${VERSION_NAME}.exe"
|
||||||
elif [ "$PLATFORM" = "linux" ]; then
|
elif [ "$PLATFORM" = "linux" ]; then
|
||||||
echo "NOTICE: Proxywoman is untested and currently unsupported on Linux."
|
echo "NOTICE: Proxywoman is untested and currently unsupported on Linux."
|
||||||
GOOS="linux" GO111MODULE=on go build -o "$OUTPUT_DIR/proxywoman"
|
GOOS="linux" GO111MODULE=on go build -ldflags "-X main.VersionName=$VERSION_NAME -X main.VersionCode=$VERSION_CODE" -o "$OUTPUT_DIR/proxywoman"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TIME_END=$(date +%s)
|
||||||
|
TIME_TAKEN=$(( TIME_END - TIME_START ))
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo "Done (${TIME_TAKEN}s)."
|
|
@ -32,22 +32,6 @@ func publicKeyOf(priv interface{}) interface{} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func pemBlockOf(priv interface{}) *pem.Block {
|
|
||||||
switch k := priv.(type) {
|
|
||||||
case *rsa.PrivateKey:
|
|
||||||
return &pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(k)}
|
|
||||||
case *ecdsa.PrivateKey:
|
|
||||||
b, err := x509.MarshalECPrivateKey(k)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Unable to marshal ECDSA private key: %v", err)
|
|
||||||
os.Exit(2)
|
|
||||||
}
|
|
||||||
return &pem.Block{Type: "EC PRIVATE KEY", Bytes: b}
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func CreateKeyPair() *[2]bytes.Buffer {
|
func CreateKeyPair() *[2]bytes.Buffer {
|
||||||
private, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
private, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -124,19 +108,6 @@ func EnsurePrivateKeyInstalled () error {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadKeyPair() error {
|
|
||||||
encodedPem, _ := ioutil.ReadFile(GetDataPath() + "/cert.pem");
|
|
||||||
block, _ := pem.Decode(encodedPem);
|
|
||||||
|
|
||||||
if(block.Type != "CERTIFICATE"){
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
//derBytes := block.Bytes;
|
|
||||||
//_, _ := x509.ParsePKCS1PrivateKey(derBytes);
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetDataPath() string {
|
func GetDataPath() string {
|
||||||
dir, _ := filepath.Abs(filepath.Dir(os.Args[0]));
|
dir, _ := filepath.Abs(filepath.Dir(os.Args[0]));
|
||||||
return dir + string(os.PathSeparator) + "data";
|
return dir + string(os.PathSeparator) + "data";
|
||||||
|
|
5
main.go
5
main.go
|
@ -11,6 +11,9 @@ import (
|
||||||
"postwoman.io/proxy/notifier"
|
"postwoman.io/proxy/notifier"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var VersionName string;
|
||||||
|
var VersionCode string;
|
||||||
|
|
||||||
var mStatus *systray.MenuItem;
|
var mStatus *systray.MenuItem;
|
||||||
var mCopyAccessToken *systray.MenuItem;
|
var mCopyAccessToken *systray.MenuItem;
|
||||||
|
|
||||||
|
@ -20,7 +23,7 @@ func main() {
|
||||||
|
|
||||||
func onReady() {
|
func onReady() {
|
||||||
systray.SetIcon(icon.Data);
|
systray.SetIcon(icon.Data);
|
||||||
systray.SetTooltip("Proxyman v1.0.0 - created by NBTX");
|
systray.SetTooltip("Proxywoman v" + VersionName + " (" + VersionCode + ") - created by NBTX");
|
||||||
|
|
||||||
/** Set up menu items. **/
|
/** Set up menu items. **/
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.0</string>
|
<string>$VERSION_NAME</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>1.0.0</string>
|
<string>$VERSION_NAME</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.developer-tools</string>
|
<string>public.app-category.developer-tools</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||||
<assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="Proxywoman" type="win32"/>
|
<assemblyIdentity version="$VERSION_NAME.0" processorArchitecture="*" name="Proxywoman" type="win32"/>
|
||||||
<dependency>
|
<dependency>
|
||||||
<dependentAssembly>
|
<dependentAssembly>
|
||||||
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"/>
|
||||||
|
|
3
version.properties
Normal file
3
version.properties
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Version Information
|
||||||
|
VERSION_NAME=0.0.2
|
||||||
|
VERSION_CODE=2
|
Loading…
Reference in a new issue