Skip to content

Latest commit

 

History

History
238 lines (177 loc) · 12.6 KB

PUBLISHING.md

File metadata and controls

238 lines (177 loc) · 12.6 KB

Publishing Guide

Releases are mostly automated. Tag a commit with vX.Y.Z and push the tag — .github/workflows/release.yml builds prebuilt binaries for Linux, macOS Intel, macOS arm64, and Windows; publishes to crates.io, the Snap Store, and the AUR; and creates a GitHub Release with checksums.

This document covers the one-time setup for each channel and the per-release checklist at the bottom.

GitHub Repository

  1. Add topics (Settings → About → Topics):

    • markdown, markdown-viewer, egui, rust, linux, desktop-app
    • syntax-highlighting, file-explorer, tabs, wayland, x11
  2. Add description:

    Fast, lightweight markdown viewer with LaTeX math, mermaid diagrams, tabs, file explorer and live reload

  3. Enable features:

    • Releases
    • Discussions (optional)

Crates.io

Every v* tag auto-publishes via the publish-crates job in release.yml. The job is gated on CARGO_REGISTRY_TOKEN — if the secret isn't set, the job no-ops with a notice and the rest of the release still ships.

The vendored fork at crates/egui_commonmark/ is published to crates.io under renamed identifiers (egui_commonmark_extended, egui_commonmark_backend_extended, egui_commonmark_macros_extended) so the consumer can resolve features like math that don't exist upstream in lampsitter/egui_commonmark. scripts/publish-crates.sh publishes in dep order (backend → macros → extended → md-viewer) with a 45 s settle delay between each, and treats "already uploaded" as success so re-tagging the same version doesn't fail.

One-time setup to enable automation

  1. Generate a crates.io token at https://crates.io/settings/tokens with scope publish-update (covers publish-new + version updates). Optionally restrict to the four crates listed above.
  2. Add it as a GitHub repo secret named CARGO_REGISTRY_TOKEN (Settings → Secrets and variables → Actions → New repository secret).

Bumping the fork

When the vendored fork at crates/egui_commonmark/ changes:

  1. Bump the workspace version in crates/egui_commonmark/Cargo.toml:
    [workspace.package]
    version = "0.NEW.0"
    
    [workspace.dependencies]
    egui_commonmark_backend_extended = { version = "0.NEW.0", path = "...", ... }
    egui_commonmark_macros_extended = { version = "0.NEW.0", path = "...", ... }
  2. Update the root Cargo.toml consumer line: egui_commonmark_extended = { version = "0.NEW.0", ... }.
  3. Push the next v* tag. CI publishes the fork crates at the new version, then md-viewer.

The root [patch.crates-io] block stays — it's neutral for cargo publish (which ignores patches) and useful locally between fork bumps.

Manual fallback

If you need to publish manually (e.g., the CI job is unavailable):

export CARGO_REGISTRY_TOKEN=<your token>
bash scripts/publish-crates.sh

AUR (Arch User Repository)

The AUR md-viewer-git package is now published automatically by CI on every v* tag (see the publish-aur job in .github/workflows/release.yml).

One-time setup to enable automation

  1. Create an SSH keypair dedicated to AUR pushes (no passphrase):
    ssh-keygen -t ed25519 -f aur-key -C "aur-md-viewer" -N ""
  2. Register the public key on your AUR account → SSH Public Key: https://aur.archlinux.org/account/aydiler/edit (paste the contents of aur-key.pub).
  3. Add the private key as a GitHub repo secret named AUR_SSH_PRIVATE_KEY (Settings → Secrets and variables → Actions → New repository secret). Value: entire contents of the aur-key file (including BEGIN/END lines).
  4. Delete the local keypair: rm aur-key aur-key.pub.

After this, every git push origin v0.X.Y triggers publish-aur, which:

  • Bumps the literal pkgver= in aur/PKGBUILD to the tag version.
  • Regenerates .SRCINFO via an archlinux/archlinux:base-devel container.
  • Commits and pushes to ssh://aur@aur.archlinux.org/md-viewer-git.git.

The job is gated on the secret existing (if: secrets.AUR_SSH_PRIVATE_KEY != ''), so the rest of the release pipeline still runs if you skip this setup.

Manual fallback

