Compare commits

...

5 Commits

21 changed files with 584 additions and 58 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4
- name: Build
run: |
docker compose run --build --rm xtool -c "swift build --product xtool"
docker compose run --build --rm xtool swift build --product xtool
build-macos:
runs-on: macos-15
steps:
-49
View File
@@ -1,49 +0,0 @@
on:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
host:
- runner: ubuntu-24.04
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.host.runner }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
docker compose run --build --rm xtool -c "Linux/build.sh && mv Linux/packages/xtool{,-${{ matrix.host.arch }}}.AppImage"
- name: Upload artifact
id: upload_artifact
uses: actions/upload-artifact@v4
with:
name: xtool-${{ matrix.host.arch }}
path: Linux/packages/xtool-${{ matrix.host.arch }}.AppImage
release:
needs: build
runs-on: ubuntu-24.04
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Download artifact
id: download_artifact
uses: actions/download-artifact@v4
with:
pattern: xtool-*
path: output
- name: Create and publish release
id: publish_release
run: |
TAG="${GITHUB_REF##*/}-${GITHUB_SHA:0:7}"
gh release create "$TAG" --draft --title "Draft Release"
gh release upload "$TAG" output/**/*.AppImage
+75
View File
@@ -0,0 +1,75 @@
on:
workflow_dispatch:
jobs:
build-linux:
strategy:
fail-fast: false
matrix:
host:
- runner: ubuntu-24.04
arch: x86_64
- runner: ubuntu-24.04-arm
arch: aarch64
runs-on: ${{ matrix.host.runner }}
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build
run: |
docker compose run --build --rm xtool bash -c "Linux/build.sh && mv Linux/packages/xtool{,-${{ matrix.host.arch }}}.AppImage"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: xtool-${{ matrix.host.arch }}
path: Linux/packages/xtool-${{ matrix.host.arch }}.AppImage
build-mac:
runs-on: macos-15
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
working-directory: macOS
bundler-cache: true
- name: Build
env:
APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }}
APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }}
APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }}
IDENTITY_P12: ${{ secrets.IDENTITY_P12 }}
DEVELOPMENT_TEAM: ${{ secrets.DEVELOPMENT_TEAM }}
run: |
cd macOS
bundle exec fastlane package
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: xtool-mac
path: |
macOS/Build/Output/xtool.app.zip
macOS/Build/Output/xtool.app.dSYM.zip
release:
needs: [build-linux, build-mac]
runs-on: ubuntu-24.04
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
pattern: xtool-*
path: output
- name: Create and publish release
run: |
TAG="${GITHUB_REF##*/}-${GITHUB_SHA:0:7}"
gh release create "$TAG" --draft --title "Draft Release"
gh release upload "$TAG" output/**/*.{AppImage,app.zip,app.dSYM.zip}
+3 -3
View File
@@ -7,8 +7,8 @@ builder:
- xtool
- scheme: xtool
platform: macosXcodebuild
# - scheme: xtool
# platform: linux
# image: # TODO: we need to use our own Docker image for this
- scheme: xtool
platform: linux
image: kabiroberai/xtool-dev:latest
- scheme: XKit
platform: ios
+1 -1
View File
@@ -94,4 +94,4 @@ ENV USBMUXD_SOCKET_ADDRESS=host.docker.internal:27015
WORKDIR /xtool
ENTRYPOINT [ "/bin/bash" ]
CMD [ "/bin/bash" ]
-4
View File
@@ -9,13 +9,9 @@ enum XToolMain {
static func main() async throws {
prepareDependencies { dependencies in
#warning("Improve persistence mechanism")
// for macOS, we can use KeychainStorage but we need to sign with entitlements.
// for Windows, we could use dpapi.h or wincred.h.
// for Linux, maybe use libsecret?
// see https://github.com/atom/node-keytar
// #if os(macOS)
// dependencies.keyValueStorage = KeychainStorage(service: "com.kabiroberai.xtool-keychain.credentials")
// #endif
}
try await XTool.run()
}
+7
View File
@@ -0,0 +1,7 @@
/XToolMac.xcodeproj
Private*.xcconfig
/fastlane/README.md
/fastlane/report.xml
/Build
/Private
+1
View File
@@ -0,0 +1 @@
3.4.3
+9
View File
@@ -0,0 +1,9 @@
source 'https://rubygems.org'
gem 'fastlane'
gem 'fastlane-plugin-xcodegen'
# https://github.com/fastlane/fastlane/issues/29183#issuecomment-2567093826
gem "abbrev"
gem "mutex_m"
gem "ostruct"
+236
View File
@@ -0,0 +1,236 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.7)
base64
nkf
rexml
abbrev (0.1.2)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.2)
aws-partitions (1.1102.0)
aws-sdk-core (3.223.0)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.992.0)
aws-sigv4 (~> 1.9)
base64
jmespath (~> 1, >= 1.6.1)
logger
aws-sdk-kms (1.100.0)
aws-sdk-core (~> 3, >= 3.216.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.185.0)
aws-sdk-core (~> 3, >= 3.216.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
aws-sigv4 (1.11.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
base64 (0.2.0)
claide (1.1.0)
colored (1.2)
colored2 (3.1.2)
commander (4.6.0)
highline (~> 2.0.0)
declarative (0.0.20)
digest-crc (0.7.0)
rake (>= 12.0.0, < 14.0.0)
domain_name (0.6.20240107)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.112.0)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
faraday (>= 0.8.0)
http-cookie (~> 1.0.0)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.1.0)
multipart-post (~> 2.0)
faraday-net_http (1.0.2)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.1)
faraday (~> 1.0)
fastimage (2.4.0)
fastlane (2.227.2)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0)
colored (~> 1.2)
commander (~> 4.6)
dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0)
excon (>= 0.71.0, < 1.0.0)
faraday (~> 1.0)
faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0)
fastimage (>= 2.1.0, < 3.0.0)
fastlane-sirp (>= 1.0.0)
gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3)
google-apis-playcustomapp_v1 (~> 0.1)
google-cloud-env (>= 1.6.0, < 2.0.0)
google-cloud-storage (~> 1.31)
highline (~> 2.0)
http-cookie (~> 1.0.5)
json (< 3.0.0)
jwt (>= 2.1.0, < 3)
mini_magick (>= 4.9.4, < 5.0.0)
multipart-post (>= 2.0.0, < 3.0.0)
naturally (~> 2.2)
optparse (>= 0.1.1, < 1.0.0)
plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0)
security (= 0.1.5)
simctl (~> 1.6.3)
terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (~> 3)
tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.4.1)
xcpretty-travis-formatter (>= 0.0.3, < 2.0.0)
fastlane-plugin-brew (0.1.1)
fastlane-plugin-xcodegen (1.1.0)
fastlane-plugin-brew (~> 0.1.1)
fastlane-sirp (1.0.0)
sysrandom (~> 1.0)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.54.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-core (0.11.3)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
mini_mime (~> 1.0)
representable (~> 3.0)
retriable (>= 2.0, < 4.a)
rexml
google-apis-iamcredentials_v1 (0.17.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-playcustomapp_v1 (0.13.0)
google-apis-core (>= 0.11.0, < 2.a)
google-apis-storage_v1 (0.31.0)
google-apis-core (>= 0.11.0, < 2.a)
google-cloud-core (1.8.0)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.5.0)
google-cloud-storage (1.47.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
google-apis-storage_v1 (~> 0.31.0)
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.8.1)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
multi_json (~> 1.11)
os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a)
highline (2.0.3)
http-cookie (1.0.8)
domain_name (~> 0.5)
httpclient (2.9.0)
mutex_m
jmespath (1.6.2)
json (2.11.3)
jwt (2.10.1)
base64
logger (1.7.0)
mini_magick (4.13.2)
mini_mime (1.1.5)
multi_json (1.15.0)
multipart-post (2.4.1)
mutex_m (0.3.0)
nanaimo (0.4.0)
naturally (2.2.1)
nkf (0.2.0)
optparse (0.6.0)
os (1.1.4)
ostruct (0.6.1)
plist (3.7.2)
public_suffix (6.0.2)
rake (13.2.1)
representable (3.2.0)
declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0)
uber (< 0.2.0)
retriable (3.1.2)
rexml (3.4.1)
rouge (3.28.0)
ruby2_keywords (0.0.5)
rubyzip (2.4.1)
security (0.1.5)
signet (0.20.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.10)
CFPropertyList
naturally
sysrandom (1.0.5)
terminal-notifier (2.0.0)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
trailblazer-option (0.1.2)
tty-cursor (0.7.1)
tty-screen (0.8.2)
tty-spinner (0.9.3)
tty-cursor (~> 0.7)
uber (0.1.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.27.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.4.1)
rouge (~> 3.28.0)
xcpretty-travis-formatter (1.0.1)
xcpretty (~> 0.2, >= 0.0.7)
PLATFORMS
arm64-darwin-24
ruby
DEPENDENCIES
abbrev
fastlane
fastlane-plugin-xcodegen
mutex_m
ostruct
BUNDLED WITH
2.6.7
+11
View File
@@ -0,0 +1,11 @@
# macOS Packaging
xtool is packaged as a .app bundle on macOS, so that we can add entitlements and use the keychain.
Ideally we'd dogfood xtool to package xtool, but it only supports iOS apps right now. Someday, hopefully.
## Building
1. Install [XcodeGen](https://github.com/yonaskolb/XcodeGen)
2. Run `xcodegen` inside this (`./macOS`) directory
3. Open the Xcode project and build the `XToolMac` scheme
+22
View File
@@ -0,0 +1,22 @@
#!/bin/bash
# https://github.com/microsoft/vscode/blob/509cc674f24d87a298d56518c318de67bda357cb/resources/darwin/bin/code.sh
function app_realpath() {
SOURCE="$1"
while [ -h "$SOURCE" ]; do
DIR=$(/usr/bin/dirname "$SOURCE")
SOURCE=$(/usr/bin/readlink "$SOURCE")
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE"
done
SOURCE_DIR="$( cd -P "$( /usr/bin/dirname "$SOURCE" )" >/dev/null 2>&1 && echo "$PWD" )"
echo "${SOURCE_DIR%%${SOURCE_DIR#*.app}}"
}
APP_PATH="$(app_realpath "${BASH_SOURCE[0]}")"
if [ -z "$APP_PATH" ]; then
echo "Unable to determine app path from symlink : ${BASH_SOURCE[0]}"
exit 1
fi
XTL_CLI=1 "$APP_PATH/Contents/MacOS/xtool" "$@"
+9
View File
@@ -0,0 +1,9 @@
GENERATE_INFOPLIST_FILE = YES
CODE_SIGN_ENTITLEMENTS = Support/XToolMac.entitlements
CODE_SIGN_STYLE = Automatic
ENABLE_HARDENED_RUNTIME = YES
PRODUCT_NAME = xtool
PRODUCT_MODULE_NAME = XToolMac
#include? "Private.xcconfig"
+1
View File
@@ -0,0 +1 @@
#include "Base.xcconfig"
+1
View File
@@ -0,0 +1 @@
#include "Base.xcconfig"
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)sh.xtool.keychain</string>
</array>
</dict>
</plist>
+24
View File
@@ -0,0 +1,24 @@
import Foundation
import Dependencies
import XToolSupport
import XKit
@main enum XToolMacMain {
static func main() async throws {
// the bin/xtool script invokes us with this env var, allowing us to
// detect command-line invocations vs a UI app launch
if ProcessInfo.processInfo.environment["XTL_CLI"] == "1" {
try await runXTool()
} else {
XToolMacUI.main()
}
}
private static func runXTool() async throws {
try await withDependencies {
$0.keyValueStorage = KeychainStorage(service: "sh.xtool.keychain.credentials")
} operation: {
try await XTool.run()
}
}
}
+79
View File
@@ -0,0 +1,79 @@
import SwiftUI
struct XToolMacUI: App {
var body: some Scene {
WindowGroup {
ContentView()
}
.disableWindowResizingIfPossible()
}
}
private struct ContentView: View {
private static let command = """
sudo ln -fs /Applications/xtool.app/Contents/Resources/bin/xtool /usr/local/bin/xtool
"""
var body: some View {
VStack(alignment: .leading, spacing: 16) {
StepView(1) {
Text("Move this app into your `/Applications` folder.")
}
StepView(2) {
VStack(alignment: .leading, spacing: 16) {
Text("Symlink xtool into a location on your `PATH`.")
Text(Self.command)
.font(.body.monospaced())
.textSelection(.enabled)
Button("Copy Command") {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(Self.command, forType: .string)
}
}
}
}
.padding()
.padding(.vertical)
.frame(width: 500)
.fixedSize()
.navigationTitle("xtool")
}
}
private struct StepView<Content: View>: View {
let number: Int
let content: Content
init(_ number: Int, @ViewBuilder content: () -> Content) {
self.number = number
self.content = content()
}
var body: some View {
HStack(alignment: .firstTextBaseline) {
Text("\(number)")
.foregroundStyle(.background)
.padding(8)
.background(.secondary, in: .circle)
content
}
}
}
extension Scene {
fileprivate func disableWindowResizingIfPossible() -> some Scene {
if #available(macOS 13, *) {
return self.windowResizability(.contentSize)
} else {
return self
}
}
}
#Preview {
ContentView()
}
+1
View File
@@ -0,0 +1 @@
app_identifier("sh.xtool.XToolMac")
+66
View File
@@ -0,0 +1,66 @@
default_platform(:mac)
ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120"
lane :package do
xcodegen
# Config is controlled via env vars
app_store_connect_api_key(
is_key_content_base64: true,
)
create_keychain(
name: "xtool.keychain",
password: "",
unlock: true,
)
unlock_keychain(
path: "xtool.keychain",
password: "",
)
Tempfile.create(["Identity", ".p12"]) do |file|
file.write(Base64.decode64(ENV["IDENTITY_P12"]))
file.close
import_certificate(
certificate_path: file.path,
keychain_name: "xtool.keychain",
keychain_password: "",
)
end
sigh(
platform: "macos",
output_path: "./Build/Signing",
force: true,
developer_id: true,
)
update_code_signing_settings(
use_automatic_signing: false,
team_id: ENV["DEVELOPMENT_TEAM"],
code_sign_identity: "Developer ID Application",
profile_name: lane_context[SharedValues::SIGH_NAME],
)
gym(
export_method: "developer-id",
output_directory: "./Build/Output",
)
notarize(
package: "./Build/Output/xtool.app",
)
# we need to re-package after notarization and stapling.
# we have to use `ditto --sequesterRsrc` rather than zip
# because the default strategy stores resource forks as
# ._Foo but codesigning doesn't like that, and instead
# wants them in __MACOSX.
sh(
"ditto", "-c", "-k", "--keepParent", "--sequesterRsrc",
"../Build/Output/xtool.app", "../Build/Output/xtool.app.zip",
)
end
+27
View File
@@ -0,0 +1,27 @@
name: XToolMac
options:
bundleIdPrefix: sh.xtool
packages:
xtool:
path: ..
group: ""
fileGroups:
- Support
targets:
XToolMac:
type: application
platform: macOS
deploymentTarget: "12.0"
sources:
- path: XToolMac
- path: Resources/xtool
buildPhase:
copyFiles:
destination: resources
subpath: bin
configFiles:
Debug: Support/Debug.xcconfig
Release: Support/Release.xcconfig
dependencies:
- package: xtool
product: XToolSupport