Skip to content

Commit

Permalink
Merge pull request #19 from dirtyhenry/distribute
Browse files Browse the repository at this point in the history
Notarized Distribution Images
  • Loading branch information
dirtyhenry authored Mar 29, 2023
2 parents 00834c9 + 23870c2 commit 3338c50
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 4 deletions.
13 changes: 13 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# This file is treated as a Makefile so spaces are OK to use.

CODESIGN_IDENTITY = "Developer ID Application: John Appleseed (1234AAPL)"
PKG_CODESIGN_IDENTITY = "Developer ID Installer: John Appleseed (1234AAPL)"

USERNAME = john.appleseed@me.com
TEAM_ID = 1234AAPL

# Use an application-specific password, not your developer account password
# 🔗 https://appleid.apple.com/
PASSWORD_ID = abcd-efgh-ijkl-mnop

REVERSED_DOMAIN = com.me
5 changes: 4 additions & 1 deletion .github/workflows/deploy_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Deploy Documentation

# Manual trigger
# 📜 https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
on: workflow_dispatch
on:
workflow_dispatch:
push:
branches: [main]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
# 📜 https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ xcuserdata/

# Local documentation
.Pomodoro.doccarchive

# Build I/O
.env
pkg/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017-2022 Mickaël Floc'hlay
Copyright (c) 2017-2023 Mickaël Floc'hlay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
69 changes: 68 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# 📜 https://forums.swift.org/t/how-to-distribute-a-swiftpm-executable-on-macos/47127/5
# 📜 https://developer.apple.com/developer-id/

VERSION = 1.1.0
PRODUCT = pomodoro-cli

BINARY = .build/apple/Products/Release/${PRODUCT}
PKG_ROOT = ./pkg/${PRODUCT}-${VERSION}
PKG_DIR = ${PKG_ROOT}/usr/local/bin
PKG_DMG = ./pkg/${PRODUCT}-${VERSION}.dmg
PKG_DMG_ROOT = ./pkg/out
PKG = ${PKG_DMG_ROOT}/${PRODUCT}-${VERSION}.pkg
BUNDLE_ID = ${REVERSED_DOMAIN}.${PRODUCT}

# Load secrets
include .env
export $(shell sed 's/=.*//' .env)

prefix ?= /usr/local
bindir = $(prefix)/bin

# --- The Everyday Tasks ---

.PHONY: docs

install:
Expand Down Expand Up @@ -33,7 +53,54 @@ docs:
rm -rf tmp/

clean:
rm -rf .build .swiftpm
rm -rf .build/ .swiftpm/ pkg/

serve-docs:
serve --single .Pomodoro.doccarchive

# --- The Distribution Tasks ---

${BINARY}:
swift build -c release --product ${PRODUCT} --arch arm64 --arch x86_64
xcrun codesign -s ${CODESIGN_IDENTITY} \
--options=runtime \
--timestamp \
${BINARY}

${PKG}: ${BINARY}
rm -rf "${PKG_ROOT}" || true
rm -rf "${PKG_DMG_ROOT}" || true
mkdir -p ${PKG_DIR}
mkdir -p ${PKG_DMG_ROOT}
cp ${BINARY} ${PKG_DIR}
xcrun pkgbuild --root ${PKG_ROOT} \
--identifier "${BUNDLE_ID}" \
--version "${VERSION}" \
--install-location "/" \
--sign ${PKG_CODESIGN_IDENTITY} \
${PKG}

${PKG_DMG}: ${PKG} staple
hdiutil create -volname "${PRODUCT}" -srcfolder "${PKG_DMG_ROOT}" -ov -format UDZO "${PKG_DMG}"

.PHONY: build
build: ${BINARY}

.PHONY: package
package: ${PKG}

.PHONY: notarize
notarize: ${PKG}
xcrun notarytool submit \
--apple-id "${USERNAME}" \
--password "${PASSWORD_ID}" \
--team-id "${TEAM_ID}" \
--wait \
"${PKG}"

.PHONY: staple
staple:
xcrun stapler staple "${PKG}"

.PHONY: image
image: ${PKG_DMG}
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ let package = Package(
platforms: [
.macOS(.v10_12),
],
products: [
.executable(name: "pomodoro-cli", targets: ["PomodoroCLI"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.4"),
.package(url: "https://github.com/apple/swift-tools-support-core", from: "0.2.7")
Expand All @@ -16,7 +19,7 @@ let package = Package(
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core")
]),
.target(name: "PomodoroCLI", dependencies: ["Pomodoro"]),
.executableTarget(name: "PomodoroCLI", dependencies: ["Pomodoro"]),
.testTarget(name: "PomodoroTests", dependencies: ["Pomodoro"]),
]
)
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ A journal of pomodoros is created in `~/.pomodoro-cli/journal.yml`.

## Installation

### From Source

To install from sources, [Swift](https://swift.org/getting-started/) is required.

Installing `swiftlint` and `swiftformat` via [Homebrew](https://brew.sh/), and having installed [Ruby](https://www.ruby-lang.org/fr/)/[Bundler](https://bundler.io) are recommended for an easy installation.
Expand All @@ -43,6 +45,16 @@ Installing `swiftlint` and `swiftformat` via [Homebrew](https://brew.sh/), and h

Check out [`Makefile`](https://github.com/dirtyhenry/pomodoro-cli/blob/main/Makefile) for more development convenience commands.

### From Distribution Images

The `.dmg` files are created via:

```
make clean notarize
# and upon successful feedback from the Apple notary service:
make image
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Expand Down

0 comments on commit 3338c50

Please sign in to comment.