Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 43 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
dist/*.deb

metadata:
needs: build
needs: [build, macos-app]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
Expand All @@ -70,16 +70,19 @@ jobs:
path: dist
pattern: '!*.dockerbuild'
merge-multiple: true
# The cask (refract-app) is generated from the signed disk images macos-app built in this run.
- name: Homebrew and WinGet
run: |
python3 scripts/package-metadata.py "$GITHUB_REF_NAME" dist "$RUNNER_TEMP/packages"
cp "$RUNNER_TEMP/packages/homebrew/refract.rb" dist/refract.rb
cp "$RUNNER_TEMP/packages/homebrew/refract-app.rb" dist/refract-app.rb
tar -czf dist/refract-winget-manifests.tar.gz -C "$RUNNER_TEMP/packages/winget" manifests
- uses: actions/upload-artifact@v7
with:
name: package-metadata
path: |
dist/refract.rb
dist/refract-app.rb
dist/refract-winget-manifests.tar.gz

# Tool archives (Tectonic, SyncTeX, ripgrep, private Git) for every target, built
Expand All @@ -89,6 +92,26 @@ jobs:
with:
tag: ${{ github.ref_name }}

# The macOS app (#71): Refract.app with the tool archives above, signed, notarized and stapled,
# its disk image (Refract-<arch>.dmg, the download people use) and the update archive and feed
# (Refract-<arch>.zip, appcast-<arch>.xml). A release never ships an app signed ad hoc: without
# the signing secrets, or if signing or notarization fails, this job fails and nothing is published.
macos-app:
needs: tools
uses: ./.github/workflows/macos-app.yml
with:
version: ${{ github.ref_name }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proposed RC and its stable release get the same build version. I checked macos/build-app.sh: both v0.3.0-rc1 and v0.3.0 produce CFBundleVersion=0.3.0. Sparkle compares that value, so someone who installs the RC won’t be offered the stable release. Could we give the stable build a higher build number and test that upgrade path?

require-signed: true
tools-artifact: true
secrets:
MACOS_CERT_P12_BASE64: ${{ secrets.MACOS_CERT_P12_BASE64 }}
MACOS_CERT_PASSWORD: ${{ secrets.MACOS_CERT_PASSWORD }}
MACOS_SIGN_IDENTITY: ${{ secrets.MACOS_SIGN_IDENTITY }}
NOTARY_KEY_P8_BASE64: ${{ secrets.NOTARY_KEY_P8_BASE64 }}
NOTARY_KEY_ID: ${{ secrets.NOTARY_KEY_ID }}
NOTARY_ISSUER_ID: ${{ secrets.NOTARY_ISSUER_ID }}
SPARKLE_ED_PRIVATE_KEY: ${{ secrets.SPARKLE_ED_PRIVATE_KEY }}

# Exercise the CLI without any server configuration or LaTeX tools. OAuth
# itself is interactive; --help checks the login entry point without signing in.
cli-smoke:
Expand Down Expand Up @@ -132,7 +155,7 @@ jobs:
# Waits for the image's scan, so a blocked image stops the whole release,
# and attaches each architecture's scan report.
release:
needs: [build, metadata, cli-smoke, tools, image]
needs: [build, metadata, cli-smoke, tools, macos-app, image]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7 # for CHANGELOG.md
Expand All @@ -151,22 +174,18 @@ jobs:
# architecture, each pointing at an archive this release attaches. A feed that points anywhere
# else would send people's apps to the wrong file, so it stops here. Feeds are looked up at
# releases/latest/download/appcast-<arch>.xml: publish them as assets of a full (not pre-)release.
# A full release that attaches the app must carry both feeds (checked below); until the app is
# part of every release (#71), one without the app has none and is allowed.
# A full release must carry both feeds (checked below); a prerelease has none.
- name: Check the appcasts
run: |
set -- dist/appcast-*.xml
if [ ! -e "$1" ]; then
# Installed apps read releases/latest/download/appcast-<arch>.xml: a full release that
# carries the app (Refract-<arch>.zip) but no appcast would become "latest" and break
# every installed app's feed (404). Only a prerelease (a '-' in the tag) may go without.
# Installed apps read releases/latest/download/appcast-<arch>.xml: a full release without
# them would become "latest" and break every installed app's feed (404). Only a
# prerelease (a '-' in the tag) goes without.
case "$GITHUB_REF_NAME" in
*-*) echo "no appcasts in this prerelease"; exit 0 ;;
esac
if ls dist/Refract-arm64.zip dist/Refract-amd64.zip >/dev/null 2>&1; then
echo "::error::this release attaches the macOS app but no appcast-<arch>.xml: as the latest release it would break every installed app's update feed"; exit 1
fi
echo "no appcasts in this release (it has no macOS app)"; exit 0
echo "::error::a full release must carry appcast-<arch>.xml: as the latest release it would break every installed app's update feed"; exit 1
fi
for arch in arm64 amd64; do
[ -f "dist/appcast-$arch.xml" ] || { echo "::error::appcast-$arch.xml is missing: an app of that architecture could never update"; exit 1; }
Expand All @@ -184,6 +203,15 @@ jobs:
*) echo "::error::$f points at ${url##*/}, an archive of another architecture"; exit 1 ;;
esac
done
# Every release carries the macOS app: its disk image (what people download), and the zip
# the update feeds point at, for both architectures.
- name: Check the macOS app
run: |
for arch in arm64 amd64; do
for f in "Refract-$arch.dmg" "Refract-$arch.zip"; do
[ -f "dist/$f" ] || { echo "::error::$f is missing from this release"; exit 1; }
done
done
# The notes are the version's section of CHANGELOG.md ("## [0.1.0] - …"),
# minus the link definitions at the end of the file. Without that
# section, GitHub lists the commits instead.
Expand Down Expand Up @@ -221,12 +249,13 @@ jobs:
- name: Update tap
working-directory: tap
run: |
mkdir -p Formula
mkdir -p Formula Casks
cp ../metadata/refract.rb Formula/refract.rb
if git diff --quiet -- Formula/refract.rb && [ -z "$(git ls-files --others --exclude-standard Formula/refract.rb)" ]; then exit 0; fi
cp ../metadata/refract-app.rb Casks/refract-app.rb
if git diff --quiet -- Formula Casks && [ -z "$(git ls-files --others --exclude-standard Formula Casks)" ]; then exit 0; fi
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add Formula/refract.rb
git add Formula/refract.rb Casks/refract-app.rb
git commit -m "Refract $GITHUB_REF_NAME"
git push

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Notable changes to Refract. The format follows [Keep a Changelog](https://keepac

### Added

- The macOS app is part of every release: a signed and notarized disk image per architecture (`Refract-arm64.dmg`, `Refract-amd64.dmg`) with its update feed, and a Homebrew cask (`brew install --cask use-refract/tap/refract-app`). A release fails instead of publishing an app that isn't signed and notarized. Uninstalling the app, even with `--zap`, keeps your projects and key.
- **Sign in with ChatGPT** in Settings → Assistant when Refract runs on your own computer (it listens on loopback): the server runs the sign-in, waits for ChatGPT's redirect on `127.0.0.1:1455` and stores the credential, with no terminal or file. Refract opens the sign-in in the default browser, and shows the link if it can't. Uploading a credential file from `refract login` still works, and is the way for servers elsewhere, including a loopback server behind a reverse proxy. Signing out cancels a sign-in still waiting, and reopening Settings shows a sign-in that finished meanwhile.
- Refract can read its encryption key, OpenID Connect client secret, SMTP URL and OpenAlex API key from files using the corresponding `REFRACT_*_FILE` variables. `refract users` and `refract local` also accept the encryption key from a file, and the systemd unit starts Refract directly with a systemd credential.
- `REFRACT_OUTBOUND` (`any` by default, or `public`) chooses whether AI provider base URLs and git remotes may reach loopback and private networks. `public` does what `REFRACT_MODE=saas` did for outbound requests, and checks at startup that git is 2.37 or later. With `public`, provider requests and redirects must be https, and link-local git remotes are refused in every mode. `REFRACT_MODE=saas` no longer changes it.
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,20 @@ The paper in these screenshots is a made-up example, and the AI responses come f

## Quick start

Try Refract on your own computer in a few minutes, either with the `refract` program or with Docker.
Try Refract on your own computer in a few minutes: with the Mac app, the `refract` program or Docker.

> **Using an AI coding agent?** Ask it to follow [AGENTS.md](AGENTS.md): a step-by-step guide for agents to get Refract running for you, whether you want to try it, work on the code or put it on a server.

### The Mac app

Download the disk image for your Mac from the [latest release](https://github.com/Use-Refract/Refract/releases/latest): [Apple silicon](https://github.com/Use-Refract/Refract/releases/latest/download/Refract-arm64.dmg) or [Intel](https://github.com/Use-Refract/Refract/releases/latest/download/Refract-amd64.dmg) (**Apple menu → About This Mac** says which). Open it and drag **Refract** to **Applications**. Or with Homebrew:

```sh
brew install --cask use-refract/tap/refract-app
```

It needs macOS 13 or later and nothing else: Git, Tectonic, SyncTeX and ripgrep come inside the app, and the first PDF compiles offline. The app is signed and notarized, and updates itself (**Refract → Check for Updates…**). Your projects live in `~/Library/Application Support/Refract` and the key that protects stored passwords in the Keychain, outside the app: updating, or removing the app (even `brew uninstall --zap`), leaves them. Signing in to ChatGPT or adding an API key in **Settings → Assistant** is optional. The Homebrew formula `refract` is still the command line; the app is the cask `refract-app`.

### Run it on your computer

[Install the `refract` program](#install-the-cli), plus [Tectonic](https://tectonic-typesetting.github.io/book/latest/installation/) to compile and git for project history, then run:
Expand Down Expand Up @@ -723,7 +733,9 @@ Each architecture's image is pushed by digest only, with no public tag, and then
- **Recording an exception.** Add an entry with the vulnerability's id (as Grype reports it), the package, the reason it can't be exploited in Refract (or why waiting for a fix is acceptable), your GitHub login and the dates of the review and of expiry (at most 90 days apart). Merge it through a pull request like any other change. An expired or incomplete entry blocks the gate until someone reviews it again.
- **The report.** It stays with the build: each architecture's `refract-image-<version>-<arch>-scan.tar.gz` has `report.md` (the decision, the findings and the native tools), both SBOMs, Grype's full results and `image.txt` with the digest it covers. It is attached to the GitHub release and kept for 90 days as a workflow artifact, also when the scan blocks. Run it locally with `scripts/scan-image.sh <image> <folder>`.

Releases also include Debian packages for amd64 and arm64, a Homebrew formula (`refract.rb`) and WinGet manifests (`refract-winget-manifests.tar.gz`). CLI smoke tests run on macOS, Linux and Windows before the release is published. Stable releases can update the Homebrew tap automatically once its repository token is configured. [Packaging maintenance](packaging/README.md) describes the setup and manual publication steps.
Every release also carries the macOS app for both architectures (`.github/workflows/macos-app.yml`, called by the release): the signed, notarized and stapled `Refract-<arch>.dmg` people download, the `Refract-<arch>.zip` and `appcast-<arch>.xml` the app updates from. The release fails rather than publish an app signed ad hoc, so the signing, notarization and update secrets must be set ([macos/README.md](macos/README.md#signing-and-notarization)).

Releases also include Debian packages for amd64 and arm64, a Homebrew formula (`refract.rb`), the app's cask (`refract-app.rb`) and WinGet manifests (`refract-winget-manifests.tar.gz`). CLI smoke tests run on macOS, Linux and Windows before the release is published. Stable releases can update the Homebrew tap (the formula and the cask) automatically once its repository token is configured. [Packaging maintenance](packaging/README.md) describes the setup and manual publication steps.

## License

Expand Down
24 changes: 19 additions & 5 deletions packaging/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ identity, notarizes it with the same API key, staples it and mounts it to check
unsigned and uploaded as `Refract-dmg-adhoc-<arch>`. The window layout, the icon and the
background are checked in (`macos/dmg/`, `macos/Resources/AppIcon.icns`); how to regenerate them is in `macos/README.md`, "Icon and disk image".

**Release (#71).** `release.yml` calls `macos-app.yml` with the tag, `require-signed: true` and
`tools-artifact: true` (the tool archives `tools.yml` built and smoke-tested in the same run), so a
missing secret or a failed signature or notarization fails the release instead of publishing an
ad hoc build. The release attaches `Refract-<arch>.dmg`, `Refract-<arch>.zip` and
`appcast-<arch>.xml` for arm64 and amd64, and refuses to publish without them (a prerelease has no
appcasts). `scripts/package-metadata.py` writes the cask `refract-app.rb` from the two disk images
(one per architecture, `arch arm:/intel:`, macOS 13 or later), next to the formula `refract.rb`,
and the `homebrew` job copies it to `Casks/refract-app.rb` in `Use-Refract/homebrew-tap`. The cask's
`zap` removes only what the app can rebuild (caches, WebKit data, preferences, logs): never the
data folder or the Keychain item, and its caveat says so.

## Server deployments

Server deployments are a distinct path: `server/` (a systemd unit and
Expand All @@ -266,7 +277,7 @@ package adds the Git dependency and desktop entry under the policy above. Prerel

`scripts/package-metadata.py` uses Python 3.11+ and its standard library to verify
the expected nested executable paths and calculate SHA-256 hashes from the actual
archives. It generates a macOS Homebrew formula and three WinGet manifests (version,
archives and the app's disk images. It generates a macOS Homebrew formula, the app's cask and three WinGet manifests (version,
English locale and the x64/arm64 zip installers). They are release assets too:

```sh
Expand All @@ -281,14 +292,17 @@ OAuth sign-in itself remains an interactive user step and is not exercised by CI
## Homebrew

The tap is [Use-Refract/homebrew-tap](https://github.com/Use-Refract/homebrew-tap).
Copy the generated `homebrew/refract.rb` to `Formula/refract.rb` in that repository.
It uses the existing macOS binaries; neither Go nor Node is needed to install.
Copy the generated `homebrew/refract.rb` to `Formula/refract.rb` and `homebrew/refract-app.rb`
to `Casks/refract-app.rb` in that repository. The formula uses the existing macOS binaries; neither
Go nor Node is needed to install. The cask installs the signed disk image of the Mac's architecture.
Validate on macOS before pushing the tap update:

```sh
ruby -c Formula/refract.rb
ruby -c Formula/refract.rb && ruby -c Casks/refract-app.rb
brew style Casks/refract-app.rb
brew install use-refract/tap/refract
brew test use-refract/tap/refract
brew install --cask use-refract/tap/refract-app
```

For automatic updates after stable releases, configure these in the **Refract**
Expand All @@ -301,7 +315,7 @@ repository's GitHub Actions settings:

The default `GITHUB_TOKEN` cannot write to the separate tap. Without this setup,
releases still publish packages and metadata, and the tap can be updated manually.
Prereleases never automatically update the stable formula.
Prereleases never automatically update the stable formula or cask.

## WinGet

Expand Down
48 changes: 48 additions & 0 deletions scripts/package-metadata.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python3
"""Generate Homebrew and WinGet metadata from the exact release archives.

Writes the CLI's formula (refract), the macOS app's cask (refract-app, from the
signed disk images Refract-<arch>.dmg) and the WinGet manifests.

Usage: python3 scripts/package-metadata.py v0.1.2 dist packaging-output
Only the Python standard library is required. Run before publishing the release.
"""
Expand Down Expand Up @@ -41,6 +44,13 @@ def generate(tag: str, archives: Path, output: Path) -> None:
with path.open("rb") as source:
hashes[platform, arch] = hashlib.file_digest(source, "sha256").hexdigest()

# The app's disk images (macos-app.yml): both architectures, read before anything is written.
dmgs = {}
for arch in ("arm64", "amd64"):
path = archives / f"Refract-{arch}.dmg"
with path.open("rb") as source:
dmgs[arch] = hashlib.file_digest(source, "sha256").hexdigest()

formula = output / "homebrew" / "refract.rb"
formula.parent.mkdir(parents=True, exist_ok=True)
base = f"{REPO}/releases/download/{tag}"
Expand Down Expand Up @@ -79,6 +89,44 @@ def caveats
assert_match "-no-browser", shell_output("#{{bin}}/refract login --help 2>&1")
end
end
''', encoding="utf-8")

# The app cask. Uninstalling, even with --zap, never removes the person's projects (the data
# folder, Application Support/Refract) or their key (Keychain): only what the app can rebuild.
cask = output / "homebrew" / "refract-app.rb"
cask.write_text(f'''cask "refract-app" do
arch arm: "arm64", intel: "amd64"

version "{version}"
sha256 arm: "{dmgs['arm64']}",
intel: "{dmgs['amd64']}"

url "{REPO}/releases/download/v#{{version}}/Refract-#{{arch}}.dmg"
name "Refract"
desc "LaTeX workspace with an AI assistant"
homepage "{REPO}"

auto_updates true
depends_on macos: ">= :ventura"

app "Refract.app"

zap trash: [
"~/Library/Caches/io.github.ponytojas.Refract",
"~/Library/HTTPStorages/io.github.ponytojas.Refract",
"~/Library/Logs/Refract",
"~/Library/Preferences/io.github.ponytojas.Refract.plist",
"~/Library/Saved Application State/io.github.ponytojas.Refract.savedState",
"~/Library/WebKit/io.github.ponytojas.Refract",
]

caveats <<~EOS
Uninstalling, even with --zap, keeps your projects in
~/Library/Application Support/Refract
and Refract's key in the Keychain (item "Refract"). Delete them yourself
only if you no longer need those projects.
EOS
end
''', encoding="utf-8")

winget = output / "winget" / "manifests" / "p" / "ponytojas" / "Refract" / version
Expand Down
Loading
Loading