Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
137 lines (122 loc) · 6.25 KB
/
Copy pathMakefile
File metadata and controls
137 lines (122 loc) · 6.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
.PHONY: windows windows-release
.PHONY: macos-release
.PHONY: linux-arch-release linux-debian-release linux-debian-release-docker
.PHONY: android-bind android android-release android-clean
.PHONY: clean check-version
-include .env
# Stamped into the Debian control file and every release asset filename.
VERSION ?= 0.3.0
## Fail if VERSION and pkg/PKGBUILD's pkgver disagree.
#
# The version lives in two hand-maintained places and nothing else notices when
# they drift. That is not hypothetical: pkg/control sat at 0.1.0 while 0.2.0 was
# released, so the published 0.2.0 .deb declared itself 0.1.0 and apt would not
# have offered it as an upgrade.
#
# Only pkg/PKGBUILD is checked. pkg/PKGBUILD-bin is *expected* to lag: it
# repackages a published release artifact, so it cannot move until the release
# it names has been uploaded.
check-version:
@pkgver=$$(sed -n 's/^pkgver=//p' pkg/PKGBUILD); \
if [ "$$pkgver" != "$(VERSION)" ]; then \
echo "make: VERSION=$(VERSION) but pkg/PKGBUILD has pkgver=$$pkgver."; \
echo " Reconcile them before cutting a release."; \
exit 1; \
fi
ANDROID_SDK ?= $(HOME)/Android/sdk
ANDROID_NDK ?= $(lastword $(sort $(wildcard $(ANDROID_SDK)/ndk/*)))
NATIVE_ABIS ?= android/arm64,android/amd64
NATIVE_API ?= 29
# gomobile builds a library rather than a main package, so the toolchain does not
# stamp vcs.revision/vcs.modified the way `go build` does and the engine has no
# way to report which build is running. These pass the same two facts in by hand;
# every other target uses `go build` and needs none of this.
VCS_REVISION ?= $(shell git rev-parse HEAD 2>/dev/null)
VCS_MODIFIED ?= $(shell test -n "$$(git status --porcelain 2>/dev/null)" && echo true || echo false)
VERSION_LDFLAGS := -X github.com/bounce-chat/bounce/chat.buildRevision=$(VCS_REVISION) \
-X github.com/bounce-chat/bounce/chat.buildModified=$(VCS_MODIFIED)
windows:
CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows go build -ldflags="-H windowsgui"
windows-release: check-version
mkdir -p releases
CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows fyne package --app-id chat.bounce -icon ui/assets/icon.png -name Bounce -os windows -tags migrated_fynedo --release
mv Bounce.exe releases/Bounce-$(VERSION).exe
macos-release: check-version
mkdir -p releases
mkdir -p build
rm -r build/*
CGO_ENABLED=1 GOARCH=amd64 go build -tags migrated_fynedo -o build/bounce-amd64
CGO_ENABLED=1 GOARCH=arm64 go build -tags migrated_fynedo -o build/bounce-arm64
lipo -create -output build/bounce-universal build/bounce-arm64 build/bounce-amd64
rm build/bounce-amd64
rm build/bounce-arm64
fyne package --app-id chat.bounce -icon ui/assets/icon.png -name Bounce -tags migrated_fynedo --release
mv Bounce.app build/
mv build/bounce-universal build/Bounce.app/Contents/MacOS/bounce
codesign --deep --force --options runtime --sign "Developer ID Application: Hayden Parker (WLRMRLF7W6)" ./build/Bounce.app
ditto -c -k --sequesterRsrc ./build/Bounce.app build/Bounce.zip
xcrun notarytool submit build/Bounce.zip --key-id $(KEY_ID) --issuer $(ISSUER_ID) --key $(KEY_PATH) --wait
xcrun stapler staple ./build/Bounce.app
rm build/Bounce.zip
ln -s /Applications build/Applications
hdiutil create -volname "Bounce" -srcfolder "build/" -size 500m -ov -format UDZO "releases/Bounce-$(VERSION).dmg"
linux-arch-release: check-version
mkdir -p releases
rm -f pkg/*.tar.zst
rm -rf pkg/bounce pkg/bounce-go-arti pkg/src pkg/pkg
cd pkg && makepkg --clean -f
cd pkg && makepkg --clean -f -p PKGBUILD-bin
mv pkg/*.tar.zst releases/
rm -rf pkg/bounce pkg/bounce-go-arti pkg/src pkg/pkg
linux-debian-release: check-version
rm -f bounce
mkdir -p releases
# VERSION is passed explicitly: an override on this target's command line
# would otherwise not reach the sub-make inside the container.
docker run --rm -it -v.:/go/src/bounce golang:trixie bash -c "cd src/bounce && make linux-debian-release-docker VERSION=$(VERSION)"
linux-debian-release-docker:
apt update && apt install -y golang gcc libgl1-mesa-dev xorg-dev libwayland-dev libxkbcommon-dev
git config --global --add safe.directory /go/src/bounce
go build -tags migrated_fynedo
rm -rf pkg/debian
mkdir -p pkg/debian/bounce/DEBIAN
mkdir -p pkg/debian/bounce/usr/bin
mkdir -p pkg/debian/bounce/usr/share/applications
mkdir -p pkg/debian/bounce/usr/share/icons/hicolor/scalable/apps
mv bounce pkg/debian/bounce/usr/bin/bounce
sed 's/^Version:.*/Version: $(VERSION)/' pkg/control > pkg/debian/bounce/DEBIAN/control
cp pkg/bounce.desktop pkg/debian/bounce/usr/share/applications/
cp ui/assets/icon.svg pkg/debian/bounce/usr/share/icons/hicolor/scalable/apps/bounce.svg
# The release asset is named bounce-$(VERSION).deb, which is the filename
# pkg/PKGBUILD-bin's source URL is built from. Producing it here removes a
# manual rename at upload time.
cd pkg/debian && dpkg-deb --build bounce && chown 1000:1000 bounce.deb && mv bounce.deb ../../releases/bounce-$(VERSION).deb && cd .. && rm -rf debian
android-bind:
@test -d "$(ANDROID_NDK)" || (echo "No NDK found under $(ANDROID_SDK)/ndk. Set ANDROID_NDK=..." && false)
mkdir -p android/app/libs
ANDROID_HOME=$(ANDROID_SDK) ANDROID_NDK_HOME=$(ANDROID_NDK) \
gomobile bind \
-target=$(NATIVE_ABIS) \
-androidapi $(NATIVE_API) \
-javapkg chat.bounce \
-o android/app/libs/goengine.aar \
-ldflags="-checklinkname=0 $(VERSION_LDFLAGS)" \
github.com/bounce-chat/bounce/android/goengine
android: android-bind
cd android && ANDROID_HOME=$(ANDROID_SDK) ANDROID_SDK_ROOT=$(ANDROID_SDK) ./gradlew assembleDebug
cp android/app/build/outputs/apk/debug/app-debug.apk ./Bounce.apk
android-release: check-version android-bind
mkdir -p releases
cd android && ANDROID_HOME=$(ANDROID_SDK) ANDROID_SDK_ROOT=$(ANDROID_SDK) ./gradlew assembleRelease \
-Pandroid.injected.signing.store.file=$(ANDROID_KEYSTORE_PATH) \
-Pandroid.injected.signing.store.password=$(ANDROID_KEYSTORE_PASSWORD) \
-Pandroid.injected.signing.key.alias=$(ANDROID_KEY_ALIAS) \
-Pandroid.injected.signing.key.password=$(ANDROID_KEY_PASSWORD)
cp android/app/build/outputs/apk/release/app-release.apk releases/Bounce-$(VERSION).apk
android-clean:
rm -rf android/app/libs/goengine.aar android/app/libs/goengine-sources.jar
rm -rf android/app/build android/build android/.gradle
rm -f Bounce.apk
clean: android-clean
rm -r releases/*
rm -r build/*