git clone ssh://aur@aur.archlinux.org/md-viewer-git.git
cd md-viewer-git
cp /path/to/repo/aur/PKGBUILD .
sed -i "s/^pkgver=.*/pkgver=$NEW_VERSION/" PKGBUILD
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO && git commit -m "Update to $NEW_VERSION" && git push

Test locally: makepkg -si.

AUR (-bin variant)

A second AUR package, md-viewer-bin, ships the GitHub Releases prebuilt binary instead of compiling from source. Arch users pick one:

  • md-viewer-bin — fast install (~5 s), no Rust toolchain needed, x86_64 only.
  • md-viewer-git — compiles from git HEAD, picks up unreleased changes.

The two packages conflict with each other; pacman won't allow both.

Maintained by the publish-aur-bin job in release.yml, mirroring publish-aur with three differences:

  1. Pushes to ssh://aur@aur.archlinux.org/md-viewer-bin.git.
  2. Rewrites both pkgver= and the five-element sha256sums=( ... ) array (Python inline, since multi-line sed is fragile). The tarball checksum comes from the build job's <asset>.sha256 artifact; the four aux-file checksums (.desktop, icon, LICENSE, THIRD_PARTY_NOTICES) are computed from raw GitHub at the tag.
  3. First push to the brand-new AUR repo uses git push -u origin HEAD:refs/heads/master.

Same AUR_SSH_PRIVATE_KEY secret powers both jobs; no separate setup. The job is independently gated, so a -git-only or -bin-only failure doesn't block the other.

The PKGBUILD pulls the .desktop, icon, LICENSE and THIRD_PARTY_NOTICES from raw GitHub URLs pinned to v${pkgver}. The release tarball has contained LICENSE and THIRD_PARTY_NOTICES since 0.1.14, so those two entries could be dropped and the files read from ${srcdir}/; the .desktop file and icon are not in the tarball.

Every source's local name carries ${pkgver} (md-viewer-${pkgver}.desktop::…, THIRD_PARTY_NOTICES-${pkgver}::…). makepkg does not download a source whose file already exists in the build directory, and AUR helpers keep that directory between upgrades. With a fixed name, the first release that changes the file fails its checksum for everyone whose build directory still holds an older copy (#282, devlog 116).

Manual fallback (-bin)

git clone ssh://aur@aur.archlinux.org/md-viewer-bin.git
cd md-viewer-bin
cp /path/to/repo/aur-bin/PKGBUILD .
# Edit PKGBUILD: bump pkgver= (or pkgrel= for a packaging-only fix), then refresh all five sha256sums via
# `updpkgsums` (from pacman-contrib) — it downloads each source and rewrites
# the array in place.
makepkg --printsrcinfo > .SRCINFO
git add PKGBUILD .SRCINFO && git commit -m "Update to $NEW_VERSION" && git push

Snap Store

  1. Create Snapcraft account: https://snapcraft.io/account

  2. Login:

snapcraft login
  1. Build the snap:
cd /path/to/repo
snapcraft
  1. Register the name (one-time):
snapcraft register md-viewer
  1. Upload and release:
snapcraft upload --release=stable md-viewer_0.1.0_amd64.snap

Releases go through CI, not these steps: the publish-snap job in release.yml (and snap-publish.yml for a re-publish) builds the snap in LXD, checks its file list (scripts/snap-ci.sh, check_contents) and then starts it (scripts/snap-smoke.sh): the snap's binary runs under bubblewrap with the core22 base as / and the environment from its own meta/snap.yaml, on a private Xvfb, once with the runner's fonts and once with none. A snap that exits, panics or leaves the screen blank is not uploaded; the run keeps its logs and screenshots as the snap-smoke artifact. To check a snap locally, run bash scripts/snap-smoke.sh <file.snap> (it downloads core22 unless SNAP_SMOKE_BASE points at one). Devlog 117.

Flatpak / Flathub

A Flatpak manifest lives at flatpak/io.github.aydiler.md-viewer.yaml. Submitting to Flathub is manual (one-time PR to the Flathub org).

