Signed release pipeline (macOS/Windows/Linux/Web); README community note
Ports photocraft's release workflow + packaging (signing, notarization, MSI/DMG/deb/rpm/AppImage/web), adds `cargo xtask version`. File-type associations omitted for now (route B); app keeps its own .desktop. Fresh WiX UpgradeCode. README 'about' note updated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
7b37dd1da5
commit
da8a14dd04
|
|
@ -0,0 +1,53 @@
|
||||||
|
# Quick static checks for the release pipeline (seconds, no Rust build): workflow syntax,
|
||||||
|
# packaging shell/PowerShell scripts, and the Linux desktop/AppStream/Flatpak metadata.
|
||||||
|
name: Packaging lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, release]
|
||||||
|
paths: [".github/workflows/**", "packaging/**", "assets/app-icon/**"]
|
||||||
|
pull_request:
|
||||||
|
paths: [".github/workflows/**", "packaging/**", "assets/app-icon/**"]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: packaging-lint-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
ACTIONLINT_VERSION: 1.7.12
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install tools
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends shellcheck desktop-file-utils appstream libxml2-utils python3-yaml
|
||||||
|
curl -fsSL "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz" \
|
||||||
|
| tar -xz -C "$RUNNER_TEMP" actionlint
|
||||||
|
- name: actionlint
|
||||||
|
run: |
|
||||||
|
"$RUNNER_TEMP/actionlint" -color
|
||||||
|
- name: shellcheck
|
||||||
|
run: shellcheck packaging/*.sh packaging/*/*.sh
|
||||||
|
- name: PowerShell
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
foreach ($f in Get-ChildItem packaging/windows/*.ps1) {
|
||||||
|
$errors = $null
|
||||||
|
[System.Management.Automation.Language.Parser]::ParseFile($f.FullName, [ref]$null, [ref]$errors) | Out-Null
|
||||||
|
if ($errors) { $errors | ForEach-Object { Write-Output "::error file=$($f.Name)::$_" }; exit 1 }
|
||||||
|
Write-Output "ok $($f.Name)"
|
||||||
|
}
|
||||||
|
- name: XML, desktop entry, AppStream, Flatpak manifest
|
||||||
|
run: |
|
||||||
|
xmllint --noout packaging/windows/vectorcraft.wxs packaging/macos/*.plist* packaging/linux/*.xml*
|
||||||
|
desktop-file-validate packaging/linux/ai.storyteller.vectorcraft.desktop
|
||||||
|
sed -e 's/@VERSION@/0.0.0/' -e 's/@DATE@/2026-01-01/' packaging/linux/ai.storyteller.vectorcraft.metainfo.xml.in >"$RUNNER_TEMP/ai.storyteller.vectorcraft.metainfo.xml"
|
||||||
|
appstreamcli validate --no-net --explain "$RUNNER_TEMP/ai.storyteller.vectorcraft.metainfo.xml"
|
||||||
|
python3 -c "import yaml; m = yaml.safe_load(open('packaging/linux/flatpak/ai.storyteller.vectorcraft.yml')); assert m['id'] == 'ai.storyteller.vectorcraft' and m['command'] == 'vectorcraft'"
|
||||||
|
|
@ -0,0 +1,285 @@
|
||||||
|
# Release pipeline: every push to `release` builds signed installers for every platform and
|
||||||
|
# creates or updates the draft GitHub Release "VectorCraft v<version>". See docs/releasing.md.
|
||||||
|
#
|
||||||
|
# All jobs run in the `release` environment (restricted to the `release` branch), which holds
|
||||||
|
# the signing secrets. Every secret is optional: missing ones produce unsigned artifacts and a
|
||||||
|
# warning, never a failed build.
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [release]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
version:
|
||||||
|
description: "Version override for a test run, e.g. 0.2.0-rc.1 (empty: Cargo.toml)"
|
||||||
|
type: string
|
||||||
|
default: ""
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: release-${{ github.ref }}
|
||||||
|
# Never cancel a run mid-notarization or mid-upload; a newer push waits its turn.
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
CARGO_TERM_COLOR: always
|
||||||
|
CARGO_INCREMENTAL: 0
|
||||||
|
RUST_BACKTRACE: 1
|
||||||
|
VECTORCRAFT_BUILD_SHA: ${{ github.sha }}
|
||||||
|
INPUT_VERSION: ${{ inputs.version }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
version:
|
||||||
|
name: version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: release
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.v.outputs.version }}
|
||||||
|
date: ${{ steps.v.outputs.date }}
|
||||||
|
prerelease: ${{ steps.v.outputs.prerelease }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- id: v
|
||||||
|
name: Resolve version
|
||||||
|
run: |
|
||||||
|
. packaging/env.sh
|
||||||
|
v="${INPUT_VERSION#v}"
|
||||||
|
v="${v:-$VERSION}"
|
||||||
|
if ! printf '%s' "$v" | grep -Eq '^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$'; then
|
||||||
|
echo "::error::'$v' is not a version like 1.2.3 or 1.2.3-rc.1"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
case "$v" in *-*) pre=true ;; *) pre=false ;; esac
|
||||||
|
{
|
||||||
|
echo "version=$v"
|
||||||
|
echo "date=$(date -u +%Y-%m-%d)"
|
||||||
|
echo "prerelease=$pre"
|
||||||
|
} >>"$GITHUB_OUTPUT"
|
||||||
|
echo "### VectorCraft v$v (\`${GITHUB_SHA::9}\`)" >>"$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
|
macos:
|
||||||
|
name: macOS universal
|
||||||
|
needs: version
|
||||||
|
runs-on: macos-15
|
||||||
|
environment: release
|
||||||
|
env:
|
||||||
|
VECTORCRAFT_VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
VECTORCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: aarch64-apple-darwin, x86_64-apple-darwin
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
key: release-macos-universal
|
||||||
|
- name: Apply version override
|
||||||
|
if: inputs.version != ''
|
||||||
|
run: cargo xtask version set "$VECTORCRAFT_VERSION"
|
||||||
|
- name: Import signing certificate
|
||||||
|
env:
|
||||||
|
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
|
||||||
|
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
|
||||||
|
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
|
||||||
|
run: packaging/macos/import-cert.sh
|
||||||
|
- name: Build, sign, notarize
|
||||||
|
env:
|
||||||
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||||
|
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
|
||||||
|
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
|
||||||
|
run: packaging/macos/package.sh --arch universal
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release-macos
|
||||||
|
path: dist/release/*
|
||||||
|
if-no-files-found: error
|
||||||
|
- name: Remove temporary keychain
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
if [ -n "${MACOS_KEYCHAIN:-}" ]; then security delete-keychain "$MACOS_KEYCHAIN" || true; fi
|
||||||
|
|
||||||
|
windows:
|
||||||
|
name: Windows ${{ matrix.arch }}
|
||||||
|
needs: version
|
||||||
|
runs-on: windows-latest
|
||||||
|
environment: release
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- { arch: x64, target: x86_64-pc-windows-msvc }
|
||||||
|
- { arch: x86, target: i686-pc-windows-msvc }
|
||||||
|
env:
|
||||||
|
VECTORCRAFT_VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
VECTORCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: ${{ matrix.target }}
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
key: release-windows-${{ matrix.arch }}
|
||||||
|
- name: Apply version override
|
||||||
|
if: inputs.version != ''
|
||||||
|
shell: bash
|
||||||
|
run: cargo xtask version set "$VECTORCRAFT_VERSION"
|
||||||
|
- name: Install WiX
|
||||||
|
shell: pwsh
|
||||||
|
run: dotnet tool install --global wix --version 5.0.2
|
||||||
|
- name: Build, sign, package
|
||||||
|
shell: pwsh
|
||||||
|
env:
|
||||||
|
WINDOWS_CERTIFICATE: ${{ secrets.WINDOWS_CERTIFICATE }}
|
||||||
|
WINDOWS_CERTIFICATE_PASSWORD: ${{ secrets.WINDOWS_CERTIFICATE_PASSWORD }}
|
||||||
|
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
|
||||||
|
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
|
||||||
|
AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }}
|
||||||
|
AZURE_SIGNING_ENDPOINT: ${{ secrets.AZURE_SIGNING_ENDPOINT }}
|
||||||
|
AZURE_SIGNING_ACCOUNT: ${{ secrets.AZURE_SIGNING_ACCOUNT }}
|
||||||
|
AZURE_CERT_PROFILE: ${{ secrets.AZURE_CERT_PROFILE }}
|
||||||
|
run: ./packaging/windows/package.ps1 -Arch ${{ matrix.arch }}
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release-windows-${{ matrix.arch }}
|
||||||
|
path: dist/release/*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
linux:
|
||||||
|
name: Linux ${{ matrix.arch }}
|
||||||
|
needs: version
|
||||||
|
# The oldest GitHub-hosted image, so the binaries only need glibc >= 2.35 (Ubuntu 22.04+,
|
||||||
|
# Debian 12+, Fedora 36+, RHEL 10). See docs/releasing.md.
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
environment: release
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- { arch: x86_64, runner: ubuntu-22.04, deb: amd64 }
|
||||||
|
- { arch: aarch64, runner: ubuntu-22.04-arm, deb: arm64 }
|
||||||
|
env:
|
||||||
|
VECTORCRAFT_VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
VECTORCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
|
||||||
|
NFPM_VERSION: 2.47.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Install build and packaging tools
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
libxkbcommon-dev libwayland-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev \
|
||||||
|
desktop-file-utils appstream python3-yaml
|
||||||
|
curl -fsSL -o "$RUNNER_TEMP/nfpm.deb" \
|
||||||
|
"https://github.com/goreleaser/nfpm/releases/download/v${NFPM_VERSION}/nfpm_${NFPM_VERSION}_${{ matrix.deb }}.deb"
|
||||||
|
sudo dpkg -i "$RUNNER_TEMP/nfpm.deb"
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
key: release-linux-${{ matrix.arch }}
|
||||||
|
- name: Apply version override
|
||||||
|
if: inputs.version != ''
|
||||||
|
run: cargo xtask version set "$VECTORCRAFT_VERSION"
|
||||||
|
- name: Build and package (AppImage, deb, rpm, tar.gz)
|
||||||
|
run: packaging/linux/package.sh
|
||||||
|
- name: Check the packages
|
||||||
|
run: |
|
||||||
|
dpkg-deb --info dist/release/*.deb
|
||||||
|
dpkg-deb --contents dist/release/*.deb | grep -E 'usr/bin/vectorcraft$|metainfo|applications'
|
||||||
|
ldd target/release/vectorcraft
|
||||||
|
python3 -c "import yaml; m = yaml.safe_load(open('packaging/linux/flatpak/ai.storyteller.vectorcraft.yml')); assert m['id'] == 'ai.storyteller.vectorcraft'"
|
||||||
|
for appimage in dist/release/*.AppImage; do
|
||||||
|
chmod +x "$appimage"
|
||||||
|
APPIMAGE_EXTRACT_AND_RUN=1 "$appimage" --version
|
||||||
|
done
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release-linux-${{ matrix.arch }}
|
||||||
|
path: dist/release/*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
web:
|
||||||
|
name: Web (wasm)
|
||||||
|
needs: version
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: release
|
||||||
|
env:
|
||||||
|
VECTORCRAFT_VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
VECTORCRAFT_BUILD_DATE: ${{ needs.version.outputs.date }}
|
||||||
|
TRUNK_VERSION: 0.21.14
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
targets: wasm32-unknown-unknown
|
||||||
|
- uses: Swatinem/rust-cache@v2
|
||||||
|
with:
|
||||||
|
key: release-web
|
||||||
|
- name: Install trunk
|
||||||
|
run: |
|
||||||
|
curl -fsSL "https://github.com/trunk-rs/trunk/releases/download/v${TRUNK_VERSION}/trunk-x86_64-unknown-linux-gnu.tar.gz" \
|
||||||
|
| tar -xz -C "$HOME/.cargo/bin" trunk
|
||||||
|
trunk --version
|
||||||
|
- name: Apply version override
|
||||||
|
if: inputs.version != ''
|
||||||
|
run: cargo xtask version set "$VECTORCRAFT_VERSION"
|
||||||
|
- name: Build and zip
|
||||||
|
run: packaging/web/package.sh
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: release-web
|
||||||
|
path: dist/release/*
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
release:
|
||||||
|
name: Draft GitHub Release
|
||||||
|
needs: [version, macos, windows, linux, web]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
environment: release
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
env:
|
||||||
|
VERSION: ${{ needs.version.outputs.version }}
|
||||||
|
PRERELEASE: ${{ needs.version.outputs.prerelease }}
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GH_REPO: ${{ github.repository }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
pattern: release-*
|
||||||
|
path: artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
- name: Checksums
|
||||||
|
working-directory: artifacts
|
||||||
|
run: |
|
||||||
|
sha256sum -- * | tee SHA256SUMS.txt
|
||||||
|
- name: Create or update the draft release
|
||||||
|
working-directory: artifacts
|
||||||
|
run: |
|
||||||
|
tag="v$VERSION"
|
||||||
|
title="VectorCraft v$VERSION"
|
||||||
|
pre=()
|
||||||
|
if [ "$PRERELEASE" = true ]; then pre=(--prerelease); fi
|
||||||
|
if draft="$(gh release view "$tag" --json isDraft --jq .isDraft 2>/dev/null)"; then
|
||||||
|
if [ "$draft" != "true" ]; then
|
||||||
|
echo "::error::Release $tag is already published. Bump the version (cargo xtask version set) before pushing to release."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Updating draft $tag: replacing its assets"
|
||||||
|
gh release view "$tag" --json assets --jq '.assets[].name' | while read -r asset; do
|
||||||
|
gh release delete-asset "$tag" "$asset" --yes
|
||||||
|
done
|
||||||
|
gh release edit "$tag" --draft --title "$title" --target "$GITHUB_SHA" --prerelease="$PRERELEASE"
|
||||||
|
gh release upload "$tag" --clobber -- *
|
||||||
|
else
|
||||||
|
echo "Creating draft $tag"
|
||||||
|
gh release create "$tag" --draft --title "$title" --target "$GITHUB_SHA" --generate-notes "${pre[@]}" -- *
|
||||||
|
fi
|
||||||
|
{
|
||||||
|
echo "Draft release **$title** at \`${GITHUB_SHA::9}\`:"
|
||||||
|
echo
|
||||||
|
sed 's/^/ /' SHA256SUMS.txt
|
||||||
|
} >>"$GITHUB_STEP_SUMMARY"
|
||||||
|
|
@ -49,9 +49,8 @@
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> **ArtCraft is a community of artists from all walks of life.** Painters, photographers,
|
> **ArtCraft is a community of artists from all walks of life.** Digital, generative, music,
|
||||||
> filmmakers, illustrators, designers, animators, hobbyists, and people who picked up a pencil
|
> games — if you make things, you're one of us. **[Come say hi on Discord](https://discord.gg/artcraft).**
|
||||||
> last week. If you make things, you're one of us. **[Come say hi on Discord](https://discord.gg/artcraft).**
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="#a-look-around">A look around</a> ·
|
<a href="#a-look-around">A look around</a> ·
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# shellcheck config for the packaging scripts (CI: .github/workflows/packaging-lint.yml).
|
||||||
|
source-path=SCRIPTDIR
|
||||||
|
external-sources=true
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
# Shared setup for the packaging scripts. Source it: `. "$(dirname "$0")/../env.sh"`.
|
||||||
|
#
|
||||||
|
# Exports:
|
||||||
|
# ROOT workspace root
|
||||||
|
# VERSION [workspace.package] version from Cargo.toml (override: VECTORCRAFT_VERSION)
|
||||||
|
# DIST output directory for release artifacts (default: $ROOT/dist/release)
|
||||||
|
# VECTORCRAFT_BUILD_SHA git commit baked into the binaries (see crates/engine/src/build_info.rs)
|
||||||
|
# VECTORCRAFT_BUILD_DATE UTC build date, YYYY-MM-DD
|
||||||
|
# CARGO_TARGET_DIR cargo's target dir (default: $ROOT/target)
|
||||||
|
|
||||||
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
export ROOT
|
||||||
|
|
||||||
|
# The version lives in exactly one place: `[workspace.package] version` in the root Cargo.toml.
|
||||||
|
# (`cargo xtask version` prints the same thing; awk avoids compiling xtask here.)
|
||||||
|
workspace_version() {
|
||||||
|
awk '
|
||||||
|
/^\[/ { in_pkg = ($0 == "[workspace.package]") ; next }
|
||||||
|
in_pkg && $1 == "version" { gsub(/[" ]/, "", $3); print $3; exit }
|
||||||
|
' "$ROOT/Cargo.toml"
|
||||||
|
}
|
||||||
|
|
||||||
|
VERSION="${VECTORCRAFT_VERSION:-$(workspace_version)}"
|
||||||
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "error: could not read [workspace.package] version from $ROOT/Cargo.toml" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
export VERSION
|
||||||
|
|
||||||
|
DIST="${DIST:-$ROOT/dist/release}"
|
||||||
|
mkdir -p "$DIST"
|
||||||
|
export DIST
|
||||||
|
|
||||||
|
if [ -z "${VECTORCRAFT_BUILD_SHA:-}" ]; then
|
||||||
|
VECTORCRAFT_BUILD_SHA="$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || true)"
|
||||||
|
fi
|
||||||
|
export VECTORCRAFT_BUILD_SHA
|
||||||
|
export VECTORCRAFT_BUILD_DATE="${VECTORCRAFT_BUILD_DATE:-$(date -u +%Y-%m-%d)}"
|
||||||
|
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$ROOT/target}"
|
||||||
|
|
||||||
|
# Emit a GitHub Actions warning (plain stderr outside Actions).
|
||||||
|
warn() {
|
||||||
|
if [ -n "${GITHUB_ACTIONS:-}" ]; then echo "::warning::$*"; else echo "warning: $*" >&2; fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy licence and readme files that exist into a package directory.
|
||||||
|
copy_docs() {
|
||||||
|
local dest="$1" f
|
||||||
|
for f in README.md LICENSE LICENSE-MIT LICENSE-APACHE COPYRIGHT; do
|
||||||
|
if [ -f "$ROOT/$f" ]; then cp "$ROOT/$f" "$dest/"; fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# Portable SHA-256 of a file (prints just the hash).
|
||||||
|
sha256() {
|
||||||
|
if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- AppStream metadata (software centres, Flathub). Template: package.sh and the Flatpak
|
||||||
|
manifest substitute @VERSION@ and @DATE@ from Cargo.toml and the build date. -->
|
||||||
|
<component type="desktop-application">
|
||||||
|
<id>ai.storyteller.vectorcraft</id>
|
||||||
|
<metadata_license>CC0-1.0</metadata_license>
|
||||||
|
<project_license>MIT OR Apache-2.0</project_license>
|
||||||
|
<name>VectorCraft</name>
|
||||||
|
<summary>Draw and edit vector illustrations, SVG and PDF</summary>
|
||||||
|
<developer id="ai.storyteller">
|
||||||
|
<name>Learning Machines LLC</name>
|
||||||
|
</developer>
|
||||||
|
<description>
|
||||||
|
<p>
|
||||||
|
VectorCraft is a vector graphics editor. Draw and edit vector illustrations, SVG and PDF
|
||||||
|
</p>
|
||||||
|
</description>
|
||||||
|
<launchable type="desktop-id">ai.storyteller.vectorcraft.desktop</launchable>
|
||||||
|
<icon type="stock">ai.storyteller.vectorcraft</icon>
|
||||||
|
<!-- Only url types known to appstream 0.15 (Ubuntu 22.04, where CI validates): no vcs-browser. -->
|
||||||
|
<url type="homepage">https://getartcraft.com/apps/vectorcraft</url>
|
||||||
|
<url type="bugtracker">https://github.com/storytold/vectorcraft/issues</url>
|
||||||
|
<url type="help">https://github.com/storytold/vectorcraft</url>
|
||||||
|
<url type="contact">https://discord.gg/artcraft</url>
|
||||||
|
<categories>
|
||||||
|
<category>Graphics</category>
|
||||||
|
<category>RasterGraphics</category>
|
||||||
|
<category>Photography</category>
|
||||||
|
</categories>
|
||||||
|
<keywords>
|
||||||
|
<keyword>photo</keyword>
|
||||||
|
<keyword>image editor</keyword>
|
||||||
|
<keyword>psd</keyword>
|
||||||
|
<keyword>layers</keyword>
|
||||||
|
</keywords>
|
||||||
|
<screenshots>
|
||||||
|
<screenshot type="default">
|
||||||
|
<caption>Editing The Great Wave off Kanagawa with type layers and adjustment layers</caption>
|
||||||
|
<image>https://raw.githubusercontent.com/storytold/vectorcraft/main/docs/images/vectorcraft-demo.jpg</image>
|
||||||
|
</screenshot>
|
||||||
|
</screenshots>
|
||||||
|
<branding>
|
||||||
|
<color type="primary" scheme_preference="light">#9fd0ff</color>
|
||||||
|
<color type="primary" scheme_preference="dark">#1f64ba</color>
|
||||||
|
</branding>
|
||||||
|
<requires>
|
||||||
|
<display_length compare="ge">760</display_length>
|
||||||
|
</requires>
|
||||||
|
<supports>
|
||||||
|
<control>keyboard</control>
|
||||||
|
<control>pointing</control>
|
||||||
|
<control>tablet</control>
|
||||||
|
</supports>
|
||||||
|
<provides>
|
||||||
|
<binary>vectorcraft</binary>
|
||||||
|
</provides>
|
||||||
|
<content_rating type="oars-1.1"/>
|
||||||
|
<releases>
|
||||||
|
<release version="@VERSION@" date="@DATE@"/>
|
||||||
|
</releases>
|
||||||
|
</component>
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||||
|
</mime-info>
|
||||||
|
|
@ -0,0 +1,56 @@
|
||||||
|
# Flatpak manifest for VectorCraft, ready for a Flathub submission.
|
||||||
|
#
|
||||||
|
# Flatpak builds run offline, so the crate sources must be vendored first. From the repo root:
|
||||||
|
#
|
||||||
|
# curl -fsSLO https://raw.githubusercontent.com/flatpak/flatpak-builder-tools/master/cargo/flatpak-cargo-generator.py
|
||||||
|
# python3 flatpak-cargo-generator.py Cargo.lock -o packaging/linux/flatpak/cargo-sources.json
|
||||||
|
# flatpak-builder --user --install --force-clean build-flatpak packaging/linux/flatpak/ai.storyteller.vectorcraft.yml
|
||||||
|
# flatpak run ai.storyteller.vectorcraft
|
||||||
|
#
|
||||||
|
# For Flathub, replace the `dir` source with a `git` source pinned to a release tag and commit.
|
||||||
|
id: ai.storyteller.vectorcraft
|
||||||
|
runtime: org.freedesktop.Platform
|
||||||
|
runtime-version: '25.08'
|
||||||
|
sdk: org.freedesktop.Sdk
|
||||||
|
sdk-extensions:
|
||||||
|
- org.freedesktop.Sdk.Extension.rust-stable
|
||||||
|
command: vectorcraft
|
||||||
|
finish-args:
|
||||||
|
- --share=ipc
|
||||||
|
- --socket=wayland
|
||||||
|
- --socket=fallback-x11
|
||||||
|
- --device=dri
|
||||||
|
# Open/Save dialogs use the file-chooser portal (rfd), and drag-and-drop uses the document
|
||||||
|
# portal, so broad filesystem access isn't needed. Pictures is granted for opening files by
|
||||||
|
# path from the command line.
|
||||||
|
- --filesystem=xdg-pictures
|
||||||
|
build-options:
|
||||||
|
append-path: /usr/lib/sdk/rust-stable/bin
|
||||||
|
modules:
|
||||||
|
- name: vectorcraft
|
||||||
|
buildsystem: simple
|
||||||
|
build-options:
|
||||||
|
env:
|
||||||
|
CARGO_HOME: /run/build/vectorcraft/cargo
|
||||||
|
CARGO_NET_OFFLINE: 'true'
|
||||||
|
build-commands:
|
||||||
|
- cargo --offline build --release --locked -p vectorcraft
|
||||||
|
- install -Dm755 target/release/vectorcraft /app/bin/vectorcraft
|
||||||
|
- install -Dm644 packaging/linux/ai.storyteller.vectorcraft.desktop /app/share/applications/ai.storyteller.vectorcraft.desktop
|
||||||
|
- install -Dm644 packaging/linux/ai.storyteller.vectorcraft.mime.xml /app/share/mime/packages/ai.storyteller.vectorcraft.xml
|
||||||
|
- mkdir -p /app/share/icons && cp -R assets/app-icon/hicolor /app/share/icons/
|
||||||
|
- >-
|
||||||
|
version=$(awk '/^\[/{p=($0=="[workspace.package]");next} p&&$1=="version"{gsub(/[" ]/,"",$3);print $3;exit}' Cargo.toml);
|
||||||
|
install -d /app/share/metainfo;
|
||||||
|
sed -e "s/@VERSION@/$version/" -e "s/@DATE@/$(date -u +%Y-%m-%d)/"
|
||||||
|
packaging/linux/ai.storyteller.vectorcraft.metainfo.xml.in > /app/share/metainfo/ai.storyteller.vectorcraft.metainfo.xml
|
||||||
|
sources:
|
||||||
|
- type: dir
|
||||||
|
path: ../../..
|
||||||
|
skip:
|
||||||
|
- target
|
||||||
|
- dist
|
||||||
|
- corpus
|
||||||
|
- build-flatpak
|
||||||
|
- .flatpak-builder
|
||||||
|
- cargo-sources.json
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
# .deb and .rpm packages (nfpm: https://nfpm.goreleaser.com). Run by package.sh, which stages
|
||||||
|
# the file tree, substitutes its path for ${STAGE} (nfpm doesn't expand env vars in `src`) and
|
||||||
|
# exports VERSION and NFPM_ARCH.
|
||||||
|
#
|
||||||
|
# nfpm package -f packaging/linux/nfpm.yaml -p deb -t dist/release/
|
||||||
|
name: vectorcraft
|
||||||
|
arch: ${NFPM_ARCH}
|
||||||
|
platform: linux
|
||||||
|
version: ${VERSION}
|
||||||
|
# semver: 0.2.0-rc.1 becomes 0.2.0~rc.1 in deb/rpm, so pre-releases sort before the release.
|
||||||
|
version_schema: semver
|
||||||
|
release: 1
|
||||||
|
section: graphics
|
||||||
|
priority: optional
|
||||||
|
maintainer: ${VECTORCRAFT_MAINTAINER}
|
||||||
|
vendor: Learning Machines LLC
|
||||||
|
homepage: https://getartcraft.com/apps/vectorcraft
|
||||||
|
license: MIT OR Apache-2.0
|
||||||
|
description: |-
|
||||||
|
Open-source, native image editor that works the way Photoshop users expect.
|
||||||
|
Layers, masks, adjustment layers, layer styles, type and brushes; opens and
|
||||||
|
saves layered PSD/PSB files; 8/16/32-bit documents; GPU compositing (wgpu).
|
||||||
|
Includes vectorcraft-cli, a headless converter and command runner.
|
||||||
|
|
||||||
|
# The binaries link only glibc and libgcc_s directly. Windowing (X11/Wayland, xkbcommon) and the
|
||||||
|
# GPU (Vulkan, EGL/GL) are loaded at runtime, so they are dependencies/recommendations here
|
||||||
|
# rather than ELF NEEDED entries.
|
||||||
|
overrides:
|
||||||
|
deb:
|
||||||
|
depends:
|
||||||
|
- libc6 (>= 2.35)
|
||||||
|
- libgcc-s1
|
||||||
|
- libxkbcommon0
|
||||||
|
- libvulkan1 | libegl1
|
||||||
|
recommends:
|
||||||
|
- libwayland-client0
|
||||||
|
- libx11-6
|
||||||
|
- libx11-xcb1
|
||||||
|
- libxcursor1
|
||||||
|
- libxi6
|
||||||
|
- libxrandr2
|
||||||
|
- mesa-vulkan-drivers
|
||||||
|
- xdg-desktop-portal
|
||||||
|
rpm:
|
||||||
|
depends:
|
||||||
|
- libxkbcommon
|
||||||
|
- (vulkan-loader or libglvnd-egl)
|
||||||
|
recommends:
|
||||||
|
- libwayland-client
|
||||||
|
- libX11
|
||||||
|
- libXcursor
|
||||||
|
- libXi
|
||||||
|
- libXrandr
|
||||||
|
- mesa-vulkan-drivers
|
||||||
|
- xdg-desktop-portal
|
||||||
|
|
||||||
|
contents:
|
||||||
|
- src: ${STAGE}/usr/bin/vectorcraft
|
||||||
|
dst: /usr/bin/vectorcraft
|
||||||
|
file_info: { mode: 0755 }
|
||||||
|
- src: ${STAGE}/usr/bin/vectorcraft-cli
|
||||||
|
dst: /usr/bin/vectorcraft-cli
|
||||||
|
file_info: { mode: 0755 }
|
||||||
|
- src: ${STAGE}/usr/share/
|
||||||
|
dst: /usr/share/
|
||||||
|
type: tree
|
||||||
|
|
||||||
|
scripts:
|
||||||
|
postinstall: packaging/linux/postinst.sh
|
||||||
|
postremove: packaging/linux/postinst.sh
|
||||||
|
|
@ -0,0 +1,120 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build and package VectorCraft for Linux (<arch> is x86_64 or aarch64):
|
||||||
|
#
|
||||||
|
# $DIST/vectorcraft-<version>-linux-<arch>.AppImage any distro with glibc >= the build host's
|
||||||
|
# $DIST/vectorcraft-<version>-linux-<arch>.deb Debian, Ubuntu, Mint, Pop!_OS, ...
|
||||||
|
# $DIST/vectorcraft-<version>-linux-<arch>.rpm Fedora, openSUSE, RHEL, ...
|
||||||
|
# $DIST/vectorcraft-<version>-linux-<arch>.tar.gz plain FHS-style tree (bin/, share/)
|
||||||
|
#
|
||||||
|
# Usage: packaging/linux/package.sh [--skip-build] [--formats "appimage deb rpm tar"]
|
||||||
|
#
|
||||||
|
# Needs: cargo; nfpm for deb/rpm (https://nfpm.goreleaser.com); appimagetool for the AppImage
|
||||||
|
# (downloaded into $CARGO_TARGET_DIR if missing). Build on an old distro (CI: Ubuntu 22.04,
|
||||||
|
# glibc 2.35) so the binaries run on newer ones. Optional: desktop-file-validate, appstreamcli.
|
||||||
|
set -euo pipefail
|
||||||
|
# shellcheck source=../env.sh
|
||||||
|
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
|
||||||
|
HERE="$ROOT/packaging/linux"
|
||||||
|
APP_ID=ai.storyteller.vectorcraft
|
||||||
|
|
||||||
|
SKIP_BUILD=0
|
||||||
|
FORMATS="appimage deb rpm tar"
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--skip-build) SKIP_BUILD=1; shift ;;
|
||||||
|
--formats) FORMATS="$2"; shift 2 ;;
|
||||||
|
-h | --help) sed -n '2,15p' "$0"; exit 0 ;;
|
||||||
|
*) echo "unknown argument: $1" >&2; exit 2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
ARCH="$(uname -m)"
|
||||||
|
case "$ARCH" in
|
||||||
|
x86_64) DEB_ARCH=amd64 ;;
|
||||||
|
aarch64 | arm64) ARCH=aarch64; DEB_ARCH=arm64 ;;
|
||||||
|
*) echo "unsupported architecture $ARCH" >&2; exit 2 ;;
|
||||||
|
esac
|
||||||
|
export VECTORCRAFT_MAINTAINER="${VECTORCRAFT_MAINTAINER:-VectorCraft maintainers <vectorcraft@storyteller.ai>}"
|
||||||
|
BASENAME="vectorcraft-$VERSION-linux-$ARCH"
|
||||||
|
|
||||||
|
echo "==> VectorCraft $VERSION for Linux $ARCH ($FORMATS)"
|
||||||
|
|
||||||
|
if [ "$SKIP_BUILD" = 0 ]; then
|
||||||
|
(cd "$ROOT" && cargo build --release --locked -p vectorcraft -p vectorcraft-cli)
|
||||||
|
fi
|
||||||
|
BIN="$CARGO_TARGET_DIR/release"
|
||||||
|
WORK="$CARGO_TARGET_DIR/linux-package"
|
||||||
|
STAGE="$WORK/root"
|
||||||
|
rm -rf "$WORK"
|
||||||
|
|
||||||
|
# ---- stage an FHS tree (shared by every format) -------------------------------------------------
|
||||||
|
install -Dm755 "$BIN/vectorcraft" "$STAGE/usr/bin/vectorcraft"
|
||||||
|
install -Dm755 "$BIN/vectorcraft-cli" "$STAGE/usr/bin/vectorcraft-cli"
|
||||||
|
strip "$STAGE/usr/bin/vectorcraft" "$STAGE/usr/bin/vectorcraft-cli" 2>/dev/null || true
|
||||||
|
install -Dm644 "$HERE/$APP_ID.desktop" "$STAGE/usr/share/applications/$APP_ID.desktop"
|
||||||
|
install -Dm644 "$HERE/$APP_ID.mime.xml" "$STAGE/usr/share/mime/packages/$APP_ID.xml"
|
||||||
|
mkdir -p "$STAGE/usr/share/metainfo"
|
||||||
|
sed -e "s/@VERSION@/$VERSION/g" -e "s/@DATE@/$VECTORCRAFT_BUILD_DATE/g" \
|
||||||
|
"$HERE/$APP_ID.metainfo.xml.in" >"$STAGE/usr/share/metainfo/$APP_ID.metainfo.xml"
|
||||||
|
mkdir -p "$STAGE/usr/share/icons"
|
||||||
|
cp -R "$ROOT/assets/app-icon/hicolor" "$STAGE/usr/share/icons/"
|
||||||
|
mkdir -p "$STAGE/usr/share/doc/vectorcraft"
|
||||||
|
copy_docs "$STAGE/usr/share/doc/vectorcraft"
|
||||||
|
|
||||||
|
if command -v desktop-file-validate >/dev/null; then
|
||||||
|
desktop-file-validate "$STAGE/usr/share/applications/$APP_ID.desktop"
|
||||||
|
fi
|
||||||
|
if command -v appstreamcli >/dev/null; then
|
||||||
|
appstreamcli validate --no-net --explain "$STAGE/usr/share/metainfo/$APP_ID.metainfo.xml"
|
||||||
|
fi
|
||||||
|
|
||||||
|
has() { case " $FORMATS " in *" $1 "*) return 0 ;; *) return 1 ;; esac; }
|
||||||
|
|
||||||
|
# ---- .tar.gz ------------------------------------------------------------------------------------
|
||||||
|
if has tar; then
|
||||||
|
mkdir -p "$WORK/tar"
|
||||||
|
cp -R "$STAGE/usr" "$WORK/tar/$BASENAME"
|
||||||
|
tar -C "$WORK/tar" -czf "$DIST/$BASENAME.tar.gz" "$BASENAME"
|
||||||
|
echo "wrote $DIST/$BASENAME.tar.gz"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- .deb / .rpm --------------------------------------------------------------------------------
|
||||||
|
if has deb || has rpm; then
|
||||||
|
command -v nfpm >/dev/null || { echo "error: nfpm not found (https://nfpm.goreleaser.com/install/)" >&2; exit 1; }
|
||||||
|
export VERSION
|
||||||
|
export NFPM_ARCH="$DEB_ARCH"
|
||||||
|
# nfpm expands env vars in fields like `version` and `arch`, but not in `contents[].src`.
|
||||||
|
sed "s|\${STAGE}|$STAGE|g" "$HERE/nfpm.yaml" >"$WORK/nfpm.yaml"
|
||||||
|
for fmt in deb rpm; do
|
||||||
|
if has "$fmt"; then (cd "$ROOT" && nfpm package -f "$WORK/nfpm.yaml" -p "$fmt" -t "$DIST/$BASENAME.$fmt"); fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- AppImage -----------------------------------------------------------------------------------
|
||||||
|
if has appimage; then
|
||||||
|
APPDIR="$WORK/VectorCraft.AppDir"
|
||||||
|
cp -R "$STAGE" "$APPDIR"
|
||||||
|
mv "$APPDIR/usr/share/doc" "$WORK/doc-unused"
|
||||||
|
ln -s usr/bin/vectorcraft "$APPDIR/AppRun"
|
||||||
|
cp "$HERE/$APP_ID.desktop" "$APPDIR/$APP_ID.desktop"
|
||||||
|
cp "$ROOT/assets/app-icon/hicolor/256x256/apps/$APP_ID.png" "$APPDIR/$APP_ID.png"
|
||||||
|
ln -s "$APP_ID.png" "$APPDIR/.DirIcon"
|
||||||
|
|
||||||
|
TOOL="${APPIMAGETOOL:-$(command -v appimagetool || true)}"
|
||||||
|
if [ -z "$TOOL" ]; then
|
||||||
|
TOOL="$CARGO_TARGET_DIR/appimagetool-$ARCH.AppImage"
|
||||||
|
if [ ! -x "$TOOL" ]; then
|
||||||
|
curl -fsSL -o "$TOOL" "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-$ARCH.AppImage"
|
||||||
|
chmod +x "$TOOL"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
OUT="$DIST/$BASENAME.AppImage"
|
||||||
|
# Extract-and-run: works without FUSE (containers, CI). The output embeds the static runtime,
|
||||||
|
# so users don't need libfuse2 either.
|
||||||
|
ARCH="$ARCH" APPIMAGE_EXTRACT_AND_RUN=1 "$TOOL" --no-appstream "$APPDIR" "$OUT"
|
||||||
|
echo "wrote $OUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
"$STAGE/usr/bin/vectorcraft-cli" --version
|
||||||
|
echo "==> done"
|
||||||
|
ls -lh "$DIST"
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# deb/rpm post-install and post-remove: refresh the desktop, MIME and icon caches.
|
||||||
|
# Every tool is optional; missing ones are skipped.
|
||||||
|
if command -v update-desktop-database >/dev/null 2>&1; then
|
||||||
|
update-desktop-database -q /usr/share/applications || true
|
||||||
|
fi
|
||||||
|
if command -v update-mime-database >/dev/null 2>&1; then
|
||||||
|
update-mime-database /usr/share/mime || true
|
||||||
|
fi
|
||||||
|
if command -v gtk-update-icon-cache >/dev/null 2>&1; then
|
||||||
|
gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor || true
|
||||||
|
fi
|
||||||
|
exit 0
|
||||||
|
|
@ -0,0 +1,149 @@
|
||||||
|
<?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">
|
||||||
|
<!-- Template: packaging/macos/package.sh substitutes @VERSION@ (full, e.g. 0.2.0-rc.1),
|
||||||
|
@SHORT_VERSION@ (numeric X.Y.Z) and @BUILD_SHA@. -->
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleDevelopmentRegion</key>
|
||||||
|
<string>en</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>VectorCraft</string>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>VectorCraft</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>VectorCraft</string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>ai.storyteller.vectorcraft</string>
|
||||||
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
|
<string>6.0</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleSignature</key>
|
||||||
|
<string>????</string>
|
||||||
|
<key>CFBundleShortVersionString</key>
|
||||||
|
<string>@SHORT_VERSION@</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>@SHORT_VERSION@</string>
|
||||||
|
<key>VectorCraftVersion</key>
|
||||||
|
<string>@VERSION@</string>
|
||||||
|
<key>VectorCraftBuildCommit</key>
|
||||||
|
<string>@BUILD_SHA@</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>VectorCraft</string>
|
||||||
|
<key>LSApplicationCategoryType</key>
|
||||||
|
<string>public.app-category.graphics-design</string>
|
||||||
|
<!-- Must match MACOSX_DEPLOYMENT_TARGET in package.sh. Big Sur is the first release on
|
||||||
|
Apple silicon and has the Metal feature set wgpu targets. -->
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>11.0</string>
|
||||||
|
<key>NSHighResolutionCapable</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||||
|
<true/>
|
||||||
|
<key>NSRequiresAquaSystemAppearance</key>
|
||||||
|
<false/>
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright © the VectorCraft authors. MIT OR Apache-2.0.</string>
|
||||||
|
|
||||||
|
<!-- Vectorcraft's own format. -->
|
||||||
|
<key>UTExportedTypeDeclarations</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>ai.storyteller.vectorcraft.document</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>VectorCraft Document</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
<string>public.image</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeIconFile</key>
|
||||||
|
<string>VectorCraft</string>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array><string>pcraft</string></array>
|
||||||
|
<key>public.mime-type</key>
|
||||||
|
<array><string>application/x-vectorcraft</string></array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<!-- Types macOS may not know; the system's own declaration wins when it has one. -->
|
||||||
|
<key>UTImportedTypeDeclarations</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>com.adobe.photoshop-large-image</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>Photoshop Large Document</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
<string>public.image</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array><string>psb</string></array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>UTTypeIdentifier</key>
|
||||||
|
<string>ai.storyteller.vectorcraft.qoi</string>
|
||||||
|
<key>UTTypeDescription</key>
|
||||||
|
<string>QOI Image</string>
|
||||||
|
<key>UTTypeConformsTo</key>
|
||||||
|
<array>
|
||||||
|
<string>public.data</string>
|
||||||
|
<string>public.image</string>
|
||||||
|
</array>
|
||||||
|
<key>UTTypeTagSpecification</key>
|
||||||
|
<dict>
|
||||||
|
<key>public.filename-extension</key>
|
||||||
|
<array><string>qoi</string></array>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Photoshop Document</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Alternate</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>com.adobe.photoshop-image</string>
|
||||||
|
<string>com.adobe.photoshop-large-image</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeName</key>
|
||||||
|
<string>Image</string>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Editor</string>
|
||||||
|
<key>LSHandlerRank</key>
|
||||||
|
<string>Alternate</string>
|
||||||
|
<key>LSItemContentTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>public.png</string>
|
||||||
|
<string>public.jpeg</string>
|
||||||
|
<string>public.tiff</string>
|
||||||
|
<string>org.webmproject.webp</string>
|
||||||
|
<string>com.compuserve.gif</string>
|
||||||
|
<string>com.microsoft.bmp</string>
|
||||||
|
<string>com.truevision.tga-image</string>
|
||||||
|
<string>com.microsoft.ico</string>
|
||||||
|
<string>public.pbm</string>
|
||||||
|
<string>com.ilm.openexr-image</string>
|
||||||
|
<string>public.radiance</string>
|
||||||
|
<string>public.avif</string>
|
||||||
|
<string>ai.storyteller.vectorcraft.qoi</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?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">
|
||||||
|
<!-- Hardened-runtime entitlements for Vectorcraft. Deliberately empty: the app is pure Rust,
|
||||||
|
loads no unsigned code, needs no JIT, and is not sandboxed (it opens files by path, from the
|
||||||
|
command line and drag-and-drop). Add exceptions here only with a reason in a comment. -->
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# CI only: import the Developer ID certificate into a temporary keychain so codesign can use it.
|
||||||
|
#
|
||||||
|
# Inputs (env): APPLE_CERTIFICATE (base64 .p12), APPLE_CERTIFICATE_PASSWORD, KEYCHAIN_PASSWORD
|
||||||
|
# (optional; random if unset), RUNNER_TEMP (or TMPDIR).
|
||||||
|
# Outputs: MACOS_SIGN_IDENTITY (SHA-1 of the identity) and MACOS_KEYCHAIN, appended to
|
||||||
|
# $GITHUB_ENV when running in Actions, otherwise printed.
|
||||||
|
#
|
||||||
|
# Missing certificate: prints a warning and exits 0, so package.sh falls back to ad-hoc signing.
|
||||||
|
set -euo pipefail
|
||||||
|
umask 077
|
||||||
|
# shellcheck source=../env.sh
|
||||||
|
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
|
||||||
|
|
||||||
|
if [ -z "${APPLE_CERTIFICATE:-}" ]; then
|
||||||
|
warn "APPLE_CERTIFICATE is not set: macOS builds will be ad-hoc signed and not notarized"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
TMP="${RUNNER_TEMP:-${TMPDIR:-/tmp}}"
|
||||||
|
KEYCHAIN="$TMP/vectorcraft-signing.keychain-db"
|
||||||
|
CERT="$TMP/vectorcraft-signing.p12"
|
||||||
|
KC_PASS="${KEYCHAIN_PASSWORD:-$(openssl rand -hex 24)}"
|
||||||
|
|
||||||
|
trap 'rm -f "$CERT"' EXIT
|
||||||
|
printf '%s' "$APPLE_CERTIFICATE" | base64 --decode >"$CERT"
|
||||||
|
security create-keychain -p "$KC_PASS" "$KEYCHAIN"
|
||||||
|
security set-keychain-settings -lut 21600 "$KEYCHAIN"
|
||||||
|
security unlock-keychain -p "$KC_PASS" "$KEYCHAIN"
|
||||||
|
security import "$CERT" -P "${APPLE_CERTIFICATE_PASSWORD:-}" -T /usr/bin/codesign -T /usr/bin/security -t cert -f pkcs12 -k "$KEYCHAIN"
|
||||||
|
rm -f "$CERT"
|
||||||
|
# Let codesign use the key without a UI prompt.
|
||||||
|
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KC_PASS" "$KEYCHAIN" >/dev/null
|
||||||
|
# Put it on the search list (keeping the login keychain) so codesign and notarytool find it.
|
||||||
|
# shellcheck disable=SC2046
|
||||||
|
security list-keychains -d user -s "$KEYCHAIN" $(security list-keychains -d user | tr -d '"')
|
||||||
|
|
||||||
|
IDENTITY="$(security find-identity -v -p codesigning "$KEYCHAIN" | awk '/Developer ID Application/ { print $2; exit }')"
|
||||||
|
if [ -z "$IDENTITY" ]; then
|
||||||
|
security find-identity -v -p codesigning "$KEYCHAIN" >&2
|
||||||
|
echo "error: no 'Developer ID Application' identity in APPLE_CERTIFICATE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Imported signing identity $IDENTITY"
|
||||||
|
if [ -n "${GITHUB_ENV:-}" ]; then
|
||||||
|
{ echo "MACOS_SIGN_IDENTITY=$IDENTITY"; echo "MACOS_KEYCHAIN=$KEYCHAIN"; } >>"$GITHUB_ENV"
|
||||||
|
else
|
||||||
|
echo "MACOS_SIGN_IDENTITY=$IDENTITY"
|
||||||
|
echo "MACOS_KEYCHAIN=$KEYCHAIN"
|
||||||
|
fi
|
||||||
|
|
@ -0,0 +1,162 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build, sign and (optionally) notarize the macOS release artifacts:
|
||||||
|
#
|
||||||
|
# $DIST/vectorcraft-<version>-macos-<arch>.dmg VectorCraft.app on a drag-to-Applications DMG
|
||||||
|
# $DIST/vectorcraft-cli-<version>-macos-<arch>.zip the headless CLI
|
||||||
|
#
|
||||||
|
# Usage: packaging/macos/package.sh [--arch universal|aarch64|x86_64] [--skip-build]
|
||||||
|
#
|
||||||
|
# Signing (env):
|
||||||
|
# MACOS_SIGN_IDENTITY codesign identity (name or SHA-1). Default "-" = ad-hoc (local testing;
|
||||||
|
# Gatekeeper will reject the result on other Macs). In CI, import-cert.sh sets it.
|
||||||
|
# MACOS_KEYCHAIN keychain holding the identity (optional)
|
||||||
|
# Notarization (env; all three needed, and a real identity):
|
||||||
|
# APPLE_ID, APPLE_PASSWORD (app-specific password), APPLE_TEAM_ID
|
||||||
|
set -euo pipefail
|
||||||
|
# shellcheck source=../env.sh
|
||||||
|
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
|
||||||
|
HERE="$ROOT/packaging/macos"
|
||||||
|
|
||||||
|
ARCH=universal
|
||||||
|
SKIP_BUILD=0
|
||||||
|
while [ $# -gt 0 ]; do
|
||||||
|
case "$1" in
|
||||||
|
--arch) ARCH="$2"; shift 2 ;;
|
||||||
|
--skip-build) SKIP_BUILD=1; shift ;;
|
||||||
|
-h | --help) sed -n '2,16p' "$0"; exit 0 ;;
|
||||||
|
*) echo "unknown argument: $1" >&2; exit 2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
case "$ARCH" in
|
||||||
|
universal) TARGETS=(aarch64-apple-darwin x86_64-apple-darwin) ;;
|
||||||
|
aarch64) TARGETS=(aarch64-apple-darwin) ;;
|
||||||
|
x86_64) TARGETS=(x86_64-apple-darwin) ;;
|
||||||
|
*) echo "unknown --arch $ARCH" >&2; exit 2 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Keep in sync with LSMinimumSystemVersion in Info.plist.in.
|
||||||
|
export MACOSX_DEPLOYMENT_TARGET=11.0
|
||||||
|
IDENTITY="${MACOS_SIGN_IDENTITY:--}"
|
||||||
|
SHORT_VERSION="${VERSION%%-*}"
|
||||||
|
WORK="$CARGO_TARGET_DIR/macos-package"
|
||||||
|
APP="$WORK/VectorCraft.app"
|
||||||
|
DMG="$DIST/vectorcraft-$VERSION-macos-$ARCH.dmg"
|
||||||
|
CLI_ZIP="$DIST/vectorcraft-cli-$VERSION-macos-$ARCH.zip"
|
||||||
|
|
||||||
|
NOTARIZE=0
|
||||||
|
if [ "$IDENTITY" = "-" ]; then
|
||||||
|
warn "macOS: ad-hoc signing (no MACOS_SIGN_IDENTITY); artifacts are not notarized"
|
||||||
|
elif [ -n "${APPLE_ID:-}" ] && [ -n "${APPLE_PASSWORD:-}" ] && [ -n "${APPLE_TEAM_ID:-}" ]; then
|
||||||
|
NOTARIZE=1
|
||||||
|
else
|
||||||
|
warn "macOS: APPLE_ID / APPLE_PASSWORD / APPLE_TEAM_ID incomplete; signed but not notarized"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> VectorCraft $VERSION for macOS ($ARCH), identity: $IDENTITY, notarize: $NOTARIZE"
|
||||||
|
|
||||||
|
# ---- build -------------------------------------------------------------------------------------
|
||||||
|
if [ "$SKIP_BUILD" = 0 ]; then
|
||||||
|
args=()
|
||||||
|
for t in "${TARGETS[@]}"; do args+=(--target "$t"); done
|
||||||
|
(cd "$ROOT" && cargo build --release --locked -p vectorcraft -p vectorcraft-cli "${args[@]}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -rf "$WORK"
|
||||||
|
mkdir -p "$WORK/bin"
|
||||||
|
for bin in vectorcraft vectorcraft-cli; do
|
||||||
|
inputs=()
|
||||||
|
for t in "${TARGETS[@]}"; do inputs+=("$CARGO_TARGET_DIR/$t/release/$bin"); done
|
||||||
|
lipo -create -output "$WORK/bin/$bin" "${inputs[@]}"
|
||||||
|
lipo -info "$WORK/bin/$bin"
|
||||||
|
done
|
||||||
|
|
||||||
|
# ---- signing helpers ---------------------------------------------------------------------------
|
||||||
|
sign() {
|
||||||
|
# Hardened runtime + secure timestamp for a real identity; ad-hoc can't be timestamped.
|
||||||
|
local ts=(--timestamp)
|
||||||
|
[ "$IDENTITY" = "-" ] && ts=(--timestamp=none)
|
||||||
|
local kc=()
|
||||||
|
[ -n "${MACOS_KEYCHAIN:-}" ] && kc=(--keychain "$MACOS_KEYCHAIN")
|
||||||
|
codesign --force --sign "$IDENTITY" ${kc[@]+"${kc[@]}"} "${ts[@]}" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
notarize() {
|
||||||
|
local file="$1" out id status
|
||||||
|
echo "==> notarizing $(basename "$file") (this can take a few minutes)"
|
||||||
|
out="$(xcrun notarytool submit "$file" --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" \
|
||||||
|
--team-id "$APPLE_TEAM_ID" --wait --timeout 1h --output-format json)" || true
|
||||||
|
echo "$out"
|
||||||
|
id="$(printf '%s' "$out" | plutil -extract id raw -o - - 2>/dev/null || true)"
|
||||||
|
status="$(printf '%s' "$out" | plutil -extract status raw -o - - 2>/dev/null || true)"
|
||||||
|
if [ "$status" != "Accepted" ]; then
|
||||||
|
if [ -n "$id" ]; then
|
||||||
|
xcrun notarytool log "$id" --apple-id "$APPLE_ID" --password "$APPLE_PASSWORD" --team-id "$APPLE_TEAM_ID" || true
|
||||||
|
fi
|
||||||
|
echo "error: notarization of $(basename "$file") failed (status: ${status:-unknown})" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# ---- VectorCraft.app ----------------------------------------------------------------------------
|
||||||
|
echo "==> assembling $APP"
|
||||||
|
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
|
||||||
|
# Executable and icon carry the display name (CFBundleExecutable / CFBundleIconFile).
|
||||||
|
cp "$WORK/bin/vectorcraft" "$APP/Contents/MacOS/VectorCraft"
|
||||||
|
cp "$ROOT/assets/app-icon/vectorcraft.icns" "$APP/Contents/Resources/VectorCraft.icns"
|
||||||
|
sed -e "s/@VERSION@/$VERSION/g" -e "s/@SHORT_VERSION@/$SHORT_VERSION/g" \
|
||||||
|
-e "s/@BUILD_SHA@/${VECTORCRAFT_BUILD_SHA:-unknown}/g" \
|
||||||
|
"$HERE/Info.plist.in" >"$APP/Contents/Info.plist"
|
||||||
|
plutil -lint "$APP/Contents/Info.plist"
|
||||||
|
printf 'APPL????' >"$APP/Contents/PkgInfo"
|
||||||
|
|
||||||
|
# Sign inside-out: nested code first, then the bundle itself (no --deep on the final signature).
|
||||||
|
# Today the only nested code is the main executable; frameworks/helpers would be signed here too.
|
||||||
|
sign --options runtime --entitlements "$HERE/entitlements.plist" "$APP/Contents/MacOS/VectorCraft"
|
||||||
|
sign --options runtime --entitlements "$HERE/entitlements.plist" "$APP"
|
||||||
|
codesign --verify --strict --deep --verbose=2 "$APP"
|
||||||
|
|
||||||
|
if [ "$NOTARIZE" = 1 ]; then
|
||||||
|
ditto -c -k --keepParent "$APP" "$WORK/VectorCraft-notarize.zip"
|
||||||
|
notarize "$WORK/VectorCraft-notarize.zip"
|
||||||
|
xcrun stapler staple "$APP"
|
||||||
|
xcrun stapler validate "$APP"
|
||||||
|
spctl --assess --type execute -vvv "$APP"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- DMG ---------------------------------------------------------------------------------------
|
||||||
|
echo "==> building $DMG"
|
||||||
|
STAGE="$WORK/dmg"
|
||||||
|
mkdir -p "$STAGE"
|
||||||
|
ditto "$APP" "$STAGE/VectorCraft.app"
|
||||||
|
ln -s /Applications "$STAGE/Applications"
|
||||||
|
rm -f "$DMG" "$WORK/raw.dmg"
|
||||||
|
# makehybrid + convert builds the image without attaching a device, unlike `create -srcfolder`,
|
||||||
|
# which is flaky on CI runners ("Resource busy") and hangs in sandboxed sessions.
|
||||||
|
hdiutil makehybrid -hfs -hfs-volume-name "VectorCraft $VERSION" -hfs-openfolder "$STAGE" -o "$WORK/raw.dmg" "$STAGE"
|
||||||
|
hdiutil convert "$WORK/raw.dmg" -format UDZO -imagekey zlib-level=9 -o "$DMG"
|
||||||
|
rm -f "$WORK/raw.dmg"
|
||||||
|
sign "$DMG"
|
||||||
|
codesign --verify --strict --verbose=2 "$DMG"
|
||||||
|
if [ "$NOTARIZE" = 1 ]; then
|
||||||
|
notarize "$DMG"
|
||||||
|
xcrun stapler staple "$DMG"
|
||||||
|
xcrun stapler validate "$DMG"
|
||||||
|
spctl --assess --type open --context context:primary-signature -vvv "$DMG"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- CLI ---------------------------------------------------------------------------------------
|
||||||
|
echo "==> building $CLI_ZIP"
|
||||||
|
CLI_DIR="$WORK/vectorcraft-cli-$VERSION-macos-$ARCH"
|
||||||
|
mkdir -p "$CLI_DIR"
|
||||||
|
cp "$WORK/bin/vectorcraft-cli" "$CLI_DIR/"
|
||||||
|
copy_docs "$CLI_DIR"
|
||||||
|
sign --options runtime "$CLI_DIR/vectorcraft-cli"
|
||||||
|
codesign --verify --strict --verbose=2 "$CLI_DIR/vectorcraft-cli"
|
||||||
|
rm -f "$CLI_ZIP"
|
||||||
|
ditto -c -k --keepParent "$CLI_DIR" "$CLI_ZIP"
|
||||||
|
# A bare Mach-O can't carry a stapled ticket; Gatekeeper looks the notarization up online.
|
||||||
|
if [ "$NOTARIZE" = 1 ]; then notarize "$CLI_ZIP"; fi
|
||||||
|
|
||||||
|
"$WORK/bin/vectorcraft-cli" --version
|
||||||
|
echo "==> done"
|
||||||
|
ls -lh "$DMG" "$CLI_ZIP"
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Apache (see HOSTING.md). Needs mod_mime; mod_deflate and mod_headers are optional.
|
||||||
|
AddType application/wasm .wasm
|
||||||
|
AddType text/javascript .js
|
||||||
|
|
||||||
|
<IfModule mod_deflate.c>
|
||||||
|
AddOutputFilterByType DEFLATE application/wasm text/javascript text/html
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<IfModule mod_headers.c>
|
||||||
|
<FilesMatch "\.(wasm|js)$">
|
||||||
|
Header set Cache-Control "public, max-age=31536000, immutable"
|
||||||
|
</FilesMatch>
|
||||||
|
<FilesMatch "^index\.html$">
|
||||||
|
Header set Cache-Control "no-cache"
|
||||||
|
</FilesMatch>
|
||||||
|
</IfModule>
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
# Hosting VectorCraft for the web
|
||||||
|
|
||||||
|
`vectorcraft-web-<version>.zip` (from the GitHub release, or `packaging/web/package.sh`) holds a
|
||||||
|
static site in `vectorcraft-web-<version>/`:
|
||||||
|
|
||||||
|
| File | What it is |
|
||||||
|
|---|---|
|
||||||
|
| `index.html` | The page. It loads everything through relative URLs. |
|
||||||
|
| `vectorcraft-web-<hash>.js` | wasm-bindgen glue (generated, ES module) |
|
||||||
|
| `vectorcraft-web-<hash>_bg.wasm` | The app, about 13 MB, or 5 MB with compression |
|
||||||
|
| `_headers`, `.htaccess` | Sample header rules for Netlify/Cloudflare Pages and Apache |
|
||||||
|
|
||||||
|
There is no server-side code. Upload the folder's contents anywhere that serves static files.
|
||||||
|
|
||||||
|
## Any path works
|
||||||
|
|
||||||
|
All URLs in `index.html` are relative (`public_url = "./"` in `apps/vectorcraft-web/Trunk.toml`),
|
||||||
|
so the site works at a domain root (`https://example.com/`), under a prefix
|
||||||
|
(`https://example.com/tools/vectorcraft/`) and from a CDN bucket. The asset names carry a content
|
||||||
|
hash, so they can be cached forever. Only `index.html` needs revalidation.
|
||||||
|
|
||||||
|
## Required server settings
|
||||||
|
|
||||||
|
- **MIME type:** serve `.wasm` as `application/wasm`. Browsers refuse to stream-compile it under
|
||||||
|
any other type, and the app then loads slowly or not at all. Serve `.js` as `text/javascript`.
|
||||||
|
Most hosts already do both. For nginx, check that `mime.types` has `application/wasm wasm;`.
|
||||||
|
- **Compression:** turn on gzip or Brotli for `.wasm`, `.js` and `.html`. That takes the
|
||||||
|
download from about 13 MB to about 5 MB. You can also precompress (`brotli -k *.wasm`) and let
|
||||||
|
the server send `Content-Encoding: br`.
|
||||||
|
- **Caching:** `Cache-Control: public, max-age=31536000, immutable` on the hashed `.wasm` and
|
||||||
|
`.js` files, and `no-cache` on `index.html`.
|
||||||
|
- **HTTPS:** WebGPU (and the clipboard) only work in a secure context, which means `https://`
|
||||||
|
or `http://localhost`. Over plain HTTP elsewhere, the app falls back to WebGL2.
|
||||||
|
- **No special isolation headers:** VectorCraft doesn't use `SharedArrayBuffer`, so it doesn't
|
||||||
|
need `Cross-Origin-Opener-Policy` or `Cross-Origin-Embedder-Policy`. If your site already sends
|
||||||
|
COEP `require-corp`, also send `Cross-Origin-Resource-Policy: same-origin` (or `cross-origin`
|
||||||
|
when the files live on a CDN) on the app's files.
|
||||||
|
|
||||||
|
nginx example:
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
location /vectorcraft/ {
|
||||||
|
types { application/wasm wasm; text/javascript js; text/html html; }
|
||||||
|
gzip on;
|
||||||
|
gzip_types application/wasm text/javascript text/html;
|
||||||
|
location ~* \.(wasm|js)$ { add_header Cache-Control "public, max-age=31536000, immutable"; }
|
||||||
|
location ~* index\.html$ { add_header Cache-Control "no-cache"; }
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Local test: `python3 -m http.server 8765` inside the folder, then open http://localhost:8765/.
|
||||||
|
|
||||||
|
## Embedding in a page (iframe)
|
||||||
|
|
||||||
|
```html
|
||||||
|
<iframe
|
||||||
|
src="https://example.com/vectorcraft/"
|
||||||
|
title="VectorCraft image editor"
|
||||||
|
style="width: 100%; height: 720px; border: 0;"
|
||||||
|
allow="fullscreen; clipboard-read; clipboard-write"
|
||||||
|
allowfullscreen>
|
||||||
|
</iframe>
|
||||||
|
```
|
||||||
|
|
||||||
|
- The app fills the iframe and follows its size, so size the iframe and not the app.
|
||||||
|
- Keyboard shortcuts go to the iframe after the user clicks into it, as with any embedded app.
|
||||||
|
- **Cross-origin embeds** work. Preferences are kept in the iframe's `localStorage`. Browsers
|
||||||
|
that partition or block third-party storage may forget them between visits, and the app
|
||||||
|
then starts with defaults.
|
||||||
|
- **Sandboxed iframes** need at least
|
||||||
|
`sandbox="allow-scripts allow-same-origin allow-downloads allow-popups"`. Without
|
||||||
|
`allow-same-origin` there's no storage. Without `allow-downloads`, Save and Export (browser
|
||||||
|
downloads) are blocked.
|
||||||
|
- Don't send `X-Frame-Options: DENY` or a `frame-ancestors` CSP that excludes the embedding page.
|
||||||
|
|
||||||
|
## Renderer selection and fallback flags
|
||||||
|
|
||||||
|
VectorCraft renders with wgpu. It uses **WebGPU** when the browser has it and falls back to
|
||||||
|
**WebGL2** on its own. URL query flags override this, and they work on the iframe `src` too:
|
||||||
|
|
||||||
|
| Flag | Effect |
|
||||||
|
|---|---|
|
||||||
|
| *(none)* | WebGPU if available, otherwise WebGL2 |
|
||||||
|
| `?webgl` | Force the WebGL2 backend (useful when a WebGPU driver misbehaves) |
|
||||||
|
| `?cpu` | Force the CPU canvas path (slowest, most compatible) |
|
||||||
|
|
||||||
|
For example: `<iframe src="https://example.com/vectorcraft/?webgl" ...>`.
|
||||||
|
|
||||||
|
A browser with neither WebGPU nor WebGL2 gets a message in place of the app.
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
# Netlify / Cloudflare Pages header rules (see HOSTING.md). Other hosts: set the same headers.
|
||||||
|
/*
|
||||||
|
X-Content-Type-Options: nosniff
|
||||||
|
|
||||||
|
/*.wasm
|
||||||
|
Content-Type: application/wasm
|
||||||
|
Cache-Control: public, max-age=31536000, immutable
|
||||||
|
|
||||||
|
/*.js
|
||||||
|
Cache-Control: public, max-age=31536000, immutable
|
||||||
|
|
||||||
|
/index.html
|
||||||
|
Cache-Control: no-cache
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Build the browser version and zip it: $DIST/vectorcraft-web-<version>.zip
|
||||||
|
#
|
||||||
|
# Usage: packaging/web/package.sh [--skip-build]
|
||||||
|
#
|
||||||
|
# Needs: trunk (brew install trunk / cargo install trunk --locked) and the wasm32-unknown-unknown
|
||||||
|
# target. The zip holds a self-contained static site in vectorcraft-web-<version>/ that works
|
||||||
|
# from any URL path and inside an <iframe>. Hosting notes: packaging/web/README.md.
|
||||||
|
set -euo pipefail
|
||||||
|
# shellcheck source=../env.sh
|
||||||
|
. "$(dirname "${BASH_SOURCE[0]}")/../env.sh"
|
||||||
|
HERE="$ROOT/packaging/web"
|
||||||
|
|
||||||
|
if [ "${1:-}" != "--skip-build" ]; then
|
||||||
|
command -v trunk >/dev/null || { echo "error: trunk not found (cargo install trunk --locked)" >&2; exit 1; }
|
||||||
|
(cd "$ROOT/apps/vectorcraft-web" && trunk build --release)
|
||||||
|
fi
|
||||||
|
|
||||||
|
SITE="$ROOT/dist/web"
|
||||||
|
[ -f "$SITE/index.html" ] || { echo "error: $SITE/index.html missing; run without --skip-build" >&2; exit 1; }
|
||||||
|
# Paths must be relative so the site works under any prefix (public_url = "./" in Trunk.toml).
|
||||||
|
if grep -Eq '(src|href)="/[^/]' "$SITE/index.html"; then
|
||||||
|
echo "error: $SITE/index.html has root-absolute URLs; it would break when served from a sub-path" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
NAME="vectorcraft-web-$VERSION"
|
||||||
|
WORK="$CARGO_TARGET_DIR/web-package"
|
||||||
|
rm -rf "$WORK"
|
||||||
|
mkdir -p "$WORK/$NAME"
|
||||||
|
cp -R "$SITE/." "$WORK/$NAME/"
|
||||||
|
# Sample server configs (MIME type, caching, compression); harmless where unused.
|
||||||
|
cp "$HERE/_headers" "$HERE/.htaccess" "$WORK/$NAME/"
|
||||||
|
cp "$HERE/README.md" "$WORK/$NAME/HOSTING.md"
|
||||||
|
copy_docs "$WORK/$NAME"
|
||||||
|
rm -f "$DIST/$NAME.zip"
|
||||||
|
(cd "$WORK" && zip -qr9 "$DIST/$NAME.zip" "$NAME")
|
||||||
|
echo "wrote $DIST/$NAME.zip"
|
||||||
|
ls -lh "$DIST/$NAME.zip"
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Build, sign and package VectorCraft for Windows.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Produces, in $env:DIST (default: dist/release):
|
||||||
|
vectorcraft-<version>-windows-<arch>.msi per-machine installer (WiX v5)
|
||||||
|
vectorcraft-<version>-windows-<arch>-portable.zip vectorcraft.exe + vectorcraft-cli.exe
|
||||||
|
|
||||||
|
The binaries link the C runtime statically (+crt-static), so neither the MSI nor the portable
|
||||||
|
zip needs the Visual C++ redistributable. Signing is delegated to sign.ps1 (skipped with a
|
||||||
|
warning when no signing secrets are set).
|
||||||
|
|
||||||
|
Needs: Rust (MSVC toolchain + the target), the Windows SDK (rc.exe, signtool.exe),
|
||||||
|
and WiX v5: dotnet tool install --global wix --version 5.0.2
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
pwsh packaging/windows/package.ps1 -Arch x64
|
||||||
|
pwsh packaging/windows/package.ps1 -Arch x86 -SkipBuild
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[ValidateSet('x64', 'x86')] [string] $Arch = 'x64',
|
||||||
|
[switch] $SkipBuild
|
||||||
|
)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$Root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||||
|
|
||||||
|
function Invoke-Native([string] $What, [scriptblock] $Block) {
|
||||||
|
Write-Output "==> $What"
|
||||||
|
& $Block
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw "$What failed with exit code $LASTEXITCODE" }
|
||||||
|
}
|
||||||
|
|
||||||
|
# The version lives in one place: [workspace.package] version in the root Cargo.toml.
|
||||||
|
$Version = $env:VECTORCRAFT_VERSION
|
||||||
|
if (-not $Version) {
|
||||||
|
$inPkg = $false
|
||||||
|
foreach ($line in Get-Content (Join-Path $Root 'Cargo.toml')) {
|
||||||
|
if ($line -match '^\s*\[') { $inPkg = ($line.Trim() -eq '[workspace.package]'); continue }
|
||||||
|
if ($inPkg -and $line -match '^\s*version\s*=\s*"([^"]+)"') { $Version = $Matches[1]; break }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $Version) { throw 'could not read [workspace.package] version from Cargo.toml' }
|
||||||
|
# MSI ProductVersion is numeric (major.minor.build); pre-release tags are dropped there.
|
||||||
|
$MsiVersion = ($Version -split '-')[0]
|
||||||
|
|
||||||
|
$Target = if ($Arch -eq 'x64') { 'x86_64-pc-windows-msvc' } else { 'i686-pc-windows-msvc' }
|
||||||
|
$Dist = if ($env:DIST) { $env:DIST } else { Join-Path $Root 'dist\release' }
|
||||||
|
$TargetDir = if ($env:CARGO_TARGET_DIR) { $env:CARGO_TARGET_DIR } else { Join-Path $Root 'target' }
|
||||||
|
New-Item -ItemType Directory -Force -Path $Dist | Out-Null
|
||||||
|
|
||||||
|
if (-not $env:VECTORCRAFT_BUILD_SHA) { $env:VECTORCRAFT_BUILD_SHA = (git -C $Root rev-parse HEAD 2>$null) }
|
||||||
|
if (-not $env:VECTORCRAFT_BUILD_DATE) { $env:VECTORCRAFT_BUILD_DATE = (Get-Date).ToUniversalTime().ToString('yyyy-MM-dd') }
|
||||||
|
|
||||||
|
Write-Output "VectorCraft $Version for Windows $Arch ($Target)"
|
||||||
|
|
||||||
|
if (-not $SkipBuild) {
|
||||||
|
# Static CRT: no VC++ redistributable needed. Scoped to the target so host build scripts and
|
||||||
|
# proc-macros are unaffected.
|
||||||
|
$flagVar = 'CARGO_TARGET_' + ($Target.ToUpper() -replace '-', '_') + '_RUSTFLAGS'
|
||||||
|
[Environment]::SetEnvironmentVariable($flagVar, '-C target-feature=+crt-static')
|
||||||
|
# Fail the build (rather than warn) if the icon/VERSIONINFO can't be embedded.
|
||||||
|
$env:VECTORCRAFT_REQUIRE_WINRES = '1'
|
||||||
|
Invoke-Native "cargo build ($Target)" { cargo build --release --locked -p vectorcraft -p vectorcraft-cli --target $Target }
|
||||||
|
}
|
||||||
|
|
||||||
|
$Bin = Join-Path $TargetDir "$Target\release"
|
||||||
|
$Stage = Join-Path $TargetDir "windows-package\$Arch"
|
||||||
|
Remove-Item -Recurse -Force $Stage -ErrorAction SilentlyContinue
|
||||||
|
New-Item -ItemType Directory -Force -Path $Stage | Out-Null
|
||||||
|
Copy-Item (Join-Path $Bin 'vectorcraft.exe'), (Join-Path $Bin 'vectorcraft-cli.exe') $Stage
|
||||||
|
|
||||||
|
& (Join-Path $PSScriptRoot 'sign.ps1') (Join-Path $Stage 'vectorcraft.exe') (Join-Path $Stage 'vectorcraft-cli.exe')
|
||||||
|
|
||||||
|
# ---- MSI ---------------------------------------------------------------------------------------
|
||||||
|
$Msi = Join-Path $Dist "vectorcraft-$Version-windows-$Arch.msi"
|
||||||
|
Invoke-Native 'wix build' {
|
||||||
|
wix build (Join-Path $PSScriptRoot 'vectorcraft.wxs') -arch $Arch `
|
||||||
|
-d "Version=$MsiVersion" -d "BinDir=$Stage" -d "IconPath=$(Join-Path $Root 'assets\app-icon\vectorcraft.ico')" `
|
||||||
|
-o $Msi
|
||||||
|
}
|
||||||
|
# wix writes its debug symbols (.wixpdb) next to the MSI; keep them out of the release assets.
|
||||||
|
Remove-Item -Force -ErrorAction SilentlyContinue ([IO.Path]::ChangeExtension($Msi, '.wixpdb'))
|
||||||
|
& (Join-Path $PSScriptRoot 'sign.ps1') $Msi
|
||||||
|
|
||||||
|
# ---- portable zip ------------------------------------------------------------------------------
|
||||||
|
$Portable = Join-Path $TargetDir "windows-package\vectorcraft-$Version-windows-$Arch-portable"
|
||||||
|
Remove-Item -Recurse -Force $Portable -ErrorAction SilentlyContinue
|
||||||
|
New-Item -ItemType Directory -Force -Path $Portable | Out-Null
|
||||||
|
Copy-Item (Join-Path $Stage '*.exe') $Portable
|
||||||
|
foreach ($f in 'README.md', 'LICENSE', 'LICENSE-MIT', 'LICENSE-APACHE') {
|
||||||
|
$p = Join-Path $Root $f
|
||||||
|
if (Test-Path $p) { Copy-Item $p $Portable }
|
||||||
|
}
|
||||||
|
$Zip = Join-Path $Dist "vectorcraft-$Version-windows-$Arch-portable.zip"
|
||||||
|
Remove-Item -Force $Zip -ErrorAction SilentlyContinue
|
||||||
|
Compress-Archive -Path $Portable -DestinationPath $Zip
|
||||||
|
|
||||||
|
Invoke-Native 'vectorcraft-cli --version' { & (Join-Path $Stage 'vectorcraft-cli.exe') --version }
|
||||||
|
Get-Item $Msi, $Zip | Format-Table Name, Length
|
||||||
|
|
@ -0,0 +1,95 @@
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Authenticode-sign files with signtool, using whichever signing material is configured.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Tries, in order:
|
||||||
|
1. A code-signing certificate file: WINDOWS_CERTIFICATE (base64 .pfx), WINDOWS_CERTIFICATE_PASSWORD
|
||||||
|
2. Azure Trusted Signing: AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET,
|
||||||
|
AZURE_SIGNING_ENDPOINT (e.g. https://eus.codesigning.azure.net),
|
||||||
|
AZURE_SIGNING_ACCOUNT, AZURE_CERT_PROFILE
|
||||||
|
With neither, it prints a warning and leaves the files unsigned (exit code 0), so test builds
|
||||||
|
still produce installers.
|
||||||
|
|
||||||
|
This is the one place to adapt when the signing setup changes (an HSM/cloud key, a different
|
||||||
|
timestamp server, ...). Optional overrides: WINDOWS_TIMESTAMP_URL, SIGNTOOL (path to signtool.exe).
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
pwsh packaging/windows/sign.ps1 dist/vectorcraft.exe dist/Vectorcraft.msi
|
||||||
|
#>
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)]
|
||||||
|
[string[]] $Files
|
||||||
|
)
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
|
function Write-Warn([string] $Message) {
|
||||||
|
if ($env:GITHUB_ACTIONS) { Write-Output "::warning::$Message" } else { Write-Warning $Message }
|
||||||
|
}
|
||||||
|
|
||||||
|
function Find-SignTool {
|
||||||
|
if ($env:SIGNTOOL) { return $env:SIGNTOOL }
|
||||||
|
$onPath = Get-Command signtool.exe -ErrorAction SilentlyContinue
|
||||||
|
if ($onPath) { return $onPath.Source }
|
||||||
|
$kits = Join-Path ${env:ProgramFiles(x86)} 'Windows Kits\10\bin'
|
||||||
|
$found = Get-ChildItem -Path $kits -Recurse -Filter signtool.exe -ErrorAction SilentlyContinue |
|
||||||
|
Where-Object { $_.FullName -match '\\x64\\signtool\.exe$' } |
|
||||||
|
Sort-Object FullName -Descending | Select-Object -First 1
|
||||||
|
if (-not $found) { throw 'signtool.exe not found (install the Windows SDK)' }
|
||||||
|
return $found.FullName
|
||||||
|
}
|
||||||
|
|
||||||
|
function Invoke-SignTool([string[]] $Arguments) {
|
||||||
|
& $script:SignTool @Arguments
|
||||||
|
if ($LASTEXITCODE -ne 0) { throw "signtool $($Arguments[0]) failed with exit code $LASTEXITCODE" }
|
||||||
|
}
|
||||||
|
|
||||||
|
$Files = $Files | ForEach-Object { (Resolve-Path $_).Path }
|
||||||
|
$haveCert = [bool]$env:WINDOWS_CERTIFICATE
|
||||||
|
$azureVars = 'AZURE_TENANT_ID', 'AZURE_CLIENT_ID', 'AZURE_CLIENT_SECRET', 'AZURE_SIGNING_ENDPOINT', 'AZURE_SIGNING_ACCOUNT', 'AZURE_CERT_PROFILE'
|
||||||
|
$haveAzure = -not ($azureVars | Where-Object { -not [Environment]::GetEnvironmentVariable($_) })
|
||||||
|
|
||||||
|
if (-not $haveCert -and -not $haveAzure) {
|
||||||
|
Write-Warn "Windows signing secrets not set (WINDOWS_CERTIFICATE or AZURE_*): leaving unsigned: $($Files -join ', ')"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:SignTool = Find-SignTool
|
||||||
|
$common = @('sign', '/v', '/fd', 'SHA256', '/td', 'SHA256', '/d', 'VectorCraft', '/du', 'https://github.com/storytold/vectorcraft')
|
||||||
|
$tmp = Join-Path ([IO.Path]::GetTempPath()) "vectorcraft-sign-$PID"
|
||||||
|
New-Item -ItemType Directory -Force -Path $tmp | Out-Null
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($haveCert) {
|
||||||
|
Write-Output "Signing with WINDOWS_CERTIFICATE: $($Files -join ', ')"
|
||||||
|
$pfx = Join-Path $tmp 'cert.pfx'
|
||||||
|
[IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE))
|
||||||
|
$ts = if ($env:WINDOWS_TIMESTAMP_URL) { $env:WINDOWS_TIMESTAMP_URL } else { 'http://timestamp.digicert.com' }
|
||||||
|
$signArgs = $common + @('/tr', $ts, '/f', $pfx)
|
||||||
|
if ($env:WINDOWS_CERTIFICATE_PASSWORD) { $signArgs += @('/p', $env:WINDOWS_CERTIFICATE_PASSWORD) }
|
||||||
|
Invoke-SignTool ($signArgs + $Files)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Write-Output "Signing with Azure Trusted Signing ($env:AZURE_SIGNING_ACCOUNT / $env:AZURE_CERT_PROFILE): $($Files -join ', ')"
|
||||||
|
# The dlib authenticates with DefaultAzureCredential, which reads AZURE_TENANT_ID,
|
||||||
|
# AZURE_CLIENT_ID and AZURE_CLIENT_SECRET from the environment.
|
||||||
|
$pkg = Join-Path $tmp 'trusted-signing.zip'
|
||||||
|
Invoke-WebRequest -Uri 'https://www.nuget.org/api/v2/package/Microsoft.Trusted.Signing.Client' -OutFile $pkg
|
||||||
|
Expand-Archive -Path $pkg -DestinationPath (Join-Path $tmp 'client') -Force
|
||||||
|
$dlib = Get-ChildItem -Path (Join-Path $tmp 'client') -Recurse -Filter Azure.CodeSigning.Dlib.dll |
|
||||||
|
Where-Object { $_.FullName -match '\\x64\\' } | Select-Object -First 1
|
||||||
|
if (-not $dlib) { throw 'Azure.CodeSigning.Dlib.dll not found in Microsoft.Trusted.Signing.Client' }
|
||||||
|
$metadata = Join-Path $tmp 'metadata.json'
|
||||||
|
@{
|
||||||
|
Endpoint = $env:AZURE_SIGNING_ENDPOINT
|
||||||
|
CodeSigningAccountName = $env:AZURE_SIGNING_ACCOUNT
|
||||||
|
CertificateProfileName = $env:AZURE_CERT_PROFILE
|
||||||
|
} | ConvertTo-Json | Set-Content -Path $metadata -Encoding utf8
|
||||||
|
$ts = if ($env:WINDOWS_TIMESTAMP_URL) { $env:WINDOWS_TIMESTAMP_URL } else { 'http://timestamp.acs.microsoft.com' }
|
||||||
|
Invoke-SignTool ($common + @('/tr', $ts, '/dlib', $dlib.FullName, '/dmdf', $metadata) + $Files)
|
||||||
|
}
|
||||||
|
Invoke-SignTool (@('verify', '/pa', '/v') + $Files)
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
VectorCraft MSI (WiX Toolset v5: `dotnet tool install -g wix`). Built by package.ps1:
|
||||||
|
|
||||||
|
wix build vectorcraft.wxs -arch x64 -d Version=1.2.3 -d BinDir=... -d IconPath=... -o out.msi
|
||||||
|
|
||||||
|
Per-machine install into Program Files, a Start Menu shortcut, `.pcraft` owned by VectorCraft,
|
||||||
|
and VectorCraft offered under "Open with" for PSD/PSB and the image formats it reads (without
|
||||||
|
taking over the user's default app for them).
|
||||||
|
-->
|
||||||
|
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||||
|
<Package
|
||||||
|
Name="VectorCraft"
|
||||||
|
Manufacturer="Learning Machines LLC"
|
||||||
|
Version="$(var.Version)"
|
||||||
|
UpgradeCode="601C6437-08AE-4645-ADCC-27F036C2EA2F"
|
||||||
|
Scope="perMachine"
|
||||||
|
Compressed="yes"
|
||||||
|
Language="1033">
|
||||||
|
<SummaryInformation Description="VectorCraft image editor" Manufacturer="Learning Machines LLC" />
|
||||||
|
<!-- Same-version upgrades let successive pre-releases of one X.Y.Z replace each other
|
||||||
|
(MSI versions are numeric, so 1.2.3-rc.1 and 1.2.3-rc.2 are both 1.2.3). -->
|
||||||
|
<MajorUpgrade AllowSameVersionUpgrades="yes"
|
||||||
|
DowngradeErrorMessage="A newer version of VectorCraft is already installed." />
|
||||||
|
<MediaTemplate EmbedCab="yes" CompressionLevel="high" />
|
||||||
|
|
||||||
|
<Icon Id="VectorcraftIcon" SourceFile="$(var.IconPath)" />
|
||||||
|
<Property Id="ARPPRODUCTICON" Value="VectorcraftIcon" />
|
||||||
|
<Property Id="ARPURLINFOABOUT" Value="https://getartcraft.com/apps/vectorcraft" />
|
||||||
|
<Property Id="ARPURLUPDATEINFO" Value="https://getartcraft.com/apps/vectorcraft" />
|
||||||
|
<Property Id="ARPHELPLINK" Value="https://discord.gg/artcraft" />
|
||||||
|
|
||||||
|
<StandardDirectory Id="ProgramFiles6432Folder">
|
||||||
|
<Directory Id="INSTALLFOLDER" Name="VectorCraft" />
|
||||||
|
</StandardDirectory>
|
||||||
|
<StandardDirectory Id="ProgramMenuFolder" />
|
||||||
|
|
||||||
|
<Feature Id="Main" Title="VectorCraft" Level="1">
|
||||||
|
<ComponentGroupRef Id="VectorcraftFiles" />
|
||||||
|
</Feature>
|
||||||
|
</Package>
|
||||||
|
|
||||||
|
<Fragment>
|
||||||
|
<ComponentGroup Id="VectorcraftFiles" Directory="INSTALLFOLDER">
|
||||||
|
<Component Id="VectorcraftApp" Guid="0E8C6C5E-DE4A-4E1D-9DB0-44E8E38C2103">
|
||||||
|
<File Id="VectorcraftExe" Source="$(var.BinDir)\vectorcraft.exe" KeyPath="yes">
|
||||||
|
<Shortcut Id="StartMenuShortcut" Directory="ProgramMenuFolder" Name="VectorCraft"
|
||||||
|
Description="VectorCraft image editor" WorkingDirectory="INSTALLFOLDER" Advertise="yes"
|
||||||
|
Icon="VectorcraftIcon" IconIndex="0" />
|
||||||
|
</File>
|
||||||
|
|
||||||
|
<RegistryValue Root="HKLM" Key="Software\Microsoft\Windows\CurrentVersion\App Paths\vectorcraft.exe" Value="[#VectorcraftExe]" Type="string" />
|
||||||
|
</Component>
|
||||||
|
|
||||||
|
<Component Id="VectorcraftCli">
|
||||||
|
<File Id="VectorcraftCliExe" Source="$(var.BinDir)\vectorcraft-cli.exe" KeyPath="yes" />
|
||||||
|
</Component>
|
||||||
|
</ComponentGroup>
|
||||||
|
</Fragment>
|
||||||
|
</Wix>
|
||||||
|
|
@ -8,6 +8,7 @@ mod bundle;
|
||||||
mod ico;
|
mod ico;
|
||||||
mod layers;
|
mod layers;
|
||||||
mod stats;
|
mod stats;
|
||||||
|
mod version;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Command, ExitCode};
|
use std::process::{Command, ExitCode};
|
||||||
|
|
@ -39,6 +40,7 @@ fn main() -> ExitCode {
|
||||||
Some("corpus") => cmd_corpus(rest.contains(&"--download")),
|
Some("corpus") => cmd_corpus(rest.contains(&"--download")),
|
||||||
Some("bundle") => bundle::run(&root()),
|
Some("bundle") => bundle::run(&root()),
|
||||||
Some("ico") => ico::run(&rest),
|
Some("ico") => ico::run(&rest),
|
||||||
|
Some("version") => version::run(&root(), &rest),
|
||||||
Some("stats") => stats::run(&root(), rest.contains(&"--exact")),
|
Some("stats") => stats::run(&root(), rest.contains(&"--exact")),
|
||||||
Some("-h" | "--help" | "help") | None => {
|
Some("-h" | "--help" | "help") | None => {
|
||||||
print!("{USAGE}");
|
print!("{USAGE}");
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,164 @@
|
||||||
|
//! `cargo xtask version [set X.Y.Z[-pre]]`: the workspace version, the single source of truth.
|
||||||
|
//!
|
||||||
|
//! The version lives in `[workspace.package] version` in the root `Cargo.toml`; every crate
|
||||||
|
//! inherits it with `version.workspace = true`, and the packaging scripts read it from here.
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
/// The `version = "…"` value inside `[workspace.package]`.
|
||||||
|
pub fn read(manifest: &str) -> Result<String, String> {
|
||||||
|
let (_, line) = find_line(manifest)?;
|
||||||
|
let v = line
|
||||||
|
.split_once('=')
|
||||||
|
.map(|(_, v)| v.trim().trim_matches('"').to_string())
|
||||||
|
.unwrap_or_default();
|
||||||
|
if v.is_empty() {
|
||||||
|
return Err("empty [workspace.package] version".into());
|
||||||
|
}
|
||||||
|
Ok(v)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// `manifest` with the workspace version replaced; everything else is byte-for-byte unchanged.
|
||||||
|
pub fn replace(manifest: &str, new: &str) -> Result<String, String> {
|
||||||
|
validate(new)?;
|
||||||
|
let (idx, _) = find_line(manifest)?;
|
||||||
|
let mut out = String::with_capacity(manifest.len() + 8);
|
||||||
|
for (i, line) in manifest.split_inclusive('\n').enumerate() {
|
||||||
|
if i == idx {
|
||||||
|
let eol = if line.ends_with("\r\n") {
|
||||||
|
"\r\n"
|
||||||
|
} else if line.ends_with('\n') {
|
||||||
|
"\n"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
out.push_str(&format!("version = \"{new}\"{eol}"));
|
||||||
|
} else {
|
||||||
|
out.push_str(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(out)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Semver without build metadata: `MAJOR.MINOR.PATCH` plus an optional `-pre.release` tag.
|
||||||
|
pub fn validate(v: &str) -> Result<(), String> {
|
||||||
|
let bad = || Err(format!("`{v}` is not a version like 1.2.3 or 1.2.3-rc.1"));
|
||||||
|
let (core, pre) = match v.split_once('-') {
|
||||||
|
Some((c, p)) => (c, Some(p)),
|
||||||
|
None => (v, None),
|
||||||
|
};
|
||||||
|
let nums: Vec<&str> = core.split('.').collect();
|
||||||
|
if nums.len() != 3
|
||||||
|
|| nums.iter().any(|n| {
|
||||||
|
n.is_empty()
|
||||||
|
|| !n.bytes().all(|b| b.is_ascii_digit())
|
||||||
|
|| (n.len() > 1 && n.starts_with('0'))
|
||||||
|
})
|
||||||
|
{
|
||||||
|
return bad();
|
||||||
|
}
|
||||||
|
if let Some(p) = pre
|
||||||
|
&& (p.is_empty()
|
||||||
|
|| p.split('.').any(|id| {
|
||||||
|
id.is_empty() || !id.bytes().all(|b| b.is_ascii_alphanumeric() || b == b'-')
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
return bad();
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Index and text of the `version` line in `[workspace.package]`.
|
||||||
|
fn find_line(manifest: &str) -> Result<(usize, &str), String> {
|
||||||
|
let mut in_section = false;
|
||||||
|
for (i, line) in manifest.lines().enumerate() {
|
||||||
|
let t = line.trim();
|
||||||
|
if t.starts_with('[') {
|
||||||
|
in_section = t == "[workspace.package]";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if in_section
|
||||||
|
&& let Some(rest) = t.strip_prefix("version")
|
||||||
|
&& rest.trim_start().starts_with('=')
|
||||||
|
{
|
||||||
|
return Ok((i, line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err("no `version = \"…\"` in [workspace.package] of the root Cargo.toml".into())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn run(root: &Path, args: &[&str]) -> Result<(), String> {
|
||||||
|
let path = root.join("Cargo.toml");
|
||||||
|
let text = std::fs::read_to_string(&path).map_err(|e| format!("read {}: {e}", path.display()))?;
|
||||||
|
match args {
|
||||||
|
[] => {
|
||||||
|
println!("{}", read(&text)?);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
["set", new] => {
|
||||||
|
let old = read(&text)?;
|
||||||
|
let updated = replace(&text, new)?;
|
||||||
|
// Write atomically: a half-written root manifest breaks every build in the workspace.
|
||||||
|
let tmp = root.join("target").join("Cargo.toml.xtask-version");
|
||||||
|
std::fs::create_dir_all(root.join("target")).map_err(|e| format!("create target/: {e}"))?;
|
||||||
|
std::fs::write(&tmp, updated).map_err(|e| format!("write {}: {e}", tmp.display()))?;
|
||||||
|
std::fs::rename(&tmp, &path).map_err(|e| format!("replace {}: {e}", path.display()))?;
|
||||||
|
// Refresh the workspace members' entries in Cargo.lock (no dependency upgrades).
|
||||||
|
let mut c = crate::cargo();
|
||||||
|
c.args(["update", "--workspace", "--offline"]);
|
||||||
|
if crate::run(c, "cargo update --workspace --offline").is_err() {
|
||||||
|
let mut c = crate::cargo();
|
||||||
|
c.args(["update", "--workspace"]);
|
||||||
|
crate::run(c, "cargo update --workspace")?;
|
||||||
|
}
|
||||||
|
println!("version: {old} -> {new}");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
_ => Err("usage: cargo xtask version [set X.Y.Z[-pre]]".into()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
const MANIFEST: &str = "[workspace]\nmembers = [\"a\"]\n\n[workspace.package]\nversion = \"0.1.0\"\nedition = \"2024\"\n\n[workspace.dependencies]\nfoo = { version = \"1\" }\n";
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn reads_the_workspace_version() {
|
||||||
|
assert_eq!(read(MANIFEST).unwrap(), "0.1.0");
|
||||||
|
assert!(read("[package]\nversion = \"1.0.0\"\n").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn replaces_only_the_workspace_version() {
|
||||||
|
let out = replace(MANIFEST, "1.2.3-rc.1").unwrap();
|
||||||
|
assert_eq!(read(&out).unwrap(), "1.2.3-rc.1");
|
||||||
|
assert_eq!(out, MANIFEST.replace("version = \"0.1.0\"", "version = \"1.2.3-rc.1\""));
|
||||||
|
assert!(out.contains("foo = { version = \"1\" }"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn keeps_crlf_line_endings() {
|
||||||
|
let crlf = MANIFEST.replace('\n', "\r\n");
|
||||||
|
let out = replace(&crlf, "2.0.0").unwrap();
|
||||||
|
assert_eq!(out, crlf.replace("\"0.1.0\"", "\"2.0.0\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn validates_versions() {
|
||||||
|
for ok in ["0.1.0", "1.20.300", "1.0.0-rc.1", "1.0.0-alpha", "1.0.0-x-y.2"] {
|
||||||
|
assert!(validate(ok).is_ok(), "{ok}");
|
||||||
|
}
|
||||||
|
for bad in ["1.0", "1.0.0.0", "v1.0.0", "01.0.0", "1.0.0-", "1.0.0-a..b", "1.0.0+meta", "1.a.0", ""] {
|
||||||
|
assert!(validate(bad).is_err(), "{bad}");
|
||||||
|
}
|
||||||
|
assert!(replace(MANIFEST, "nope").is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_real_manifest_has_a_valid_version() {
|
||||||
|
let text = std::fs::read_to_string(crate::root().join("Cargo.toml")).unwrap();
|
||||||
|
validate(&read(&text).unwrap()).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue