Skip to content

Commit

Permalink
chore(build): minor build updates (#829)
Browse files Browse the repository at this point in the history
  • Loading branch information
WanderingHogan authored May 19, 2023
1 parent 03f3811 commit b2c28cc
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 88 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/build-dmg-universal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
MACOS_CERTIFICATE_NAME: ${{ secrets.MACOS_CERTIFICATE_NAME }}
MACOS_CI_KEYCHAIN_PWD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }}
MACOS_KEYCHAIN_NAME: ${{ secrets.MACOS_KEYCHAIN_NAME }}
MACOS_CERT_ID: ${{secrets.MACOS_CERT_ID}}
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p "$MACOS_CI_KEYCHAIN_PWD" builduplink.keychain
Expand All @@ -51,7 +52,7 @@ jobs:
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$MACOS_CI_KEYCHAIN_PWD" builduplink.keychain
security find-identity -p codesigning -v
security list-keychains
make dmg
make dmg SIGNING_KEY="$MACOS_CERT_ID"
- name: "Notarize executable"
env:
PROD_MACOS_NOTARIZATION_APPLE_ID: ${{ secrets.MACOS_NOTARIZATION_APPLE_ID }}
Expand All @@ -62,14 +63,14 @@ jobs:
echo "Create keychain profile"
xcrun notarytool store-credentials "uplink-notarytool-profile" --apple-id "$PROD_MACOS_NOTARIZATION_APPLE_ID" --team-id "$PROD_MACOS_NOTARIZATION_TEAM_ID" --password "$PROD_MACOS_NOTARIZATION_PWD"
echo "Creating temp notarization archive"
ditto -c -k --keepParent "target/macos_bundle/Uplink.app" "notarization.zip"
ditto -c -k --keepParent "target/release/macos/Uplink.app" "notarization.zip"
echo "Notarize app"
xcrun notarytool submit "notarization.zip" --keychain-profile "uplink-notarytool-profile" --wait
echo "Attach staple"
xcrun stapler staple "target/macos_bundle/Uplink.app"
xcrun stapler staple "target/release/macos/Uplink.app"
- name: Create ZIP archive
run: |
ditto -c -k --sequesterRsrc --keepParent target/macos_bundle/Uplink.app Uplink-Mac-Universal.zip
ditto -c -k --sequesterRsrc --keepParent target/release/macos/Uplink.app Uplink-Mac-Universal.zip
- name: Calculate hashes
run: |
shasum -a 256 Uplink-Mac-Universal.zip > Uplink-Mac-Universal.zip.sha256.txt
Expand All @@ -86,4 +87,4 @@ jobs:
uses: softprops/action-gh-release@v1
with:
files: |
Uplink-Mac-Universal.zip
Uplink-Mac-Universal.zip
2 changes: 2 additions & 0 deletions .github/workflows/build-release-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
name: Build Release Linux
runs-on: ubuntu-latest
steps:
- name: Get latest package list
run: sudo apt-get update
- name: Install libwebkit2gtk
run: sudo apt-get install -y build-essential pkg-config libssl-dev libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev librust-alsa-sys-dev dpkg-dev gzip
- name: Install Protoc
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ opt-level = 3
codegen-units = 1

[workspace.package]
version = "0.0.1"
version = "0.1.5"
rust-version = "1.68"

[workspace.dependencies]
Expand Down
134 changes: 66 additions & 68 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,89 +1,87 @@

# the relevant documentation is provided by apple.developer.com, specifically regarding code signing and CFBundles.
# code signing resource guide:
# https://developer.apple.com/library/archive/documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html

# name of the executable
TARGET = uplink

# stuff to copy over to RESOURCES_DIR
ASSETS_SOURCE_DIR = ui/extra

# directory structure for .dmg :
# https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/10000123i-CH101-SW8
ASSETS_DIR = ./ui/extra
RELEASE_DIR = ./target/release

BUNDLE_DIR = target/macos_bundle
# folder used for the universal installer
DMG_NAME = $(BUNDLE_DIR)/Uplink.dmg
# folder used to build the .app
APP_DIR = $(BUNDLE_DIR)/Uplink.app
APP_NAME = Uplink.app
APP_TEMPLATE = $(ASSETS_DIR)/macos/$(APP_NAME)
APP_DIR = $(RELEASE_DIR)/macos
APP_BINARY = $(RELEASE_DIR)/$(TARGET)
CONTENTS = $(APP_DIR)/$(APP_NAME)/Contents
APP_BINARY_DIR = $(APP_DIR)/$(APP_NAME)/Contents/MacOS
APP_EXTRAS_DIR = $(APP_DIR)/$(APP_NAME)/Contents/Resources
APP_FRAMEWORKS_DIR = $(APP_DIR)/$(APP_NAME)/Contents/Frameworks

# contains all subfolders: MacOs, Resources, Frameworks
# https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html#//apple_ref/doc/uid/20001119-110730
APP_CONTENTS_DIR = $(APP_DIR)/Contents
DMG_NAME = Uplink.dmg
DMG_DIR = $(RELEASE_DIR)/macos

# contains standalone executables
MACOS_DIR = $(APP_CONTENTS_DIR)/MacOs
# contains resources
RESOURCES_DIR = $(APP_CONTENTS_DIR)/Resources
# contains shared libraries (.dylib)
FRAMEWORKS_DIR = $(APP_CONTENTS_DIR)/Frameworks
vpath $(TARGET) $(RELEASE_DIR)
vpath $(APP_NAME) $(APP_DIR)
vpath $(DMG_NAME) $(APP_DIR)

all: help

help: ## Print this help message
@grep -E '^[a-zA-Z._-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

folders: ## creates build directory and copies assets
# clean up from previous build
@rm -rf $(APP_DIR)
@rm -f $(DMG_NAME)
@mkdir -p $(APP_DIR)

# this copy command also creates $(APP_CONTENTS_DIR) and $(RESOURCES_DIR)
@cp -fRp $(ASSETS_SOURCE_DIR)/macos/Uplink.App/Contents $(APP_DIR)
@mkdir $(MACOS_DIR)
@mkdir $(FRAMEWORKS_DIR)

@cp -R $(ASSETS_SOURCE_DIR)/assets $(RESOURCES_DIR)
@cp -R $(ASSETS_SOURCE_DIR)/images $(RESOURCES_DIR)
@cp -R $(ASSETS_SOURCE_DIR)/prism_langs $(RESOURCES_DIR)
@cp -R $(ASSETS_SOURCE_DIR)/themes $(RESOURCES_DIR)

app: folders ## Build the release binary and Uplink.app
@echo "make app ..."
binary: $(TARGET)-native ## Build a release binary
binary-universal: $(TARGET)-universal ## Build a universal release binary
$(TARGET)-native:
MACOSX_DEPLOYMENT_TARGET="10.11" cargo build --release -F production_mode
@lipo target/release/$(TARGET) -create -output $(APP_BINARY)
$(TARGET)-universal:
MACOSX_DEPLOYMENT_TARGET="10.11" cargo build --release --target=x86_64-apple-darwin -F production_mode
MACOSX_DEPLOYMENT_TARGET="10.11" cargo build --release --target=aarch64-apple-darwin -F production_mode
@lipo target/{x86_64,aarch64}-apple-darwin/release/$(TARGET) -create -output $(MACOS_DIR)/$(TARGET)
@lipo target/{x86_64,aarch64}-apple-darwin/release/libclear_all.dylib -create -output $(FRAMEWORKS_DIR)/libclear_all.dylib
@lipo target/{x86_64,aarch64}-apple-darwin/release/libemoji_selector.dylib -create -output $(FRAMEWORKS_DIR)/libemoji_selector.dylib

# delete all special attributes. not sure why/if this is needed
xattr -c $(APP_CONTENTS_DIR)/Info.plist
xattr -c $(RESOURCES_DIR)/uplink.icns

signed-app: app ## sign the executable, .dylibs, and Uplink.app directory
@echo "make signed-app ..."
/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_SOURCE_DIR)/entitlements.plist --strict --options=runtime --force -s $(SIGNING_KEY) $(FRAMEWORKS_DIR)/libclear_all.dylib
/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_SOURCE_DIR)/entitlements.plist --strict --options=runtime --force -s $(SIGNING_KEY) $(FRAMEWORKS_DIR)/libemoji_selector.dylib
/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_SOURCE_DIR)/entitlements.plist --strict --options=runtime --force -s $(SIGNING_KEY) $(APP_DIR)

unsigned-dmg: app ## build the universal Uplink.dmg file without signing
@lipo target/{x86_64,aarch64}-apple-darwin/release/$(TARGET) -create -output $(APP_BINARY)
@lipo target/{x86_64,aarch64}-apple-darwin/release/libemoji_selector.dylib -create -output $(RELEASE_DIR)/libemoji_selector.dylib

/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_DIR)/entitlements.plist --strict -s $(SIGNING_KEY) --options=runtime --force $(APP_BINARY)
# /usr/bin/codesign -vvv --deep --entitlements $(ASSETS_DIR)/entitlements.plist --strict -s $(SIGNING_KEY) --options=runtime --force $(APP_TEMPLATE)

app: $(APP_NAME)-native ## Create a Uplink.app
app-universal: $(APP_NAME)-universal ## Create a universal Uplink.app
$(APP_NAME)-%: $(TARGET)-%
@mkdir -p $(APP_BINARY_DIR)
@mkdir -p $(APP_EXTRAS_DIR)
@mkdir -p $(APP_FRAMEWORKS_DIR)
@cp -fRp $(APP_TEMPLATE) $(APP_DIR)
@cp -fp $(APP_BINARY) $(APP_BINARY_DIR)
@touch -r "$(APP_BINARY)" "$(APP_DIR)/$(APP_NAME)"
@echo "Created '$(APP_NAME)' in '$(APP_DIR)'"
xattr -c $(APP_DIR)/$(APP_NAME)/Contents/Info.plist
xattr -c $(APP_DIR)/$(APP_NAME)/Contents/Resources/uplink.icns

