Files
snapcad-studio/.github/workflows/desktop-release.yml
T
Zeno Jiricek 502ef1a807 feat(desktop): publish Linux AppImage releases
Build Windows and Linux packages through a platform matrix, attach both artifacts to one GitHub release, and add Linux desktop metadata.
2026-08-18 17:42:35 +09:30

248 lines
7.2 KiB
YAML

name: Desktop Release
on:
push:
tags:
- "v*.*.*"
workflow_dispatch:
inputs:
version:
description: "Version to release (for example 1.0.4)"
required: true
type: string
permissions:
contents: write
concurrency:
group: desktop-release
cancel-in-progress: false
jobs:
build:
name: Build ${{ matrix.platform }} desktop
strategy:
fail-fast: false
matrix:
include:
- platform: windows
runner: windows-latest
artifact: desktop-windows
- platform: linux
runner: ubuntu-latest
artifact: desktop-linux
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
steps:
- name: Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Resolve release version
id: version
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
TAG_NAME: ${{ github.ref_name }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
version="${INPUT_VERSION#v}"
else
version="${TAG_NAME#v}"
fi
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid release version: $version" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Set package version
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Run tests
run: npm test
- name: Build desktop package
run: npm run desktop:dist
- name: Verify Windows artifacts
if: matrix.platform == 'windows'
shell: pwsh
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
$required = @(
"dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe",
"dist/desktop/SketchForge-Setup-$env:VERSION-x64.exe.blockmap",
"dist/desktop/latest.yml"
)
foreach ($file in $required) {
if (-not (Test-Path $file -PathType Leaf)) {
throw "Missing Windows artifact: $file"
}
}
- name: Verify Linux artifacts
if: matrix.platform == 'linux'
shell: bash
env:
VERSION: ${{ steps.version.outputs.version }}
run: |
test -f "dist/desktop/SketchForge-$VERSION-x86_64.AppImage"
test -f dist/desktop/latest-linux.yml
- name: Store Windows artifacts
if: matrix.platform == 'windows'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
dist/desktop/SketchForge-Setup-*-x64.exe
dist/desktop/SketchForge-Setup-*-x64.exe.blockmap
dist/desktop/latest.yml
if-no-files-found: error
- name: Store Linux artifacts
if: matrix.platform == 'linux'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: |
dist/desktop/SketchForge-*.AppImage
dist/desktop/latest-linux.yml
if-no-files-found: error
attach:
name: Attach packages to release
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.sha }}
- name: Resolve release metadata
id: version
shell: bash
env:
INPUT_VERSION: ${{ inputs.version }}
TAG_NAME: ${{ github.ref_name }}
EVENT_NAME: ${{ github.event_name }}
run: |
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
version="${INPUT_VERSION#v}"
tag="v$version"
else
tag="$TAG_NAME"
version="${tag#v}"
fi
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "Invalid release version: $version" >&2
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Ensure release tag exists
if: github.event_name == 'workflow_dispatch'
env:
TAG: ${{ steps.version.outputs.tag }}
SOURCE_SHA: ${{ github.sha }}
run: |
git fetch --tags --force
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo "$TAG already exists."
else
git tag "$TAG" "$SOURCE_SHA"
git push origin "$TAG"
fi
- name: Download Windows artifacts
uses: actions/download-artifact@v4
with:
name: desktop-windows
path: dist/release
- name: Download Linux artifacts
uses: actions/download-artifact@v4
with:
name: desktop-linux
path: dist/release
- name: Create draft release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
existing=$(gh release view "$TAG" --json isDraft 2>/dev/null || true)
if [ -n "$existing" ]; then
is_draft=$(jq -r '.isDraft' <<< "$existing")
if [ "$is_draft" != "true" ]; then
echo "Release $TAG is already published. Refusing to replace it." >&2
exit 1
fi
echo "Using existing draft release $TAG."
else
gh release create "$TAG" --draft --verify-tag \
--title "SketchForge $VERSION" \
--notes "SketchForge desktop $VERSION"
fi
- name: Upload desktop packages
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: gh release upload "$TAG" dist/release/* --clobber
- name: Verify release assets
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
VERSION: ${{ steps.version.outputs.version }}
run: |
assets=$(gh release view "$TAG" --json isDraft,assets)
test "$(jq -r '.isDraft' <<< "$assets")" = "true"
names=$(jq -r '.assets[].name' <<< "$assets")
for expected in \
"SketchForge-Setup-$VERSION-x64.exe" \
"SketchForge-Setup-$VERSION-x64.exe.blockmap" \
"latest.yml" \
"SketchForge-$VERSION-x86_64.AppImage" \
"latest-linux.yml"; do
grep -Fxq "$expected" <<< "$names" || {
echo "GitHub release is missing $expected" >&2
exit 1
}
done
- name: Publish release as latest
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.version.outputs.tag }}
run: gh release edit "$TAG" --draft=false --latest