Pre-submission requirements

  • Replace the placeholder icon at data/io.github.aydiler.md-viewer.png with a designed 256×256 PNG (or scalable SVG). Flathub reviewers will reject submissions whose icon is a generic placeholder.
  • Bump tag: and commit: in the manifest to the latest release before opening the PR. The x-checker-data block will auto-bump them on subsequent releases after the first submission is accepted.
  • Regenerate Cargo sources when Cargo.lock changes its transitive deps (Flathub builds offline):
    # one-time tool setup
    git clone https://github.com/flatpak/flatpak-builder-tools.git /tmp/fbt
    uv run --with aiohttp --with PyYAML --with tomlkit \
        /tmp/fbt/cargo/flatpak-cargo-generator.py Cargo.lock \
        -o flatpak/cargo-sources.json
    Commit the updated flatpak/cargo-sources.json. Pure version bumps (without dep changes) don't require regeneration.
  • Run the Flathub linter and fix all error-level findings:
    # one-time tool install (Arch Linux):
    sudo pacman -S flatpak-builder
    flatpak install --user flathub org.flatpak.Builder
    
    # then:
    flatpak run --command=flatpak-builder-lint org.flatpak.Builder manifest \
        flatpak/io.github.aydiler.md-viewer.yaml
    Warnings are non-fatal but worth addressing. One known lint error is intentional: finish-args-home-ro-filesystem-access flags the --filesystem=home:ro permission. The viewer needs this to read markdown files at arbitrary paths under $HOME for CLI invocation (md-viewer ~/anywhere/foo.md) and live reload via the notify watcher. Flathub permits read-only home access with reviewer justification — include a note in the PR description explaining the use case. If reviewers reject it, fall back to --filesystem=xdg-documents only and document the CLI/live-reload limitation in the README.

Local smoke test before submitting

flatpak install --user flathub \
    org.freedesktop.Platform//24.08 \
    org.freedesktop.Sdk//24.08 \
    org.freedesktop.Sdk.Extension.rust-stable//24.08

flatpak-builder --user --install --force-clean build-dir \
    flatpak/io.github.aydiler.md-viewer.yaml

flatpak run io.github.aydiler.md-viewer README.md

Submission steps

  1. Fork https://github.com/flathub/flathub on GitHub.
  2. Create a branch io.github.aydiler.md-viewer in your fork.
  3. Add io.github.aydiler.md-viewer.yaml (copied from this repo's flatpak/) plus the cargo-sources.json to the branch root.
  4. Open a PR against flathub/flathub:new-pr. Flathub's bot will validate the build.
  5. Iterate with reviewers (typical asks: icon variants, screenshot improvements, sandbox tightening).
  6. After merge, Flathub builds and serves updates on every v* tag if you wire x-checker-data into the manifest.

Icon

The repo currently ships a placeholder icon at data/io.github.aydiler.md-viewer.png (256×256 "md" on dark blue, generated by ImageMagick). Replace this with a designed icon before opening the Flathub PR. The icon is also referenced by the Flatpak manifest and AppStream metainfo.

Release Checklist

  • Update version in Cargo.toml (version = "X.Y.Z")
  • Update version in snap/snapcraft.yaml (version: 'X.Y.Z') — version-sync CI check enforces parity
  • If the vendored renderer changed, bump [workspace.package] version in crates/egui_commonmark/Cargo.toml and every reference to it — the Vendored fork is publishable to crates.io release step fails otherwise
  • Bump Cargo.lock surgically, anchored on name = "md-viewer". Never sed the version line: the fork lockfile carries glam in sixteen versions and a substitution rewrites unrelated crates
  • Append a <release> entry to data/io.github.aydiler.md-viewer.metainfo.xml
  • Write the ## [X.Y.Z] - YYYY-MM-DD section in CHANGELOG.md by hand. Do not run git-cliff -o CHANGELOG.md — this history is not conventional-commit shaped, and -o replaces the hand-written prose with a sparse file that drops whole versions (see docs/LESSONS.md)
  • Commit: git commit -am "Release X.Y.Z"
  • Tag: git tag vX.Y.Z && git push origin main vX.Y.Z
  • Watch release.yml. Expected outputs:
    • 3 prebuilt binaries (Linux x86_64, macOS arm64, Windows x86_64) + matching .sha256. Intel Mac was dropped from the matrix — its runner pool queued for 24+ minutes on v0.1.3; those users build via cargo install
    • GitHub Release with RELEASE_NOTES.md body
    • crates.io publish (gated on CARGO_REGISTRY_TOKEN; idempotent on re-tag)
    • Snap Store stable channel publish
    • AUR push (gated on AUR_SSH_PRIVATE_KEY)