mkdir -p $(APP_DIR)/$(APP_NAME)/Contents/Resources/extra
cp -r ./ui/extra/* $(APP_DIR)/$(APP_NAME)/Contents/Resources
# cp -r ./ui/extra/images $(APP_DIR)/$(APP_NAME)/Contents/Resources/images
# cp -r ./ui/extra/prism_langs $(APP_DIR)/$(APP_NAME)/Contents/Resources/prism_langs
# cp -r ./ui/extra/themes $(APP_DIR)/$(APP_NAME)/Contents/Resources/themes

cp $(RELEASE_DIR)/*.dylib $(APP_FRAMEWORKS_DIR)
/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_DIR)/entitlements.plist --strict -s $(SIGNING_KEY) --options=runtime --force $(APP_FRAMEWORKS_DIR)/libemoji_selector.dylib
/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_DIR)/entitlements.plist --strict --options=runtime --force -s $(SIGNING_KEY) $(APP_DIR)/$(APP_NAME)

dmg: $(DMG_NAME)-native ## Create a Uplink.dmg
dmg-universal: $(DMG_NAME)-universal ## Create a universal Uplink.dmg
$(DMG_NAME)-%: $(APP_NAME)-%
@echo "Packing disk image..."
@ln -sf /Applications $(BUNDLE_DIR)/Applications
@hdiutil create $(DMG_NAME) \
@ln -sf /Applications $(DMG_DIR)/Applications
@hdiutil create $(DMG_DIR)/$(DMG_NAME) \
-volname "Uplink" \
-fs HFS+ \
-srcfolder $(BUNDLE_DIR) \
-srcfolder $(APP_DIR) \
-ov -format UDZO
@echo "Packed '$(BUNDLE_DIR)' into dmg"
@echo "Packed '$(APP_NAME)' in '$(APP_DIR)'"
/usr/bin/codesign -vvv --entitlements $(ASSETS_DIR)/entitlements.plist --strict --options=runtime --force -s $(SIGNING_KEY) $(DMG_DIR)/$(DMG_NAME)

dmg: signed-app unsigned-dmg ## sign Uplink.dmg
@echo "make dmg..."
/usr/bin/codesign -vvv --deep --entitlements $(ASSETS_SOURCE_DIR)/entitlements.plist --strict --options=runtime --force -s $(SIGNING_KEY) $(DMG_NAME)
install: $(INSTALL)-native ## Mount disk image
install-universal: $(INSTALL)-native ## Mount universal disk image
$(INSTALL)-%: $(DMG_NAME)-%
@open $(DMG_DIR)/$(DMG_NAME)

.PHONY: app binary clean dmg install $(TARGET) $(TARGET)-universal

# tell Make that these targets don't correspond to physical files
.PHONY: dmg unsigned-dmg signed-app app folders help all clean
clean: ## Remove all build artifacts
@cargo clean

watch: ## run this first: `cargo install cargo-watch`
@cargo watch -x 'run'
10 changes: 5 additions & 5 deletions ui/deb/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: {{package}}
Version: {{version}}
Vendor: Satellite Im
Description: P2P chat application
Section: net
Vendor: Satellite IM Inc
Description: (Pre-Release Software) Secure, Encrypted, P2P chat written atop Warp, IPFS, LibP2P, and many more awesome projects and protocols.
Section: net, communication
Priority: required
Depends: libwebkit2gtk-4.1-0 libopus0, ffmpeg
Maintainer: matt.wisniewski@deepspaceshipping.co
Depends: libwebkit2gtk-4.1-0, libopus0, ffmpeg
Maintainer: hello@satellite.im
Architecture: {{architecture}}
Homepage: https://satellite.im/
4 changes: 0 additions & 4 deletions ui/wix/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@
</DirectoryRef>
<!-- end of ExtraFolder -->
<DirectoryRef Id="ExtensionFolder">
<Component Id="cmpLibClearAll.dll" Guid="8A156548-9269-4D20-8FC8-213D865E3252">
<File Id="ClearAll.dll" Name="clear_all.dll" DiskId="1" KeyPath="yes" Source="$(var.CargoTargetDir)\release\clear_all.dll" />
</Component>
<Component Id="cmpLibEmojiSelector.dll" Guid="8C8B04BE-FAAE-418B-8CD9-5AADF2859C67">
<File Id="EmojiSelector.dll" Name="emoji_selector.dll" DiskId="1" KeyPath="yes" Source="$(var.CargoTargetDir)\release\emoji_selector.dll" />
</Component>
Expand Down Expand Up @@ -211,7 +208,6 @@
<ComponentRef Id="cmpNord.scss" />
<ComponentRef Id="cmpPink.scss" />
<ComponentRef Id="cmpPolar.scss" />
<ComponentRef Id="cmpLibClearAll.dll" />
<ComponentRef Id="cmpLibEmojiSelector.dll" />
<Feature Id="Environment" Title="PATH Environment Variable" Description="Add the install location of the [ProductName] executable to the PATH system environment variable. This allows the [ProductName] executable to be called from any location." Level="1" Absent="allow">
<ComponentRef Id="Path" />
Expand Down

0 comments on commit b2c28cc

Please sign in to comment.